Android权限安全(5)组件的android:exported属性

时间:2022-09-23 02:27:45

Android四大组件都有 android:exported 属性

  android:exported="true" 时 表示该组件是公开的,其它组件可以访问这个组件

  android:exported="false" 时表示该组件是私有的,只有自己或有相关权限的其它组件可以访问

     <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:exported="false"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

它的默认值;

  组件在mainifest.xml中定义时,如果没有 <intent-filter> 那么就是 true