當我運行聯繫人列表項目時它發生。我不知道爲什麼會出現請幫助。不幸的是,應用程序已停止。當在真實設備上運行
-6
A
回答
0
這是因爲您使用的Android操作系統版本比棒棒糖大。
所以你要添加的權限爲您的聯繫人
公共無效askForContactPermission(){ 如果(Build.VERSION.SDK_INT> = Build.VERSION_CODES.M){ 如果(ContextCompat.checkSelfPermission(getActivity() ,Manifest.permission.READ_CONTACTS)= PackageManager.PERMISSION_GRANTED){
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(),
Manifest.permission.READ_CONTACTS)) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Contacts access needed");
builder.setPositiveButton(android.R.string.ok, null);
builder.setMessage("please confirm Contacts access");//TODO put real question
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onDismiss(DialogInterface dialog) {
requestPermissions(
new String[]
{Manifest.permission.READ_CONTACTS}
, PERMISSION_REQUEST_CONTACT);
}
});
builder.show();
// 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.
}
+0
沒有。 android 5.0.2版本是。 –
相關問題
- 1. Android應用程序不幸停止時,從真實設備運行
- 2. 不幸的是,應用程序已停止在某些Android設備
- 3. 不幸已在實際設備問題上停止了錯誤
- 4. 執行時出現「不幸的是,應用程序已停止」
- 5. 」不幸的是,應用程序名稱已停止。「 Android設備或模擬器
- 6. Android應用程序的虛擬設備上運行,但不是真實設備
- 7. 不幸的應用程序已停止 - 當OnClick事件運行時
- 8. Android應用程序未在仿真器上運行也不是真實設備
- 9. 不幸的是應用程序停止
- 10. 不幸的是,應用程序已經停止在登錄
- 11. 不幸的是應用程序已停止在模擬器
- 12. 不幸的是,應用程序已停止在Android模擬器 -
- 13. Android應用程序,不幸的應用程序已停止
- 14. 不幸停止應用程序停止
- 15. 在模擬器上運行APK:「不幸的是,YourAPP已停止。」
- 16. 不幸的是,應用程序已停止在Android應用程序的問題
- 17. 麻煩在真實設備上運行的應用程序
- 18. 不幸的是,當應用程序在genymotion模擬器上運行時,android已停止工作
- 19. 不幸的是,(我的應用程序)已停止。 Eclipse Android
- 20. 不幸的是,我的應用程序已停止
- 21. 不幸的是應用程序的名稱已停止
- 22. 不幸的是,我的應用程序已停止
- 23. 不幸的是,Organitza't(我的應用程序)已停止
- 24. 不幸的是(我的應用程序)已停止工作
- 25. 「不幸的是我的應用程序已停止」
- 26. 不幸的是你的應用程序已停止工作 - android
- 27. 「不幸的是,應用程序的名字已停止工作」
- 28. 不幸的是,我的Android應用程序已停止
- 29. 不幸的是您的應用程序已停止
- 30. 不幸的是應用程序的名字已停止錯誤
這裏瞭解如何提問:-http://stackoverflow.com/help/mcve –
請詳細說明您的問題得到適當的解決方案。 –