【问题标题】:Item not found when trying to open and image file (jpg) via intent尝试通过意图打开和图像文件 (jpg) 时找不到项目
【发布时间】:2015-01-05 18:57:50
【问题描述】:

我有一个想通过意图打开的图像文件,但我面临的问题是,在测试应用程序时,我收到一条消息,说找不到该项目。我已经尝试了各种类似的问题及其解决方案,但似乎没有任何问题可以解决我的问题。

这是我目前的代码:

View rootView = inflater.inflate(R.layout.fragment_trythisimage, container, false);

Button button = (Button) rootView.findViewById(R.id.thisImagea);
button.setOnClickListener(new OnClickListener() {

 public void onClick(final View v) {

    File jpgFile = new File("android.resource://com.funny.funnyimages/" + R.raw.funnyimagea);
    Uri path = Uri.fromFile(jpgFile);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.setDataAndType(path, "image/jpeg");
    startActivity(intent);  
         }
    });

    return rootView;
    }
   }

【问题讨论】:

    标签: android android-intent android-button


    【解决方案1】:

    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/external/images/media/16"))); /** 替换成你自己的uri */

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-15
      相关资源
      最近更新 更多