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();
}