版本5.9.0更新相机胶卷的问题
创始人
2024-11-20 17:00:43
0

要解决版本5.9.0更新相机胶卷的问题,可以尝试以下代码示例:

  1. 使用新的相机胶卷API:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    // 使用新的相机胶卷API
    Uri collection = MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
    String[] projection = new String[]{MediaStore.Video.Media._ID, MediaStore.Video.Media.DISPLAY_NAME};
    String selection = null;
    String[] selectionArgs = null;
    String sortOrder = null;

    try (Cursor cursor = getContentResolver().query(collection, projection, selection, selectionArgs, sortOrder)) {
        if (cursor != null) {
            while (cursor.moveToNext()) {
                long id = cursor.getLong(cursor.getColumnIndex(MediaStore.Video.Media._ID));
                String name = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DISPLAY_NAME));
                // 处理相机胶卷中的视频
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
} else {
    // 使用旧的相机胶卷API
    String[] projection = new String[]{MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA};
    String selection = null;
    String[] selectionArgs = null;
    String sortOrder = null;

    try (Cursor cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, selection, selectionArgs, sortOrder)) {
        if (cursor != null) {
            while (cursor.moveToNext()) {
                long id = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media._ID));
                String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
                // 处理相机胶卷中的图片
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
  1. 使用第三方库来处理相机胶卷:
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    // 使用新的相机胶卷API
    Uri collection = MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
    String[] projection = new String[]{MediaStore.Video.Media._ID, MediaStore.Video.Media.DISPLAY_NAME};
    String selection = null;
    String[] selectionArgs = null;
    String sortOrder = null;

    try (Cursor cursor = getContentResolver().query(collection, projection, selection, selectionArgs, sortOrder)) {
        if (cursor != null) {
            while (cursor.moveToNext()) {
                long id = cursor.getLong(cursor.getColumnIndex(MediaStore.Video.Media._ID));
                String name = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DISPLAY_NAME));
                // 使用Glide加载相机胶卷中的视频
                Glide.with(this)
                        .load(Uri.withAppendedPath(collection, String.valueOf(id)))
                        .into(imageView);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
} else {
    // 使用旧的相机胶卷API
    String[] projection = new String[]{MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA};
    String selection = null;
    String[] selectionArgs = null;
    String sortOrder = null;

    try (Cursor cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, selection, selectionArgs, sortOrder)) {
        if (cursor != null) {
            while (cursor.moveToNext()) {
                long id = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media._ID));
                String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
                // 使用Glide加载相机胶卷中的图片
                Glide.with(this)
                        .load(Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, String.valueOf(id)))
                        .into(imageView);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

这些代码示例可以帮助您在版本5.9.0更新后处理相机胶卷的问题。根据您的需求和具体情况,可以适当修改代码。

相关内容

热门资讯

必备攻略(pokerworld... 必备攻略(pokerworld软件)外挂透明挂辅助app(透视)软件透明挂(2024已更新)(哔哩哔...
盘点十款!微扑克算正规平台吗(... 自定义微扑克系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不管你是想分享...
四分钟了解!乐山游戏中心有挂,... 四分钟了解!乐山游戏中心有挂,白金岛让系统发好牌,第三方教程(存在有挂)1、每一步都需要思考,不同水...
详细说明!wpk,Wepoke... 详细说明!wpk,Wepoke合作反正真的有挂,技巧教程(有挂规律)-哔哩哔哩;1.Wepoke合作...
推荐十款(德扑手牌)外挂透视辅... 推荐十款(德扑手牌)外挂透视辅助app(辅助挂)软件透明挂(2020已更新)(哔哩哔哩);德扑手牌是...
3分钟科普!西元红河棋牌有挂,... 3分钟科普!西元红河棋牌有挂,白金岛跑的快让系统发好牌,必胜教程(有挂方法)您好,白金岛,确实是有挂...
记者爆料!pokerx机器人(... 记者爆料!pokerx机器人(辅助挂)外挂透视辅助机制(2020已更新)(哔哩哔哩)1、pokerx...
普及知识!aapoker ai... 1、普及知识!aapoker ai软件(WPK辅助)外挂透明挂辅助app(辅助挂)2024新版总结(...
一秒答解(德扑之星透明)外挂透... 一秒答解(德扑之星透明)外挂透视辅助软件(透视)软件透明挂(2020已更新)(哔哩哔哩);原来确实真...
透视游戏!德扑之星隐藏功能(透... 透视游戏!德扑之星隐藏功能(透视)原来确实真的有挂2023已更新)(哔哩哔哩);德扑之星隐藏是一种具...