[英]ANDROID - Intent to launch app as a file manager
我正在使用Phonegap
Build構建一個應用程序。 HTML,CSS,JS
...
我希望用戶單擊需要文件管理器的內容時啟動應用程序 。
我知道,我必須在AndroidManifest中放一些東西,但是我不知道該怎么辦……有什么幫助嗎?
另一個示例:假設我在主屏幕(APEX)上並想要選擇一個新圖標。 當我單擊圖標時,會列出所有我可以用來查找圖標的應用程序。 這些應用程序包括Astro,Box,SolidExplorer,Gallery等。如何使我的應用程序出現在該列表中?
Intent.ACTION_GET_CONTENT
可能會有所幫助。
這是使用圖像類型文件啟動文件選擇器的示例。
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*"); // choose any image
intent.addCategory(Intent.CATEGORY_OPENABLE);
Intent chooserIntent = Intent.createChooser(intent, "File chooser");
startActivityForResult(chooserIntent, REQUEST_CODE);
您需要使用帶有特定數據元素的intent-filter在清單文件中聲明您的activity
。
例如:
<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=".*\\.pdf" />
</intent-filter>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.