導航:首頁 > 版本升級 > intent打開文件

intent打開文件

發布時間:2024-03-19 02:52:43

1. android怎麼用intent跳轉到文件管理器

Intent mIntent = new Intent( );
ComponentName comp = new ComponentName("com.mediatek.filemanager", "com.mediatek.filemanager.FileManagerOperationActivity");
mIntent.setComponent(comp);
mIntent.setAction("android.intent.action.VIEW");
startActivity(mIntent);
可能需要設置mIntent.flag 為new_task,你試試吧

2. android手機怎麼才能直接打開URL鏈接文件

安卓代碼中調用瀏覽器來打開相應的網頁,一般有以下幾種方式

3. Android中怎麼實現打開文件時彈出一個打開方式可供選擇的框。

這個是隱私Intent調用,沒有指定明確的Activity,而是設置了條件,只要符合都可以響應。

像你說的這種是根據文件類型做條件來判斷,可以通過Intent的setDataAndType方法實現。

這個Type是指MIME Type,網上有文件名後綴與MIME類型的對照表,可以參考。


提供一個打開內存儲根目錄下1.txt文件的樣例代碼,僅供參考(前提是沒給txt文件設置默認的打開應用)

Intentintent=newIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(Environment.getExternalStorageDirectory()+"/1.txt"),"text/plain");
startActivity(intent);

4. 安卓開發怎麼在APP內部調用手機系統瀏覽器打開指定html並獲取HTML的數據

Android開發_如何調用 瀏覽器訪問網頁和Html文件
一、啟動android默認瀏覽器

Intent intent= new Intent();
intent.setAction('android.intent.action.VIEW');
Uri content_url = Uri.parse('http://www.cnblogs.com');
intent.setData(content_url);
startActivity(intent);
這樣子,android就可以調用起手機默認的瀏覽器訪問。

二、指定相應的瀏覽器訪問
1、指定android自帶的瀏覽器訪問
( 「com.android.browser」:packagename ;「com.android.browser.BrowserActivity」:啟動主activity)
Intent intent= new Intent();
intent.setAction('android.intent.action.VIEW');
Uri content_url = Uri.parse('http://www.cnblogs.com');
intent.setData(content_url);
intent.setClassName('com.android.browser','com.android.browser.BrowserActivity');
startActivity(intent);
2、啟動其他瀏覽器(當然該瀏覽器必須安裝在機器上)
只要修改以下相應的packagename 和 主啟動activity即可調用其他瀏覽器

intent.setClassName('com.android.browser','com.android.browser.BrowserActivity');
uc瀏覽器':'com.uc.browser', 'com.uc.browser.ActivityUpdate「
opera :'com.opera.mini.android', 'com.opera.mini.android.Browser'
qq瀏覽器:'com.tencent.mtt', 'com.tencent.mtt.MainActivity'

三、打開本地html文件
打開本地的html文件的時候,一定要指定某個瀏覽器,而不能採用方式一來瀏覽,具體示例代碼如下

Intent intent= new Intent();
intent.setAction('android.intent.action.VIEW');
Uri content_url = Uri.parse('content://com.android.htmlfileprovider/sdcard/help.html');
intent.setData(content_url);
intent.setClassName('com.android.browser','com.android.browser.BrowserActivity');
startActivity(intent);

關鍵點是調用了」content「這個filter。
以前有在win32編程的朋友,可能會覺得用這種形式」file://sccard/help.html「是否可以,可以很肯定的跟你說,默認的瀏覽器設置是沒有對」file「這個進行解析的,如果要讓你的默認android瀏覽器有這個功能需要自己到android源碼修改manifest.xml文件,然後自己編譯瀏覽器代碼生成相應的apk包來重新在機器上安裝。

大體的步驟如下:

1、打開 packages/apps/Browser/AndroidManifest.xml文件把加到相應的後面就可以了

2、重新編譯打包,安裝,這樣子,新的瀏覽器就支持」file「這個形式了
有興趣的可以去試試。

閱讀全文

與intent打開文件相關的資料

熱點內容
凍結qq號能防申訴嗎 瀏覽:861
數據今年與過去幾年年比較叫什麼 瀏覽:564
矩陣理論需要什麼數據 瀏覽:252
如何批量導入音頻文件名及時長 瀏覽:881
撓癢癢視頻在哪個app有得看 瀏覽:773
陳三和陳墨涵在哪個app里直播 瀏覽:747
es文件管理器手機管理電腦文件 瀏覽:659
cad文件一直崩 瀏覽:501
微信怎麼製作文件夾視頻 瀏覽:752
飛行器攝像頭升級替換 瀏覽:184
qq昵稱帶英文 瀏覽:374
中信銀行usbkey密碼幾位 瀏覽:174
helloword單詞比賽 瀏覽:57
java測試環境搭建 瀏覽:195
手機解密壓縮文件 瀏覽:991
微信文件夾里的圖片如何刪除 瀏覽:383
表格匯入數據怎麼填寫代碼 瀏覽:103
歌奈和品勝數據線哪個好用 瀏覽:714
為什麼銷售易下載app 瀏覽:630
網上編程哪個好 瀏覽:814

友情鏈接