當我運行聯繫人列表項目時它發生。我不知道爲什麼會出現請幫助。不幸的是,應用程序已停止。當在真實設備上運行
-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. 不幸已在實際設備問題上停止了錯誤
- 3. 執行時出現「不幸的是,應用程序已停止」
- 4. 不幸的應用程序已停止 - 當OnClick事件運行時
- 5. 不幸的是,應用程序已停止在Android模擬器 -
- 6. 不幸停止應用程序停止
- 7. 不幸的是,應用程序已停止在Android應用程序的問題
- 8. 不幸的是,當應用程序在genymotion模擬器上運行時,android已停止工作
- 9. 不幸的是(我的應用程序)已停止工作
- 10. 不幸的是,(我的應用程序)已停止。 Eclipse Android
- 11. 「不幸的是我的應用程序已停止」
- 12. 不幸的是(應用程序)已經停止
- 13. 爲什麼我不幸的是應用程序已停止....?
- 14. 不幸的是,應用程序m-jadwal已停止
- 15. 不幸的是,應用程序已停止
- 16. 不幸的是應用程序已經停止
- 17. 不幸的是應用程序已停止 - android.os.NetworkOnMainThreadException
- 18. 不幸的是,HelloAndroid應用程序已停止
- 19. 不幸的是,應用程序已停止
- 20. Android Studio - 不幸的是。應用程序已停止
- 21. 不幸的是,「應用程序名稱」已停止。 (Eclipse,Android)
- 22. 不幸的是,應用程序已停止?
- 23. 不幸的是,應用程序已停止Xamarin C#Android
- 24. Android-不幸的是應用程序已經停止
- 25. 不幸的是,應用程序已停止工作
- 26. 不幸的是應用程序已經停止,錯誤doinbackground()
- 27. 不幸的是,該應用程序已停止Android Studio
- 28. 在真實設備上運行應用程序vs模擬器
- 29. 如何在真實設備上運行android應用程序?
- 30. 在真實設備上運行Xamarin.iOS應用程序
這裏瞭解如何提問:-http://stackoverflow.com/help/mcve –
請詳細說明您的問題得到適當的解決方案。 –