0
可能重複:
Android intent filter: associate app with file extensionAndroid的 - 如何從主要活動打開相關文件的應用程序
與擴展.X到我的申請,我相關的XML文件。我想單擊.x文件,我的相關應用程序應該啓動,並且我想從activity的onCreate()內部以某種方式打開文件。有一種方法可以做到這一點?
在此先感謝。
可能重複:
Android intent filter: associate app with file extensionAndroid的 - 如何從主要活動打開相關文件的應用程序
與擴展.X到我的申請,我相關的XML文件。我想單擊.x文件,我的相關應用程序應該啓動,並且我想從activity的onCreate()內部以某種方式打開文件。有一種方法可以做到這一點?
在此先感謝。
在您的清單中添加這個意圖過濾到您的活動
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/xml" />
<data android:pathPattern=".*\\.x" />
</intent-filter>
您的onCreate文件作爲傳遞:
Uri uri = this.getIntent().getData();
if(uri!=null){
Log.v(getClass().getSimpleName(), "importing uri:"+uri.toString());
}