Android 兼容性问题

Android 兼容性问题整理,持续更新

1.vivo手机默认把快捷方式关闭了,基本上在这个手机上创建快捷方式是行不通的,金立更狠,连快捷方式的管理都不提供,直接干掉。无解
2.三星手机调用手机拍照后出现横竖屏切换的问题。
解决方案:

public static int getPictureDegree(String path) {
    int degree = 0;
    try {
        ExifInterface exifInterface = new ExifInterface(path);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_90:
            degree = 90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            degree = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_270:
            degree = 270;
            break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return degree;
}

public static Bitmap roateBitmap(Bitmap bitmap, int degree) {
    if (degree == 0) {
        return bitmap;
    }
    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    Bitmap bmp = Bitmap.createBitmap(bitmap, 0, 0,    bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    return bmp;
}

int degree = getPictureDegree(filePath);
return roateBitmap(thumbBitmap, degree);

  1. 在小米4手机上,不能跑UIAumator写的测试用例,运行后报异常:
    Test running failed: Instrumentation run failed due to ‘java.lang.SecurityException’。但可以跑Espresso的测试用例
  2. 又是小米4,醉了,monkey测试的时候,monkey进程直接挂掉,crash异常:
02-06 19:17:13.010 17091-17091/? E/AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
                                                   java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
                                                       at android.os.Parcel.readException(Parcel.java:1620)
                                                       at android.os.Parcel.readException(Parcel.java:1573)
                                                       at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:434)
                                                       at android.hardware.input.InputManager.injectInputEvent(InputManager.java:798)
                                                       at com.android.commands.monkey.MonkeyMotionEvent.injectEvent(MonkeyMotionEvent.java:188)
                                                       at com.android.commands.monkey.Monkey.runMonkeyCycles(Monkey.java:1128)
                                                       at com.android.commands.monkey.Monkey.run(Monkey.java:622)
                                                       at com.android.commands.monkey.Monkey.main(Monkey.java:485)
                                                       at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
                                                       at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:308)
02-06 19:17:13.011 17091-17091/? E/AndroidRuntime: Error reporting crash
                                                   java.lang.RuntimeException: Bad file descriptor
                                                       at android.os.BinderProxy.transactNative(Native Method)
                                                       at android.os.BinderProxy.transact(Binder.java:503)
                                                       at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4429)
                                                       at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:145)
                                                       at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                                                       at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
发布了33 篇原创文章 · 获赞 8 · 访问量 1万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览