zoukankan      html  css  js  c++  java
  • [Android Studio篇][1] AS开发中遇到问题汇总

    1 在android新建文件,提示权限不够,增加权限 修改工程下 main/AndroidMainfest.xml增加

       <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>(这个是写文件的权限,默认是有读权限的)
        <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>(这个是创建文件/文件夹的权限)
    但是要注意这两行的位置:

    <?xml version="1.0" encoding="utf-8"?>

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="byd.eagle"
          android:versionCode="1"
          android:versionName="1.0">
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>  
        <application android:icon="@drawable/icon" android:label="@string/app_name">
        </application>
        <uses-sdk android:minSdkVersion="8" />
    </manifest>

     添加了读写权限后,发现还是报: java.io.FileNotFoundException: /sdcard/12.png (Permission denied)

    另外我在网上

    后来是:还要给应用添加权限:设置--应用---(test)---权限--存储空间(打开)

    private static final int REQUEST_EXTERNAL_STORAGE = 1;
    private static String[] PERMISSIONS_STORAGE = {
    android.Manifest.permission.
    READ_EXTERNAL_STORAGE,
    android.Manifest.permission.
    WRITE_EXTERNAL_STORAGE
    };
    public static void verifyStoragePermissions(Activity activity)
    {

    // Check if we have write permission
    int permission = ActivityCompat.checkSelfPermission(activity,
    android.Manifest.permission.
    WRITE_EXTERNAL_STORAGE);

    if (permission != PackageManager.PERMISSION_GRANTED) {
    // We don't have permission so prompt the user
    ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE,
    REQUEST_EXTERNAL_STORAGE);
    }

    }
    但是传参数的时候(不对,MainActivity.this)--不知道怎么改了
    http://blog.csdn.net/escic/article/details/52774762
    http://www.aichengxu.com/xitong/2508579.htm
    private static final int REQUEST_EXTERNAL_STORAGE = 1;
    private static String[] PERMISSIONS_STORAGE = {
    android.Manifest.permission.READ_EXTERNAL_STORAGE,
    android.Manifest.permission.WRITE_EXTERNAL_STORAGE
    };
    public static void verifyStoragePermissions(Activity activity)
    {

    // Check if we have write permission
    int permission = ActivityCompat.checkSelfPermission(activity,
    android.Manifest.permission.WRITE_EXTERNAL_STORAGE);

    if (permission != PackageManager.PERMISSION_GRANTED) {
    // We don't have permission so prompt the user
    ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE,
    REQUEST_EXTERNAL_STORAGE);
    }

    }
  • 相关阅读:
    路由的添加和删除
    extjs中的tabpanle下的combobox提交问题
    Asp.net下from认证统一认证配置
    ASP.NET权限管理系统(FrameWork) 1.0.8 Release
    Web网站架构设计
    手机6120C 玩仙剑dos版
    Extjs 4.07 对类型定义引发的匹配问题
    Supesoft权限管理系统(FrameWork) 1.0.9 Release
    Google静态地图如何显示两点之间路线1(简单路线)
    Chrome不支持showModalDialog模态对话框和无法返回returnValue的问题
  • 原文地址:https://www.cnblogs.com/liuzhipenglove/p/6854862.html
Copyright © 2011-2022 走看看