當前位置:首頁 » 安卓系統 » android打開指定文件

android打開指定文件

發布時間: 2022-05-29 14:30:17

安卓系統里如何更改打開某個文件的默認打開方式

  • 打開設置,應用程序,找到要改的軟體,點擊,往下拉,清除默認設置,或者清除默認值,以後打開這種文件需要選擇打開方式。操作非常簡單,不再附圖說明啦。

  • 文件管理器是一個類Windows的文件管理器,打開後會有一種很熟悉的感覺。可以讓你的手機瞬間成為電腦,這款文件管理軟體,對於文件的管理風格非常採用了電腦文件的管理風格,界面更加的直觀,對於大多數人來說,這款軟體的操作更加的便利,更容易操作使用。功能也很豐富,可以直接查看圖片等,設置這款軟體擁有3D視圖功能。

⑵ Android如何觸發intent打開指定目錄

Android觸發intent打開指定目錄的步驟:
1、android系統內置了很多應用,包括電話撥號,簡訊,瀏覽器等,這里創建一個簡單的Android程序,調用內置的瀏覽器打開指定的地址。
2、對應的layout xml為:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/btnGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="46dp"
android:text="@string/btnTitle_go" />
<EditText
android:id="@+id/txtUri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnGo"
android:layout_alignBottom="@+id/btnGo"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/btnGo"
android:ems="10"
android:text="http://junqilian.cnblogs.com" >
<requestFocus />
</EditText>
</RelativeLayout>
3、java代碼實現如下,主要是給EditText添加一個OnKeyListener,處理在editText裡面按回車鍵,給button添加一個onClickListener,觸發到OpenBroswer函數,通過intent打開內置的瀏覽器。

⑶ android開發 怎麼實現點擊按鈕打開文件瀏覽器並自動定位到指定文件夾

文件瀏覽器就是常見的文件管理app對吧?關鍵不在定位path,我認為(特別強調,我認為),解決方案,
1,擁有文件管理app源碼,修改或者了解是否 支持其他應用的參照啟動方式,就是非launcher啟動時,是否能處理path或uri參數。
2,在你的app中附加,文件瀏覽(功能)。

⑷ android如何打開一個文件使用安裝應用程序嗎

應用中如何調用系統所裝的軟體打開一個文件,這是我們經常碰到的問題,下面是我所用到的一種方法,和大家一起分享一下!

這個是打開文件的一個方法:

