Open With
대화 상자에서 내 앱을 선택했을 때 URI
을 방금 가져온 것 같습니다. screenshot
. 하지만 난 항상 intent.getParcelableExtra(Intent.EXTRA_STREAM)
제공된 코드 샘플에서 null이됩니다.캡처 한 스크린 샷의 URI를 intent.getParcelableExtra (Intent.EXTRA_STREAM)에서 가져올 수 없습니다!
이것은 내 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
을 얻으려고 어떻게 내 활동. 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