android獲取一個用於開啟各種檔案的intent
//android獲取一個用於開啟文字檔案的intent public static Intent getTextFileIntent( String param, boolean paramBoolean) { Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (paramBoolean) { Uri uri1 = Uri.parse(param ); intent.setDataAndType(uri1, "text/plain"); } else { Uri uri2 = Uri.fromFile(new File(param )); intent.setDataAndType(uri2, "text/plain"); } return intent; } //android獲取一個用於開啟CHM檔案的intent public static Intent getChmFileIntent( String param ) { Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = Uri.fromFile(new File(param )); intent.setDataAndType(uri, "application/x-chm"); return intent; } //android獲取一個用於開啟PDF檔案的intent public static Intent getPdfFileIntent( String param ) { Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = Uri.fromFile(new File(param )); intent.setDataAndType(uri, "application/pdf"); return intent; } //android獲取一個用於開啟Word檔案的intent public static Intent getWordFileIntent( String param ) { Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = Uri.fromFile(new File(param )); intent.setDataAndType(uri, "application/msword"); return intent; } //android獲取一個用於開啟PPT檔案的intent public static Intent getPptFileIntent( String param ) { Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = Uri.fromFile(new File(param )); intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); return intent; } //android獲取一個用於開啟Excel檔案的intent public static Intent getExcelFileIntent( String param ) { Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = Uri.fromFile(new File(param )); intent.setDataAndType(uri, "application/vnd.ms-excel"); return intent; }
String |
ADD_SHORTCUT_ACTION |
動作:在系統中新增一個快捷方式。. |
"android.intent.action.ADD_SHORTCUT" |
String |
ALL_APPS_ACTION |
動作:列舉所有可用的應用。輸入:無。 |
"android.intent.action.ALL_APPS" |
String |
ALTERNATIVE_CATEGORY |
類別:說明 activity 是使用者正在瀏覽的資料的一個可選操作。 |
"android.intent.category.ALTERNATIVE" |
String |
ANSWER_ACTION |
動作:處理撥入的電話。 |
"android.intent.action.ANSWER" |
String |
BATTERY_CHANGED_ACTION |
廣播:充電狀態,或者電池的電量發生變化。 |
"android.intent.action.BATTERY_CHANGED" |
String |
BOOT_COMPLETED_ACTION |
廣播:在系統啟動後,這個動作被廣播一次(只有一次)。 |
"android.intent.action.BOOT_COMPLETED" |
String |
BROWSABLE_CATEGORY |
類別:能夠被瀏覽器安全使用的 activities 必須支援這個類別。 |
"android.intent.category.BROWSABLE" |
String |
BUG_REPORT_ACTION |
動作:顯示 activity 報告錯誤。 |
"android.intent.action.BUG_REPORT" |
String |
CALL_ACTION |
動作:撥打電話,被呼叫的聯絡人在資料中指定。 |
"android.intent.action.CALL" |
String |
CALL_FORWARDING_STATE_CHANGED_ ACTION |
廣播:語音電話的來電轉駁狀態已經改變。 |
"android.intent.action.CFF" |
String |
CLEAR_CREDENTIALS_ACTION |
動作:清除登陸憑證 (credential)。 |
"android.intent.action.CLEAR_CREDENTIALS" |
String |
CONFIGURATION_CHANGED_ACTION |
廣播:裝置的配置資訊已經改變,參見 Resources.Configuration. |
"android.intent.action.CONFIGURATION_CHANGED" |
Creator |
CREATOR |
無 |
無 |
String |
DATA_ACTIVITY_STATE_CHANGED_ACTION |
廣播:電話的資料活動(data activity)狀態(即收發資料的狀態)已經改變。 |
"android.intent.action.DATA_ACTIVITY" |
String |
DATA_CONNECTION_STATE_CHANGED _ACTION |
廣播:電話的資料連線狀態已經改變。 |
"android.intent.action.DATA_STATE" |
String |
DATE_CHANGED_ACTION |
廣播:日期被改變。 |
"android.intent.action.DATE_CHANGED" |
String |
DEFAULT_ACTION |
動作:和 VIEW_ACTION 相同,是在資料上執行的標準動作。 |
"android.intent.action.VIEW" |
String |
DEFAULT_CATEGORY |
類別:如果 activity 是對資料執行確省動作(點選, center press)的 一個選項,需要設定這個類別。 |
"android.intent.category.DEFAULT" |
String |
DELETE_ACTION |
動作:從容器中刪除給定的資料。 |
"android.intent.action.DELETE" |
String |
DEVELOPMENT_PREFERENCE_CATEGORY |
類別:說明 activity 是一個設定面板 (development preference panel). |
"android.intent.category.DEVELOPMENT _PREFERENCE" |
String |
DIAL_ACTION |
動作:撥打資料中指定的電話號碼。 |
"android.intent.action.DIAL" |
String |
EDIT_ACTION |
動作:為制定的資料顯示可編輯介面。 |
"android.intent.action.EDIT" |
String |
EMBED_CATEGORY |
類別:能夠在上級(父)activity 中執行。 |
"android.intent.category.EMBED" |
String |
EMERGENCY_DIAL_ACTION |
動作:撥打緊急電話號碼。 |
"android.intent.action.EMERGENCY_DIAL" |
int |
FORWARD_RESULT_LAUNCH |
啟動標記:如果這個標記被設定,而且被一個已經存在的 activity 用來啟 動新的 activity,已有 activity 的回覆目標 (reply target) 會被轉移 給新的 activity。 |
16 0x00000010 |
String |
FOTA_CANCEL_ACTION |
廣播:取消所有被掛起的 (pending) 更新下載。 |
"android.server.checkin.FOTA_CANCEL" |
String |
FOTA_INSTALL_ACTION |
廣播:更新已經被確認,馬上就要開始安裝。 |
"android.server.checkin.FOTA_INSTALL" |
String |
FOTA_READY_ACTION |
廣播:更新已經被下載,可以開始安裝。 |
"android.server.checkin.FOTA_READY" |
String |
FOTA_RESTART_ACTION |
廣播:恢復已經停止的更新下載。 |
"android.server.checkin.FOTA_RESTART" |
String |
FOTA_UPDATE_ACTION |
廣播:通過 OTA 下載並安裝作業系統更新。 |
"android.server.checkin.FOTA_UPDATE" |
String |
FRAMEWORK_INSTRUMENTATION_TEST _CATEGORY |
類別 To be used as code under test for framework instrumentation tests. |
"android.intent.category.FRAMEWORK _INSTRUMENTATION_TEST" |
String |
GADGET_CATEGORY |
類別:這個 activity 可以被嵌入宿主 activity (activity that is hosting gadgets)。 |
"android.intent.category.GADGET" |
String |
GET_CONTENT_ACTION |
動作:讓使用者選擇資料並返回。 |
"android.intent.action.GET_CONTENT" |
String |
HOME_CATEGORY |
類別:主螢幕 (activity),裝置啟動後顯示的第一個 activity。 |
"android.intent.category.HOME" |
String |
INSERT_ACTION |
動作:在容器中插入一個空項 (item)。 |
"android.intent.action.INSERT" |
String |
INTENT_EXTRA |
附加資料:和 PICK_ACTIVITY_ACTION 一起使用時,說明使用者 選擇的用來顯示的 activity;和 ADD_SHORTCUT_ACTION 一起 使用的時候,描述要新增的快捷方式。 |
"android.intent.extra.INTENT" |
String |
LABEL_EXTRA |
附加資料:大寫字母開頭的字元標籤,和 ADD_SHORTCUT_ACTION 一起使用。 |
"android.intent.extra.LABEL" |
String |
LAUNCHER_CATEGORY |
類別:Activity 應該被顯示在頂級的 launcher 中。 |
"android.intent.category.LAUNCHER" |
String |
LOGIN_ACTION |
動作:獲取登入憑證。 |
"android.intent.action.LOGIN" |
String |
MAIN_ACTION |
動作:作為主入口點啟動,不需要資料。 |
"android.intent.action.MAIN" |
String |
MEDIABUTTON_ACTION |
廣播:使用者按下了“Media Button”。 |
"android.intent.action.MEDIABUTTON" |
String |
MEDIA_BAD_REMOVAL_ACTION |
廣播:擴充套件介質(擴充套件卡)已經從 SD 卡插槽拔出,但是掛載點 (mount point) 還沒解除 (unmount)。 |
"android.intent.action.MEDIA_BAD_REMOVAL" |
String |
MEDIA_EJECT_ACTION |
廣播:使用者想要移除擴充套件介質(拔掉擴充套件卡)。 |
"android.intent.action.MEDIA_EJECT" |
String |
MEDIA_MOUNTED_ACTION |
廣播:擴充套件介質被插入,而且已經被掛載。 |
"android.intent.action.MEDIA_MOUNTED" |
String |
MEDIA_REMOVED_ACTION |
廣播:擴充套件介質被移除。 |
"android.intent.action.MEDIA_REMOVED" |
String |
MEDIA_SCANNER_FINISHED_ACTION |
廣播:已經掃描完介質的一個目錄。 |
"android.intent.action.MEDIA_SCANNER_FINISHED" |
String |
MEDIA_SCANNER_STARTED_ACTION |
廣播:開始掃描介質的一個目錄。 |
"android.intent.action.MEDIA_SCANNER_STARTED" |
String |
MEDIA_SHARED_ACTION |
廣播:擴充套件介質的掛載被解除 (unmount),因為它已經作為 USB 大容量存 儲被共享。 |
"android.intent.action.MEDIA_SHARED" |
String |
MEDIA_UNMOUNTED_ACTION |
廣播:擴充套件介質存在,但是還沒有被掛載 (mount)。 |
"android.intent.action.MEDIA_UNMOUNTED" |
String |
MESSAGE_WAITING_STATE_CHANGED _ACTION |
廣播:電話的訊息等待(語音郵件)狀態已經改變。 |
"android.intent.action.MWI" |
int |
MULTIPLE_TASK_LAUNCH |
啟動標記:和 NEW_TASK_LAUNCH 聯合使用,禁止將已有的任 務改變為前景任務 (foreground)。 |
8 0x00000008 |
String |
NETWORK_TICKLE_RECEIVED_ACTION |
廣播:裝置收到了新的網路 "tickle" 通知。 |
"android.intent.action.NETWORK _TICKLE_RECEIVED" |
int |
NEW_TASK_LAUNCH |
啟動標記:設定以後,activity 將成為歷史堆疊中的第一個 新任務(棧頂)。 |
4 0x00000004 |
int |
NO_HISTORY_LAUNCH |
啟動標記:設定以後,新的 activity 不會被儲存在歷史堆 棧中。 |
1 0x00000001 |
String |
PACKAGE_ADDED_ACTION |
廣播:裝置上新安裝了一個應用程式包。 |
"android.intent.action.PACKAGE_ADDED" |
String |
PACKAGE_REMOVED_ACTION |
廣播:裝置上刪除了一個應用程式包。 |
"android.intent.action.PACKAGE_REMOVED" |
String |
PHONE_STATE_CHANGED_ACTION |
廣播:電話狀態已經改變。 |
"android.intent.action.PHONE_STATE" |
String |
PICK_ACTION |
動作:從資料中選擇一個專案 (item),將被選中的專案返 回。 |
"android.intent.action.PICK" |
String |
PICK_ACTIVITY_ACTION |
動作:選擇一個 activity,返回被選擇的 activity 的 類(名)。 |
"android.intent.action.PICK_ACTIVITY" |
String |
PREFERENCE_CATEGORY |
類別:activity是一個設定面板 (preference panel)。 |
"android.intent.category.PREFERENCE" |
String |
PROVIDER_CHANGED_ACTION |
廣播:更新將要(真正)被安裝。 |
"android.intent.action.PROVIDER_CHANGED" |
String |
PROVISIONING_CHECK_ACTION |
廣播:要求 polling of provisioning service 下載最新 的設定。 |
"android.intent.action.PROVISIONING_CHECK" |
String |
RUN_ACTION |
動作:執行資料(指定的應用),無論它(應用)是什麼。 |
"android.intent.action.RUN" |
String |
SAMPLE_CODE_CATEGORY |
類別:To be used as an sample code example (not part of the normal user experience). |
"android.intent.category.SAMPLE_CODE" |
String |
SCREEN_OFF_ACTION |
廣播:螢幕被關閉。 |
"android.intent.action.SCREEN_OFF" |
String |
SCREEN_ON_ACTION |
廣播:螢幕已經被開啟。 |
"android.intent.action.SCREEN_ON" |
String |
SELECTED_ALTERNATIVE_CATEGORY |
類別:對於被使用者選中的資料,activity 是它的一個可選操作。 |
"android.intent.category.SELECTED_ALTERNATIVE" |
String |
SENDTO_ACTION |
動作:向 data 指定的接收者傳送一個訊息。 |
"android.intent.action.SENDTO" |
String |
SERVICE_STATE_CHANGED_ACTION |
廣播:電話服務的狀態已經改變。 |
"android.intent.action.SERVICE_STATE" |
String |
SETTINGS_ACTION |
動作:顯示系統設定。輸入:無。 |
"android.intent.action.SETTINGS" |
String |
SIGNAL_STRENGTH_CHANGED_ACTION |
廣播:電話的訊號強度已經改變。 |
"android.intent.action.SIG_STR" |
int |
SINGLE_TOP_LAUNCH |
啟動標記:設定以後,如果 activity 已經啟動,而且位於 歷史堆疊的頂端,將不再啟動(不重新啟動) activity。 |
2 0x00000002 |
String |
STATISTICS_REPORT_ACTION |
廣播:要求 receivers 報告自己的統計資訊。 |
"android.intent.action.STATISTICS_REPORT" |
String |
相關推薦android獲取一個用於開啟各種檔案的intent//android獲取一個用於開啟文字檔案的intent public static Intent getTextFileIntent( String param, boolean paramBoolean) { Intent intent = new Intent android獲取一個用於開啟Word檔案的intent最近在做專案使用webview顯示後,有寫文件需要開啟,找了一些資料,研究了一下,弄出來了! 下面貼一下主要程式碼: param為文件的主要路徑 public static Intent getWordFileIntent(String android用於開啟各種檔案的intent(轉)import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.net.Uri.Builder; import java.io android用於開啟各種檔案的intent,包括以下檔案PDF,PPT,WORD,EXCEL,CHM,HTML,TEXT,AUDIO,VIDE(程式碼待完善)import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.net.Uri.Builder;import java.io.File;impor android 開啟各種檔案 intent.setDataAndTypeJava程式碼 /** * 開啟檔案 * @param file */ private void openFile(File file){ Intent intent = new Intent(); intent.addFlags(I android開啟各種檔案的intentimport android.app.Activity; import android.content.Intent; import android.net.Uri; import android.net.Uri.Builder; import java.io.File; import android.con Android--用intent開啟各種檔案import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.net.Uri.Builder; import java.io.File; Android開啟各種檔案的MIME TYPE-setDataAndType函式中的Type關聯MIME:全稱Multipurpose Internet Mail Extensions,多功能Internet 郵件擴充服務。它是一種多用途網際郵件擴充協議,在1992年最早應用於電子郵件系統,但後來也應用到瀏覽器。MIME型別就是設定某種副檔名的檔案用一種應用程式來開啟的方式型別,當該副檔名檔案被訪問 android 獲取指定路徑下所有檔案,將檔案從一個目錄copy到另一個目錄,執行linux命令/** * 複製整個資料夾內容 ,可以從data/data/包名下 拷貝到 data/data/包名下。也可以copy到 /sdcard 下 * @param oldPath String 原檔案路徑 如:c:/fqf 用intent開啟各種檔案 開啟sd卡路徑 開啟系統目錄...在其他類中呼叫MyIntent類中的方法,例如: Intent it = MyIntent .getHtmlFileIntent("/sdcard/tutorial.html");//對應你的檔名 startActivity( it ); //可用於獲取開 Notification的使用以及Intent開啟各種檔案一:Notification的使用 使用步驟: 流程模組: 第一步: 建立一個通知欄的Builder構造類 (Create a Notification Builder) 第二步: 定義通知欄的Action (Define the N Intent開啟各種檔案1.Android開啟系統播放器:Uri uri = Uri.parse(url);// Uri uri = Uri.parse("rtsp://10.103.131.23:554/28960004/j04.mp4"); python獲取一個目錄下的檔案以及子檔案中的檔案Python獲取資料夾下的檔案和子資料夾 這裡使用os.walk函式 關於函式該函式的介紹如下 os.walk(top, topdown=Ture, onerror=None, followlinks=False) 引數: top – 根目錄下的每一個資料夾(包含它自 Android studio 或java開啟txt檔案剛剛學習碎片知識,顯示的內容如果是txt該如何做呢?這就需要開啟檔案了,話不多說,上程式碼。 我的檔案在: a為標題檔案,a0為每個標題的內容檔案 結果如下圖: 我的a和a0txt 由於新聞標題較多,新聞內容較多,就考慮用txt來裝 Android 版本更新之開啟apk檔案的前生今世現在APP都少不了的一個功能就是版本更新,檢測到有新版,從伺服器下載下來APK,然後安裝,今天就來聊一聊它。 原始碼地址:github [Android6.0之前] 首先是許可權 <uses-permission android:name="android. Android專案需要使用的各種檔案任何一個新建的專案都會預設使用Android模式的專案結構,但這並不是專案真實的目錄結構,而是被Android Studio轉換過的這個模式結構比較簡潔明瞭,適合進行快速開發,將其切換為Project模式就是專案的真實結構了。 一.首先就是.grad Umbraco 中獲取一個media item的檔案路徑 file path我們要使用UmbracoHelper, 這裡就需要用到我們在之前的blog裡面寫的UmbracoContext 參看這個blog https://www.cnblogs.com/wphl-27/p/9927044.html public clas Android獲取assets目錄下的檔案和圖片在android studio中預設不會像eclipse一樣自動新建assets檔案,首先將android studio的檢視切換到project下,src/man下直接新建檔案命名為assets即可。 1、獲取圖片 Bitmap bitmap = n android 獲取一個月有多少周Calendar c = Calendar.getInstance(); c.setTime(new Date(System.currentTimeMillis())); int dayCurrentMonth = c.get(Calendar.DAY_OF Android獲取Assets目錄下文字檔案程式碼例項: 獲取assets目錄下的txt文字,並顯示到元件上. 核心程式碼: private void findViews(){ TextView tv = (TextView)findviewById(R.id.tv1); try{ |