【问题标题】:Displaying a specific folder of photos in the Android Gallery App在 Android 图库应用中显示特定的照片文件夹
【发布时间】:2013-12-23 18:39:01
【问题描述】:

我希望在应用程序中显示特定的图像文件夹,以便用户可以浏览它们。

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("content://sdcard/Pictures/Album"), "image/*");
startActivityForResult(intent, 0); 

这似乎显示了手机上的所有照片,而不是我在此相册中的图像。如何更改此代码,以便用户可以使用图库应用浏览特定文件夹中的图像?这背后的想法并不是让用户可以像我在此处的许多示例中看​​到的那样选择图像,而只是为了浏览图像。

【问题讨论】:

    标签: android image android-intent


    【解决方案1】:

    你可以试试这个

      File root = new File(Environment.getExternalStorageDirectory().getPath()
    + "/myFolder/");
            Uri uri = Uri.fromFile(root);
    
            Intent intent = new Intent();
            intent.setAction(android.content.Intent.ACTION_VIEW);
            intent.setData(uri);
            startActivityForResult(intent, 1);
    

    【讨论】:

    • 这似乎对我不起作用,它会产生一个异常,说它无法实例化 android.app.application: java.lang.IllegalStateException: Unable to get package info for com.example.test .
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-25
    • 1970-01-01
    • 1970-01-01
    • 2019-07-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多