我試圖[執行一點點權限檢查的測試,但它 給了我這個錯誤:爲什麼checkSelfPermissions()返回null? (安卓)
Attempt to invoke virtual method 'int android.content.Context.checkPermission(java.lang.String, int, int)' on a null object reference at com.doppler.stackingcoder.pechhulp.PechhulpActivity.makeCall(PechhulpActivity.java:238)
這裏是我的方法,其中出現的錯誤:
@TargetApi(Build.VERSION_CODES.M)
public void makeCall() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED) {
startActivity(callIntent);
} else {
Toast.makeText(this, "Geen toestemming om te bellen", Toast.LENGTH_SHORT).show();
}
}
我希望有人知道這個問題,提前致謝!
編輯:全班同學:https://gist.github.com/soufyanekaddouri/6363463ef1fb1988af4fb6f9e7e8b228
我打電話的方法,(MakeCall函數)從另一個類,稱爲CustomDialogClass.java。這裏要說的是類的要點:
https://gist.github.com/soufyanekaddouri/bcf045f80e4f9c9b95994dafdf1ba682
? –
Android 6.0所以我認爲23級 – Stackingcoder