android开发遇到的问题

1.在4.4版本以上ui中,设置了

<item name="android:windowIsTranslucent">true</item>

<item name="android:windowNoTitle">true</item>

时候,布局会跑到状态栏,在layout布局中加上android:fitsSystemWindows="true",这样就不会了;

2.在使用httpclient的时候,传入的url中出现了空格参数,导致错误很难发现,在请求url时候,把空格进行转换

3.需要预览自定义布局,加上xmlns:app="http://schemas.android.com/apk/res/com.xx.xx"

4.使用PopupWindow显示ui的方法不能在onCreate onResume中调用,如果要用需要重新开一个线程

5.androidN文件跨应用传递,如拍照传入file,安装app传入file,需要加上文件鉴权

xml文件夹加入文件如下:

<Resources>
    <paths xmlns:android="http://schemas.android.com/apk/res/android">
        <external-path path="" name="external_files"/>
        <cache-path path="" name="cache_files" />
        <external-cache-path name="external_cache_file" path=""/>
    </paths>
</Resources>

AndroidManifest.xml加入配置

<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="${applicationId}.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths"/>
</provider>

启动照相机:

try {
    // 来自相机
    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // 下面这句指定调用相机拍照后的照片存储的路径
    //getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
    File file = new File(Environment.getExternalStorageDirectory(),""+System.currentTimeMillis());
    Uri fileUri = Uri.fromFile(file);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {//androidN以上走此方法
        String sFileProvider = String.format("%s.fileprovider", getPackageName());
        fileUri = FileProvider.getUriForFile(this, sFileProvider, file);
        cameraIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
    startActivityForResult(cameraIntent, 100);// CAMERA_OK是用作判断返回结果的标识
} catch (Exception ex) {
    ex.printStackTrace();
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值