相关疑难解决方法(0)

在unity3d中实现Android 6.0权限

我已经安装了Android支持库,但是在developer.android网站上说要在我的项目中实现它我需要编辑我没有的build.gradle文件,因为它是一个Unity项目.

我创建了一个build.gradle文件,复制了这个网站的内容:http://gradleplease.appspot.com/ 我将该文件放在我的Unity项目的根目录上,但当我尝试使用该库时,它不起作用

if (ContextCompat.checkSelfPermission(thisActivity,
                                      Manifest.permission.READ_CONTACTS)
    != PackageManager.PERMISSION_GRANTED) {

    // Should we show an explanation?
    if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
                                                            Manifest.permission.READ_CONTACTS)) {

        // Show an expanation to the user *asynchronously* -- don't block
        // this thread waiting for the user's response! After the user
        // sees the explanation, try again to request the permission.

    } else {

        // No explanation needed, we can request the permission.

        ActivityCompat.requestPermissions(thisActivity,
                                          new String[]{Manifest.permission.READ_CONTACTS},
        MY_PERMISSIONS_REQUEST_READ_CONTACTS);

        // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
        // app-defined int constant. The callback method …
Run Code Online (Sandbox Code Playgroud)

permissions android unity-game-engine

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

permissions ×1

unity-game-engine ×1