【发布时间】:2021-01-24 11:27:22
【问题描述】:
我之前的应用有很多activity,其中一些被声明为exported true,以便其他应用可以通过intent filter调用它们。 其中一些还具有特定权限,这也设置在我的活动中。
现在,我正在开发一个使用单一活动的应用程序。 所以,我很想知道如何在单一活动设计中处理这个权限问题,因为我只有一个活动。
以前,在多个活动中,我可以轻松地在特定活动中设置权限。我怎么能在这里处理这个? 我是新手。我搜索了很多,但没有找到任何线索。
编辑:
Multiple activities declaration:
<permission
android:name="com.example.permission"
android:protectionLevel="signatureOrSystem"
tools:ignore="SignatureOrSystemPermissions"
/>
// Activity 1: With permission, exported = true
<activity
android:name=".place"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout"
android:exported="true"
android:label="place"
android:permission="com.example.permission" // Sets a permission
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
<intent-filter>
<action android:name="com.action.places" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
// Activity 2: With no permission, exported = true
<activity
android:name="userCheck"
android:configChanges="mcc|mnc|keyboard|keyboardHidden|orientation"
android:exported="true"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
<intent-filter>
<action android:name="com.confirm.passowrd" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
现在,我想转向单一活动。
// Single activity: exported = true. How can i handle permission for place action?
<activity
android:name="com.example.singleActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- Place -->
<action android:name="com.action.places"/> // How can i handle permission for this action?
<!-- UserCheck -->
<action android:name="com.confirm.passowrd" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
【问题讨论】:
-
我不太明白你的问题。如果您的应用只有一个
Activity,那么您需要向该Activity请求所有权限。或者您是否在询问访问您的活动所需的自定义权限?请编辑您的问题并举例说明您遇到的问题。 -
@DavidWasser 请立即查看
标签: android android-activity android-manifest android-permissions