Java代碼

  • /**

  • *打開文件

  • *@paramfile

  • */

  • privatevoidopenFile(Filefile){

  • Intentintent=newIntent();

  • intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

  • //設置intent的Action屬性

  • intent.setAction(Intent.ACTION_VIEW);

  • //獲取文件file的MIME類型

  • Stringtype=getMIMEType(file);

  • //設置intent的data和Type屬性。

  • intent.setDataAndType(/*uri*/Uri.fromFile(file),type);

  • //跳轉

  • startActivity(intent);

  • }

  • /**

  • *根據文件後綴名獲得對應的MIME類型。

  • *@paramfile

  • */

  • privateStringgetMIMEType(Filefile){

  • Stringtype="*/*";

  • StringfName=file.getName();

  • //獲取後綴名前的分隔符"."在fName中的位置。

  • intdotIndex=fName.lastIndexOf(".");

  • if(dotIndex<0){

  • returntype;

  • }

  • /*獲取文件的後綴名*/

  • Stringend=fName.substring(dotIndex,fName.length()).toLowerCase();

  • if(end=="")returntype;

  • //在MIME和文件類型的匹配表中找到對應的MIME類型。

  • for(inti=0;i<MIME_MapTable.length;i++){//MIME_MapTable??在這里你一定有疑問,這個MIME_MapTable是什麼?

  • if(end.equals(MIME_MapTable[i][0]))

  • type=MIME_MapTable[i][1];

  • }

  • returntype;

  • }

  • MIME_MapTable是所有文件的後綴名所對應的MIME類型的一個String數組:

    Java代碼

  • privatefinalString[][]MIME_MapTable={

  • //{後綴名,MIME類型}

  • {".3gp","video/3gpp"},

  • {".apk","application/vnd.android.package-archive"},

  • {".asf","video/x-ms-asf"},

  • {".avi","video/x-msvideo"},

  • {".bin","application/octet-stream"},

  • {".bmp","image/bmp"},

  • {".c","text/plain"},

  • {".class","application/octet-stream"},

  • {".conf","text/plain"},

  • {".cpp","text/plain"},

  • {".doc","application/msword"},

  • {".docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"},

  • {".xls","application/vnd.ms-excel"},

  • {".xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},

  • {".exe","application/octet-stream"},

  • {".gif","image/gif"},

  • {".gtar","application/x-gtar"},

  • {".gz","application/x-gzip"},

  • {".h","text/plain"},

  • {".htm","text/html"},

  • {".html","text/html"},

  • {".jar","application/java-archive"},

  • {".java","text/plain"},

  • {".jpeg","image/jpeg"},

  • {".jpg","image/jpeg"},

  • {".js","application/x-javascript"},

  • {".log","text/plain"},

  • {".m3u","audio/x-mpegurl"},

  • {".m4a","audio/mp4a-latm"},

  • {".m4b","audio/mp4a-latm"},

  • {".m4p","audio/mp4a-latm"},

  • {".m4u","video/vnd.mpegurl"},

  • {".m4v","video/x-m4v"},

  • {".mov","video/quicktime"},

  • {".mp2","audio/x-mpeg"},

  • {".mp3","audio/x-mpeg"},

  • {".mp4","video/mp4"},

  • {".mpc","application/vnd.mpohun.certificate"},

  • {".mpe","video/mpeg"},

  • {".mpeg","video/mpeg"},

  • {".mpg","video/mpeg"},

  • {".mpg4","video/mp4"},

  • {".mpga","audio/mpeg"},

  • {".msg","application/vnd.ms-outlook"},

  • {".ogg","audio/ogg"},

  • {".pdf","application/pdf"},

  • {".png","image/png"},

  • {".pps","application/vnd.ms-powerpoint"},

  • {".ppt","application/vnd.ms-powerpoint"},

  • {".pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"},

  • {".prop","text/plain"},

  • {".rc","text/plain"},

  • {".rmvb","audio/x-pn-realaudio"},

  • {".rtf","application/rtf"},

  • {".sh","text/plain"},

  • {".tar","application/x-tar"},

  • {".tgz","application/x-compressed"},

  • {".txt","text/plain"},

  • {".wav","audio/x-wav"},

  • {".wma","audio/x-ms-wma"},

  • {".wmv","audio/x-ms-wmv"},

  • {".wps","application/vnd.ms-works"},

  • {".xml","text/plain"},

  • {".z","application/x-compress"},

  • {".zip","application/x-zip-compressed"},

  • {"","*/*"}

  • };

⑸ Android開發怎麼打開指定文件夾

網頁鏈接 希望對你有所幫助

⑹ 如何寫android指定文件路徑

Android根據路徑打開文件夾的步驟:
1、android系統內置了很多應用,包括電話撥號,簡訊,瀏覽器等,這里創建一個簡單的Android程序,調用內置的瀏覽器打開指定的地址。
2、對應的layout xml為:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/btnGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="46dp"
android:text="@string/btnTitle_go" />
<EditText
android:id="@+id/txtUri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnGo"
android:layout_alignBottom="@+id/btnGo"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/btnGo"
android:ems="10"
android:text="http://junqilian.cnblogs.com" >
<requestFocus />
</EditText>
</RelativeLayout>
3、Java代碼實現如下,主要是給EditText添加一個OnKeyListener,處理在editText裡面按回車鍵,給button添加一個onClickListener,觸發到OpenBroswer函數,通過intent打開內置的瀏覽器。

⑺ 怎樣更改安卓手機的文件打開方式,也就是用什麼app打開某一類型的文件

1、打開自己的手機資源管理器,然後打開其中某一個類型的文件,將會彈出設置窗。

安卓系統的打開方式是由應用程序注冊的,例如像UC這些瀏覽器會注冊URL的打開方式。像天天動聽這些播放器會注冊MP3的打開方式。



拓展資料:

當碰到多個文件都注冊一個時,就會出現應用程序的選擇框讓用戶來選擇一個適合的來打開。例如你安裝了UC和海豚瀏覽器,那麼打開簡訊的網址時會同時出現默認的谷歌瀏覽器、UC和海豚讓你從3個中選擇一個,你還可以選擇一個為默認。

那選擇了默認以後,想用其它的也注冊該文件的工具打開呢?解決辦法很簡單,進入設置--應用程序,找到你設置為默認的那個應用程序,點擊"清除默認設置"即可。

⑻ android如何讀取指定目錄的文件

這個還要看你是什麼文件,舉個例子獲取圖片文件。
Bitmap bitmap = BitmapFactory.decodeFile(android.os.Environment.getExternalStorageDirectory().getAbsolutePath()+ "/data/abc/def/ghi.jkl")

⑼ 安卓開發怎麼在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「這個形式了
有興趣的可以去試試。

熱點內容
編程讓我著迷 發布:2025-08-21 05:22:28 瀏覽:763
80d怎麼看存儲 發布:2025-08-21 05:21:39 瀏覽:336
刺激戰場國際服安卓怎麼登不了 發布:2025-08-21 05:14:01 瀏覽:15
混沌序列加密圖像 發布:2025-08-21 04:54:21 瀏覽:955
從哪裡找微博登錄密碼 發布:2025-08-21 04:32:34 瀏覽:444
java輸出三角形 發布:2025-08-21 04:31:43 瀏覽:703
壓縮阻抗 發布:2025-08-21 03:52:28 瀏覽:435
javaopenssl加密 發布:2025-08-21 03:46:51 瀏覽:553
傳智php培訓 發布:2025-08-21 03:46:45 瀏覽:510
我的世界如何在伺服器檢查自己在線時間 發布:2025-08-21 03:45:28 瀏覽:466