Android版本适配

Android4.4:

uri转path需要适配  参考:https://www.cnblogs.com/kangweifeng/p/11264217.html

Android5.0适配:
分包适配 :在5.0及以上在appgradle文件中配置multiDexEnabled true即可,但是5.0以下需要倒入jar,然后在Applicationattch方法中进行初始化

Android6.0适配:

权限配置:敏感权限需动态配置

Android7.0:
Uri.fromFile()适配 -〉使用FileProvider进行适配; 参考:https://www.jianshu.com/p/1e290902e0f5
Android出于安全考虑关闭了网络/拍照/录像系统广播;

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中注册的广播不能使用隐式,需要明确指定。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值