編輯:關於android開發
在API23+以上,不止要在AndroidManifest.xml裡面添加權限
1 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 2 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
還要在JAVA代碼中請求權限:
1 // Storage Permissions 2 private static final int REQUEST_EXTERNAL_STORAGE = 1; 3 private static String[] PERMISSIONS_STORAGE = { 4 Manifest.permission.READ_EXTERNAL_STORAGE, 5 Manifest.permission.WRITE_EXTERNAL_STORAGE }; 6 7 /** 8 * Checks if the app has permission to write to device storage 9 * 10 * If the app does not has permission then the user will be prompted to 11 * grant permissions 12 * 13 * @param activity 14 */ 15 public static void verifyStoragePermissions(Activity activity) { 16 // Check if we have write permission 17 int permission = ActivityCompat.checkSelfPermission(activity, 18 Manifest.permission.WRITE_EXTERNAL_STORAGE); 19 20 if (permission != PackageManager.PERMISSION_GRANTED) { 21 // We don't have permission so prompt the user 22 ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, 23 REQUEST_EXTERNAL_STORAGE); 24 } 25 }
在保存的方法前面調用即可
官方文檔:http://developer.android.com/training/permissions/requesting.html
如何用Sencha Touch打包Android的APK 什麼是Sencha Touch 前不久基於JavaScript編寫的Ajax框架ExtJS,將現有的ExtJ
A DB2 Performance Tuning Roadmap --LOG INTRODUCTION本文的內容是在整理報表時,對DB2 STAT LOG AVITIVI
Android基礎入門教程——10.10 傳感器專題(1)——相關介紹 Android基礎入門教程——10.10 傳感器專題(1)—&
Android IPC機制(五)用Socket實現跨進程聊天程序 1.Socket簡介 Socket也稱作“套接字“,是在應用層和傳輸層之間的