我试图从Open With
对话框中选取刚截取的screenshot
的URI
。但是在提供的代码示例中,我总是从intent.getParcelableExtra(Intent.EXTRA_STREAM)
中得到空值。无法从intent.getParcelableExtra(Intent.EXTRA_STREAM)获取捕获的屏幕截图的URI!
这是我intent filter
:
实现了两个intent-filter
小号
第一个:让我的主要活动和启动。
第二个:使它的图像浏览器(寄存器在系统上本次活动作为一个图像浏览器)
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
这就是我怎样,我试图从调用的意图得到URI
我。活动。
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_VIEW.equals(action) && type != null) {
if (type.startsWith("image/")) {
Uri mediaUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
// Here mediaUri is always null
}
}
URI值将在数据领域,你需要使用intent.getData()。 – Baba