从Google Play商店下载时,我的应用程序未要求权限。我已在清单文件中指定了位置权限

西德斯·阿罗拉

维护文件

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true" />

<application
    android:allowBackup="true"
    android:hardwareAccelerated="true"
    android:icon="@mipmap/hero3"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name="info.food360.nikhil.splash"
        android:configChanges="orientation|screenSize"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="info.food360.nikhil.MainActivity"
        android:windowSoftInputMode="adjustPan|adjustResize"
        android:theme="@style/AppTheme.NoActionBar"/>
    <activity
        android:name="info.food360.nikhil.DesActivity"
        android:configChanges="orientation|screenSize"
        android:label="DestinationActivity" />
    <activity android:name="info.food360.nikhil.Suggestion" />
    <activity android:name="info.food360.nikhil.LocationWork" />
    <activity android:name="info.food360.nikhil.logicBehind"></activity>
</application>

我的应用需要位置许可,我以为Google Play商店会在下载时询问您,但是用户必须手动设置位置。GooglePlay商店应问我应该在代码中添加什么内容?

列维·莫雷拉(Levi Moreira)

如果您使用的是Android API版本23或更高版本,则需要在运行时要求权限要请求权限,您应该在使用使用权限的功能之前立即执行以下操作:

int MY_PERMISSIONS_REQUEST_LOCATION = 123;
if (ContextCompat.checkSelfPermission(thisActivity,
        Manifest.permission.ACCESS_FINE_LOCATION)
        != PackageManager.PERMISSION_GRANTED) {
    //app doesn't have permission yet

     ActivityCompat.requestPermissions(thisActivity,
                new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
                MY_PERMISSIONS_REQUEST_LOCATION);
} else {
    // Permission has already been granted
}

然后覆盖onRequestPermissionsResult以查看用户是否已授予权限:

public void onRequestPermissionsResult(int requestCode,
        String permissions[], int[] grantResults) {
    switch (requestCode) {
        case MY_PERMISSIONS_REQUEST_LOCATION: {

            if (grantResults.length > 0
                && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                // permission was granted
            } else {
                // permission denied
            }
            return;
        }

    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

有没有一种方法可以让我知道用户应向我的Google Play要求哪个权限才能接受我的应用程序?

我的应用程序更新未显示在Google Play商店中

在Google Play下载我的应用程序时,打包文件无效

应用程序未显示在Google Play商店中

在Google Play商店中更新我的应用程序时,如何保持我的应用程序通知显示?

从Google Play下载我的应用程序时,一些(但不是全部)用户会收到“打包文件未正确签名”的信息

如何直接从我的Android应用程序打开Google Play商店?

为什么我不能在Google Play商店中找到官方的Github移动应用程序?

Google Play商店表示兼容(与我的应用程序)的设备减少了

在Google Play商店上更新应用程序时,我的共享首选项正在删除

如何在我的Android应用程序中撤消Google帐户访问权限?

Google Play商店拒绝了我的应用

无法提取从Google Play应用程序下载的obb文件

我可以将我的应用程序的第二个版本放到 Google Play 商店吗

通过我自己的应用程序的 API 从 google play 获取下载数据

我在 google play 上发布的应用程序在用户下载时会显示一个 android 文件。我怎样才能解决这个问题?

如果我不使用 Google Play 商店,是否可以仅使用公钥创建应用程序

在使用Firebase / firestore服务的Google Play商店中发布应用程序时,我需要做任何额外的工作吗?

我的应用程序在Google Play商店中看不到三星银河笔记4

为什么 google play 商店稳定性报告说我的应用程序在一台设备上崩溃了

为什么我的应用程序的评论未显示在Google Play上,而是显示在我的Play控制台中?

当要求启动我的应用程序到Google Assistant时,我收到一条有关google共享数据的消息,阻止启动该应用程序

如何限制谁可以在Google Play商店中下载我的应用?

如何跟踪我的Android应用相对于Google Play商店网站上的下载的印象?

我的应用程序没有资格使用请求的权限 (SMS) Google 新政策 (Ionic 3)

我在 Google Play 商店中找不到我的应用

如何在我的应用程序中实现Google Play商店应用程序的工具栏和状态栏?

Google Play开发者控制台:授予对单个应用程序的读取权限

从Google Play商店升级应用程序,显示为“打开”