Android 12 中一些新的特性

Android 12中的一些新特性

一、意图过滤器

文档中为 intent filters
在manifest文件的activity标签内,使用 exported 来表明是否能够被其他应用启动,设置为TRUE则可以,为FALSE则只能被本应用调用启动

<activity android:name="MainActivity" android:exported="true">
    <!-- This activity is the main entry, should appear in app launcher -->
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity android:name="ShareActivity" android:exported="false">
    <!-- This activity handles "SEND" actions with text data -->
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
    </intent-filter>
</activity>

二、应用休眠

文档中称为Hibernation,指应用在后台一段时间之后将会进入休眠模式,缓存和权限会被重置

三、限制后台应用的前台权限

加强了对后台应用的限制,现在只有少数情况可以在后台启动前台服务,检查应用程序能否执行后台启动的方法如下:

在测试的虚拟机中输入:
adb shell device_config put activity_manager \
  default_fgs_starts_restriction_notification_enabled true

四、加强对Notification的限制

在用户点击通知栏之后,应用无法在接受广播broadcast 或者通过后台service来调用startActivity()方法,如果需要拉起activity则需要创建PendingIntent将通知和之后需要调用的activity相关联。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值