我需要從我的應用程序調用給定的電話號碼。Android請求權限不會顯示對話框
所以我必須驗證通話權限。
但對話框顯示在我的應用程序中,直接它是拒絕功能。我在這裏做了什麼問題。請查看我的代碼並給我一個解決方案。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CALL_PHONE}, 105);
} else {
startActivity(callIntent);
}
} else {
startActivity(callIntent);
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case 105:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
callJobseeker();
} else {
Toast.makeText(getApplicationContext(), "You cannot make a call.Because call permission is denied", Toast.LENGTH_SHORT).show();
}
break;
}
}
清單文件
我給喜歡權限:
<uses-permission android:name="android.permission.CALL_PHONE" />
<permission android:name="com.example.permission.CALL_PHONE"
/>
在哪個android os中檢查? – NilayDani
@NilayDani正在檢查6.0版本 –
@KrishnaVeni爲什麼你有寫權限com.jobsearchtry.permission.CALL_PHONE –