在我的应用程序中,我获得了用户的运行时权限。我的问题是,当获得用户的许可时,“不幸的是包安装程序已停止” 这是我的 Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="place.picker.mymarket">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_market_logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".LaunchActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".IntroductionSlider"
android:screenOrientation="portrait" />
<activity
android:name=".oneTimeValidation"
android:screenOrientation="portrait" />
<activity
android:name=".MainActivity"
android:screenOrientation="portrait" />
<activity
android:name=".MapsActivity"
android:screenOrientation="portrait" />
<activity
android:name=".list_my_posts"
android:label="deletion list"
android:screenOrientation="portrait" />
<activity
android:name=".Upload_to_server"
android:screenOrientation="portrait" />
<activity
android:name=".SharePost"
android:screenOrientation="portrait" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_login" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_place_api" />
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
<activity
android:name=".Nopost"
android:screenOrientation="portrait" />
<activity
android:name=".FeedbackActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".AboutUs"
android:screenOrientation="portrait" />
<activity
android:name=".FAQ"
android:screenOrientation="portrait" />
<activity android:name=".PostDesign"></activity>
</application>
这是我在java中的权限字符串数组
arr = new String[] {
Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_NETWORK_STATE};
以下是检查权限的方法
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int k=0;
for(String p:arr){
if(ActivityCompat.checkSelfPermission(IntroductionSlider.this,p)!= PackageManager.PERMISSION_GRANTED){
perms[k++]=p;
}
}
if(perms.length==0) {
startActivity(new Intent(IntroductionSlider.this, oneTimeValidation.class));
finish();
}else {
requestPerm(perms);
}
}
这是我的requestPerm()方法
private void requestPerm(String[] permis) {
ActivityCompat.requestPermissions(IntroductionSlider.this,permis,ALL_REQUEST_CODE);
}
这就是我所做的,但不要做什么问题,任何人都可以帮助我,请新手android.Thanks提前。
答案 0 :(得分:0)
我有同样的问题。我忘了在清单中添加相同的权限。我在清单中添加了这些权限以及迈克说。然后就行了。
如果您在课程中以编程方式提供权限,请确保您必须在AndroidManifest.xml文件中声明相同的权限。