图片不显示的问题
tomcat开了,界面是空白的
tomcat开了,界面是空白的
2019-06-03
Android 5.0以上,除了在 AndroidManifest.xml 中加 读写权限外
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
还需要在代码中增加手动增加权限申请的代码:
public static void verifyStoragePerssion(Activity activity){ int writePerssion = ActivityCompat.checkSelfPermission(activity,Manifest.permission.WRITE_EXTERNAL_STORAGE); int readPerssion = ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE); if(writePerssion != PackageManager.PERMISSION_GRANTED || readPerssion != PackageManager.PERMISSION_GRANTED){ ActivityCompat.requestPermissions(activity, PERMISSIONS_STORGE, REQUEST_EXTERNAL_STORAGE); } }
其中 REQUEST_EXTERNAL_STORAGE 和 PERMISSIONS_STORGE 定义如下:
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORGE = { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE };
举报