2015-01-16 9 views
0

내가하기 위해 필요로하는 의도 필터를 알아 내려고 노력하고 있어요을 의도을 잡으려고 intent-filters에 대한 stackoverflow 기사가로드되지만 여전히 누락 된 내용을 이해할 수 없습니다.의도 필터는 * 볼 .ext를 파일

예를 들어 이것이 내 인 텐트 필터 인 경우 "* .npk"확장명의 파일을 잡을 것으로 예상됩니다. 나는 패턴 버그에 대해 알고, 그래서 .npk 전에 0-4 점이 경로를 잡기 위해 여러 개의 데이터 라인을 추가 :

 <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="file" android:pathPattern=".*\\.npk" /> 
      <data android:scheme="file" android:pathPattern=".*\\..*\\.npk" /> 
      <data android:scheme="file" android:pathPattern=".*\\..*\\..*\\.npk" /> 
      <data android:scheme="file" android:pathPattern=".*\\..*\\..*\\..*\\.npk" /> 
      <data android:scheme="file" android:pathPattern=".*\\..*\\..*\\..*\\..*\\.npk" /> 
     </intent-filter> 

내가 총 사령관에서 파일이 작동되는 앱 열고, 예상대로 그것은 내 활동을 시작한다 (I 단 하나의 pathPattern =이 경우에도 BTW이 작동 그래서 아마 언급 된 버그가 막대 사탕에서 해결 "을 * \\ NPK..") : 그러나

{act=android.intent.action.VIEW dat=file:///storage/emulated/0/Android/data/com.fletech.smartbaby.android.pro/files/npk/animal-water-he.npk typ=application/octet-stream flg=0x10000000 cmp=com.fletech.smartbaby.android/.CategorySliderActivity} 

나가 수 ' Dropbox 앱에서 제대로 작동하지 않게하십시오. 이것은 logcat에서 "캡처 된"의도입니다. 그것을 캡처하기 위해 android : mimeType = "*/*"을 추가하여 내 앱을 선택할 수있게되었습니다. 이제 모든 파일 (.jpg)이 내 앱을 열고 싶어합니다.

{act=android.intent.action.VIEW dat=file:///storage/emulated/0/Android/data/com.dropbox.android/files/u123456/scratch/apk/nature_0.npk typ=application/octet-stream flg=0x10000003 cmp=com.fletech.smartbaby.android/.CategorySliderActivity (has extras)} 

위의 필터가이 의도를 포착하지 못하는 이유를 모르겠습니다. 전체 사령관의 의도와 드롭 박스의 의도 사이에 나타나는 유일한 차이점은 플래그입니다. 즉, IMHO를 변경해서는 안되는 엑스트라이며 파일 확장명 앞에 경로에 2 개의 4 점이 있지만 내 의도 필터는주의를 기울여야합니다. 그것의.

참고 : 저는 롤리팝을 개발하고 테스트 중이지만 api 9 이상에서 작동하고 싶습니다.

답변

0

또 다른 오랜 기간의 시행 착오 끝에 나는 다음과 같은 해결책을 찾았습니다. 나는 android : host = "*"and android : mimeType = "*/*"을 데이터 요소에 추가해야했습니다. 공식 안드로이드 문서에는 약간의 불일치가있는 것으로 보입니다.

 <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.npk" /> 
      <data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\..*\\.npk" /> 
      <data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\..*\\..*\\.npk" /> 
      <data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\..*\\..*\\..*\\.npk" /> 
      <data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\..*\\..*\\..*\\..*\\.npk" /> 
     </intent-filter>