Android4.4:
uri转path需要适配 参考:https://www.cnblogs.com/kangweifeng/p/11264217.html
Android5.0
适配:
分包适配 :在5.0
及以上在app
的gradle
文件中配置multiDexEnabled true
即可,但是5.0
以下需要倒入jar
,然后在Application
的attch
方法中进行初始化
Android6.0适配:
权限配置:敏感权限需动态配置
Android7.0:Uri.fromFile()
适配 -〉使用FileProvider
进行适配; 参考:https://www.jianshu.com/p/1e290902e0f5Android
出于安全考虑关闭了网络/拍照/录像系统广播;
Android8.0:
安装适配(唤不起系统安装器) :在 AndroidManifest.xml中申明<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />权限
Notification
适配:
private static NotificationManager manager;
public static final String NOTIFICATION_CHANNEL = "your app pkg name";
private static final String NOTIFICATION_CHANNEL_NAME = "App Channel";
1.创建channel
private static void createChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notifyChannel = new NotificationChannel(NOTIFICATION_CHANNEL,
NOTIFICATION_CHANNEL_NAME,
NotificationManager.IMPORTANCE_DEFAULT);
notifyChannel.setLightColor(Color.GREEN);
notifyChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
manager.createNotificationChannel(notifyChannel);
}
}
2. 获取 Notification.Builder
private Notification.Builder getNotificationBuilder(Context sourceContext) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return new Notification.Builder(sourceContext, NOTIFICATION_CHANNEL);
} else {
return new Notification.Builder(sourceContext);
}
}
权限适配-〉读写权限分离
Service
启动方式适配 -〉需要使用startForegroundService()
启动服务;
广播适配 -〉AndroidManifest.xml
中注册的广播不能使用隐式,需要明确指定。