Android12适配

1.给Manifest的四大组件配置属性"exported",如果有标签,需要配置成true,其他默认false。如果没有将会抛出异常。

Targeting S+ (version 10000 and above) requires that an explicit value for android:exported be defined when intent filters are present

   <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

2.在 Android 12 中创建 PendingIntent 的时候,使用 PendingIntent.FLAG_MUTABLE 或 PendingIntent.FLAG_IMMUTABLE 标志,Android Studio 强烈建议PendingIntent.FLAG_IMMUTABLE。因为抛出的异常里面就是这么说的。

java.lang.IllegalArgumentException: com.zhenpin.luxurystore: Targeting S+ (version 31 and above) requires that one of be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

PendingIntent contentIntent = PendingIntent.getActivity(
App.getInstance(), 0, intent, PendingIntent.FLAG_IMMUTABLE);

3.Bluebooth蓝牙权限变更,在31及以上请添加一下内容,动态判断申请权限

    
    
    
    
    

你可能感兴趣的:(Android适配,android,studio,android,android-studio)