zoukankan      html  css  js  c++  java
  • Android7.0 新特性

    删除了三个隐式广播  

    1.监听网络变化的广播 CONNECTIVITY_ACTION,在Manifest.xml中注册的 不会受到,在前台运行的程序 registerReceiver()注册的广播可以接收到;

    2.应用程序无法发送或接收 ACTION_NEW_PICTURE(拍照) 或 ACTION_NEW_VIDEO(录像) 广播。此项优化会影响所有应用,而不仅仅是面向 Android N 的应用;

    FileProvider的适配

    1.图片裁剪 由接收File Uri变为 Content Uri;

      

    public static Uri getImageContentUri(Context context, File imageFile) {
        String filePath = imageFile.getAbsolutePath();
        Cursor cursor = context.getContentResolver().query(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                new String[] { MediaStore.Images.Media._ID },
                MediaStore.Images.Media.DATA + "=? ",
                new String[] { filePath }, null);
    
        if (cursor != null && cursor.moveToFirst()) {
            int id = cursor.getInt(cursor
                    .getColumnIndex(MediaStore.MediaColumns._ID));
            Uri baseUri = Uri.parse("content://media/external/images/media");
            return Uri.withAppendedPath(baseUri, "" + id);
        } else {
            if (imageFile.exists()) {
                ContentValues values = new ContentValues();
                values.put(MediaStore.Images.Media.DATA, filePath);
                return context.getContentResolver().insert(
                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
            } else {
                return null;
            }
        }
    }
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(getImageContentUri(context , inputfile), IMAGE_UNSPECIFIED);//自己使用Content Uri替换File Uri
    intent.putExtra("crop", "true");
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("outputX", 180);
    intent.putExtra("outputY", 180);
    intent.putExtra("scale", true);
    intent.putExtra("return-data", false);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outputfile));//定义输出的File Uri
    intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
    intent.putExtra("noFaceDetection", true);
    startActivityForResult(intent, RequestCode);

    转自:http://www.open-open.com/lib/view/open1474615893731.html  

  • 相关阅读:
    ES6 常用总结(前端开发js技术进阶提升总结)
    web前端之es6对象的扩展
    ES6数组及对象遍历的新增方法 entries(),keys() 和 values()
    关于日期
    最近遇到的几个小东西
    求模
    同步 异步请求的认识
    变量名和函数名声明提升
    机顶盒前端开发小结
    js节点使用 碎片节点
  • 原文地址:https://www.cnblogs.com/xxwn/p/6038746.html
Copyright © 2011-2022 走看看