2014-06-18 1 views
0

확장자가 .myext 인 사용자 지정 파일 형식이 있습니다. 나는이 파일을 내 앱에 연결하기 위해 인 텐트 필터를 구성하는 방법을 이해하기 위해 android doc 및 많은 SO 게시물을 읽었습니다. 그것은 효과가 있지만 제대로 작동하지 않습니다.인 텐트 필터는 내 응용 프로그램을 모든 파일에 연결합니다.

나는이 텐트 필터 사용하는 경우 :

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

다음 내 응용 프로그램에 .myext 파일을 링크뿐만 아니라 assoiated 어떤 응용 프로그램이없는 모든 파일을. 그래서 원하지 않는 파일 .otherext을 열 수 있습니다.

은 그 때 나는 여러 의도 필터를 가지고 제안이 답변 https://stackoverflow.com/a/5097734/575481을 발견, 그래서 내가 얻을 :

 <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="http" /> 
      <data android:host="*" /> 
      <data android:pathPattern=".*\\.myext" /> 
     </intent-filter> 
     <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="http" /> 
      <data android:host="*" /> 
      <data android:mimeType="application/*" /> 
     </intent-filter> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="file" /> 
      <data android:host="*" /> 
      <data android:pathPattern=".*\\.myext" /> 
     </intent-filter> 

을하지만 나를 위해 작동하지 않는 것 같습니다.

내가 원하는 것은 : 내 응용 프로그램은 .myext 파일 만 엽니 다. 너는 어떤 생각을 가지고 있니?

또 다른 ext (.myext1, .myext2) 파일을 열어야하지만 적절한 인 텐트 필터를 얻은 후에는 확장자가있는 다른 파일을 복제해야합니다.

답변

1

알겠습니다. 제 경우에는 전자 우편에서 .ppp를 얻으려고하고 있으며 파일을 가져 오는 중입니다. 이 활동의에서 onCreate에

<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="content" android:pathPattern=".*\\.ppp" android:mimeType="application/ppp"/> 
     </intent-filter> 

가 중단 점을 넣어 작업 필터이며

의 값을 확인
getIntent() 

특히 mData는 안드로이드 무엇을 쓸 제공해야 방식과 MTYPE 무엇을 쓰기를 for android.mimeType