1、因为deviceid的限制,所有各大三方sdk需要更新,比如个推、微信支付、环信、友盟,Basesdk

2、Using WebView from more than one process at once with the same data directory is not supported

这个错误是webview多进程使用导致,在api28以上,需要对webview  目录进行控制

@RequiresApi(api = 28)public static void webviewSetPath(Context context) {    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {        String processName = getProcessName(context);        if (!packageNameocessName)) {//判断不等于默认进程名称            WebView.setDataDirectorySuffix(processName);        }    }}public static String getProcessName(Context context) {    if (context == null) return null;    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);    for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) {        if (processInfo.pid == android.os.Process.myPid()) {            return processInfo.processName;        }    }    return null;}

3、文件系统:

获取本地根目录文件夹的适配:

public static  File getDiskCacheDir(String uniqueName) {        File file = null;        String cachePath = null;        Context context = YokaApplication.context;        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){            cachePath = context.getExternalFilesDir(null).getAbsolutePath();        }else{            if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())                    || !Environment.isExternalStorageRemovable()) {                if(context.getExternalCacheDir() != null){                    cachePath = context.getExternalCacheDir().getPath(); //路径为:/mnt/sdcard//Android/data/< package name >/cach/…                }else{                    try {                        cachePath  = Environment.getExternalStorageDirectory().getPath();   //SD根目录:/mnt/sdcard/ (6.0后写入需要用户授权)                    }catch (Exception e){                        cachePath = context.getCacheDir().getPath();  //路径是:/data/data/< package name >/cach/…                    }                }            } else {                cachePath = context.getCacheDir().getPath();  //路径是:/data/data/< package name >/cach/…            }        }        file = new File(cachePath + File.separator + uniqueName);        if(file.exists()){            return file;        }else {            if(file.mkdir()){               return file;            }        }        return file;    }

4、因为文件限制

BitmapFactory.decodeFile这一类的方法不能用了,下面提供方法获取本地图片的bitmap
//根据图片路径获取bitmap    public static Bitmap getBitmapFormUrl(String url){        Bitmap bitmap = null;        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){            File file = new File(url);            File rootFile = YokaApplication.context.getExternalFilesDir(null);            if(file.getAbsolutePath().contains(rootFile.getAbsolutePath())){                bitmap = BitmapFactory.decodeFile(url);            }else {                Uri uri = getImageContentUri(url);                bitmap = getBitmapFromUri(uri);            }        }else {            bitmap = BitmapFactory.decodeFile(url);        }        return bitmap;    }public static Bitmap getBitmapFromUri( Uri uri) {        try {            ParcelFileDescriptor parcelFileDescriptor =                    YokaApplication.context.getContentResolver().openFileDescriptor(uri, "r");            FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();            Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);            parcelFileDescriptor.close();            return image;        } catch (Exception e) {            e.printStackTrace();        }        return null;    }    public static Uri getImageContentUri(String path) {        Cursor cursor = YokaApplication.context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,                new String[] { MediaStore.Images.Media._ID }, MediaStore.Images.Media.DATA + "=? ",                new String[] { path }, null);        if (cursor != null && cursor.moveToFirst()) {            int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));            return Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "" + id);        } else {            // 如果图片不在手机的共享图片数据库,就先把它插入。            if (new File(path).exists()) {                ContentValues values = new ContentValues();                values.put(MediaStore.Images.Media.DATA, path);                return YokaApplication.context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);            } else {                return null;            }        }    }

 

 

更多相关文章

  1. CheckBox控件中background和button的区别
  2. Android(安卓)ZoomControls缩放控件
  3. Android(安卓)网络显示图片 通过代理访问
  4. Flutter Android(安卓)打包发布
  5. Android(安卓)-- 重置Bitmap大小&&Bitmap转角度
  6. 关于Gallery使用
  7. Android(安卓)Camera应用初探二
  8. Android控件之ImageButton
  9. Java 软引用及在Android中的应用

随机推荐

  1. android R.java
  2. Android日志分析工具的开发介绍
  3. MTK android配置LCD背光和LED,调试方法
  4. Android NDK HelloWorld配置(Eclipse)
  5. 22、Android之 使用手机的 GPS 功能
  6. android解析XML总结(SAX、Pull、Dom三种方
  7. Android API Guides---AIDL
  8. Android:Button同时设置OnLongClick、OnCl
  9. 代号Pie!Android 9.0那些开发者必须知道的
  10. 很容易理解的Android AsyncTask源码与工