私はOpen With
ダイアログから自分のアプリを選んだので、ちょうどscreenshot
をキャプチャしたURI
を取得しようとしています。しかし、私は常に提供されたコードサンプルでintent.getParcelableExtra(Intent.EXTRA_STREAM)
からヌルを取得します。キャプチャされたスクリーンショットのURIをintent.getParcelableExtra(Intent.EXTRA_STREAM)から取得できません!
これは私のintent filter
:
実装2 intent-filter
の
第1:私の活動がメインとランチャします。
第二1:
<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
を取得しようとしている方法ですアクティビティ。 the documentation for ACTION_VIEW
を引用
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
}
}
ウリ値がデータフィールドになります、あなたはintent.getDataを使用する必要があります()。 – Baba