错误:(179,28)错误:找不到符号方法requestPermissions(ApproveActivity,String [],int)

时间:2017-08-11 09:37:32

标签: android

H:\机器人\项目\ FileTracker \应用\ SRC \主\的java \ COM \示例\ filetracker \ ApproveActivity.java 错误:(169,28)错误:找不到符号方法shouldShowRequestPermissionRationale(ApproveActivity,String) 错误:(179,28)错误:找不到符号方法requestPermissions(ApproveActivity,String [],int) 错误:(349,1)错误:方法不会覆盖或实现超类型的方法 错误:任务':app:compileDebugJavaWithJavac'执行失败。

  

编译失败;有关详细信息,请参阅编译器错误输出。

java文件(ApproveActivity.java)

public void EnableRuntimePermissionToAccessCamera()
 {

        if (ActivityCompat.shouldShowRequestPermissionRationale(ApproveActivity.this,Manifest.permission.CAMERA))
        {

            // Printing toast message after enabling runtime permission.
            Toast.makeText(ApproveActivity.this,"CAMERA permission allows us to Access CAMERA app", Toast.LENGTH_LONG).show();

        }
        else
        {

            ActivityCompat.requestPermissions(ApproveActivity.this,new String[]{Manifest.permission.CAMERA}, RequestPermissionCode);

        }
 }

的build.gradle(Module.app)

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "26.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.android.support:appcompat-v7:19.1.0'
}

1 个答案:

答案 0 :(得分:-1)

在项目中导入它;

import android.support.v4.app.ActivityCompat;