【问题标题】:how to open bitmap in gallery in android如何在android的画廊中打开位图
【发布时间】:2013-05-03 10:24:06
【问题描述】:

您好,我想在图库中打开图片,下面是我的代码

mImageView.setImageBitmap(AppUtil.getBitmapFromFile(obj.getImageUrl(), 200, 200));

    mImageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse(obj.getImageUrl()), "image/*");
            startActivity(intent);
        }
    });

但它显示 NullPointerException

Uri.parse(obj.getImageUrl() returns below string

/mnt/sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp

更新:现在我尝试了
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("file://sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp"))); 并得到一个错误

05-03 16:40:18.460: E/AndroidRuntime(4764): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file://sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp }

【问题讨论】:

标签: android android-intent photo-gallery


【解决方案1】:

试试这个

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + "/sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp"), "image/*");
startActivity(intent);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多