- 博客(13)
- 收藏
- 关注
原创 android调用Camera.open方法报错“Too many cameras already open”
使用相机时调用 Camera.open(defaultCameraId)其中defaultCameraId为相机要打开的目标设备,即为前后摄像头,一般0为主摄像头(后置),1为前置。有时候会出现报错Too many cameras already open, cannot open camera "0"'这是来自于android的报错,意思为相机被占用了(可以验证,切换到...
2020-04-14 11:23:33
2657
原创 android e.printStackTrace()异常处理
处理异常的时候不要写e.printStackTrace(),改成Log.e(TAG,Log.getStackTraceString(e));这样才会方便调试
2019-11-19 11:24:35
682
原创 android加载动画,不占用资源
protected AlertDialog alertDialog=null; public void lock(){ if(alertDialog==null){ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCa...
2018-07-11 17:48:20
745
原创 android 控件阴影
在xml文件中设置属性android:translationZ="3dp"设置控件高度,只兼容5.0以上的版本也可以与android:elevation="3dp"搭配使用
2018-07-11 17:42:51
319
转载 android 键盘遮挡
使用AndroidBug5497Workaround解决键盘遮挡问题网上的一个类的办法把AndroidBug5497Workaround类复制到项目中在需要填坑的activity的onCreate方法中添加一句AndroidBug5497Workaround.assistActivity(this)即可。public class AndroidBug5497Workaround { //...
2018-06-10 17:46:20
222
原创 android webview 手机兼容问题
其他手机上显示的H5内容没问题,个别手机出现排版乱序问题,辗转几日,终于发现是手机字体大小设置问题!!设置webview 缩放为100% 解决。myweb.getSettings().setTextZoom(100);//设置webview缩放比例很气......
2018-05-28 15:44:26
2626
1
原创 android webview不支持input type=file 标签解决办法
项目中遇到 H5的input type="file" 标签在android的webview中失效,查了一下是安卓禁用掉了 重写webview 的WebChromeClient 可以解决 webView.setWebChromeClient(new WebChromeClient(){ //For 3.0+ Devices (Start) // onActivityResu...
2018-05-23 15:51:25
10381
3
原创 android 滑动控件 ViewFlipper
<ViewFlipper android:id="@+id/vf" android:layout_width="match_parent" android:layout_height="match_parent" android:autoStart="true" android:flipInterval="3000" android:inAni..
2018-05-03 17:00:13
303
原创 webview造成窗体泄漏
项目中遇到的,发现的办法xml中不写webview控件,要动态生成webview所以只需要写一个写一个LinearLayout,然后在代码中new一个webview控件,一定使用getapplicationcontext,然后通过addview添加进去,在activity的ondestory中处理就可以了myweb=new WebView(getApplicationContext());webl...
2018-04-25 16:57:14
306
转载 使用SharedPreferences保存list
先把对象转成Gson,Gson转成Json串,最后键值对保存import android.content.Context;import android.content.SharedPreferences;import android.util.Log;import com.google.gson.Gson;import com.google.gson.JsonArray;impor...
2018-03-27 12:59:12
450
原创 android 权限动态申请
项目需求中遇到的 问题来自于用户会手动禁止app的权限,所以在使用某些权限的时候要判断一下当前app是否授权直接代码记录// 要申请的权限private String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};这个是读写权限判断是否有权限private boolean quanxian(){ // 版本判断。...
2018-03-27 12:00:15
3593
原创 popupWindow在5.0版本以下不显示的问题
5.0之前必须设置宽高在6.0版本以上直接使用setcontentview即可另外一种解决办法是在xml布局中添加background图片popupWindow.setContentView(listView);popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);popupWindow.setWidth(ViewGroup.L...
2018-03-27 11:48:50
1371
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人