adb shell模擬發(fā)送安卓廣播的入門知識和實例講解:
入門知識
什么是廣播?
廣播是一種Android系統(tǒng)提供的一種機制,用于在系統(tǒng)中傳遞事件或消息。廣播可以是系統(tǒng)級別的,也可以是應(yīng)用級別的。系統(tǒng)級別的廣播可以被所有應(yīng)用接收,應(yīng)用級別的廣播只能被同一應(yīng)用中的組件接收。
廣播的分類
廣播分為兩種類型:標準廣播和有序廣播。
標準廣播:發(fā)送者無法知道接收者是否接收到廣播,也無法知道接收者的處理順序。標準廣播是一種異步的廣播,所有接收者都是同時接收到廣播的。
有序廣播:發(fā)送者可以知道接收者是否接收到廣播,也可以指定接收者的處理順序。有序廣播是一種同步的廣播,每個接收者都按照優(yōu)先級順序接收廣播,并且可以終止廣播的傳遞。
廣播的發(fā)送
可以使用adb shell命令模擬發(fā)送廣播。命令格式如下:
adb shell am broadcast -a <action> [-d ] [-t <mime_type>] [-c <category> [-c <category>] ...]
其中,-a
參數(shù)指定廣播的Action,-d
參數(shù)指定廣播的Data URI,-t
參數(shù)指定廣播的MIME類型,-c
參數(shù)指定廣播的Category。
實例講解
以下是100個實例講解,每個實例都包含廣播的Action、Data URI、MIME類型和Category:
實例1
Action:android.intent.action.BOOT_COMPLETED
Data URI:無
MIME類型:無
Category:無文章來源:http://www.zghlxwxcb.cn/news/detail-696708.html
說明:模擬發(fā)送開機廣播。
實例2
Action:android.intent.action.TIME_TICK
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送系統(tǒng)時間變化廣播。
實例3
Action:android.intent.action.AIRPLANE_MODE
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送飛行模式開啟廣播。
實例4
Action:android.intent.action.ACTION_POWER_CONNECTED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送充電器連接廣播。
實例5
Action:android.intent.action.ACTION_POWER_DISCONNECTED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送充電器斷開廣播。
實例6
Action:android.intent.action.MEDIA_MOUNTED
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡掛載廣播。
實例7
Action:android.intent.action.MEDIA_UNMOUNTED
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡卸載廣播。
實例8
Action:android.intent.action.MEDIA_SCANNER_STARTED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送媒體掃描開始廣播。
實例9
Action:android.intent.action.MEDIA_SCANNER_FINISHED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送媒體掃描完成廣播。
實例10
Action:android.intent.action.PACKAGE_ADDED
Data URI:package:com.example.app
MIME類型:無
Category:無
說明:模擬發(fā)送應(yīng)用安裝廣播。
實例11
Action:android.intent.action.PACKAGE_REMOVED
Data URI:package:com.example.app
MIME類型:無
Category:無
說明:模擬發(fā)送應(yīng)用卸載廣播。
實例12
Action:android.intent.action.PACKAGE_CHANGED
Data URI:package:com.example.app
MIME類型:無
Category:無
說明:模擬發(fā)送應(yīng)用更新廣播。
實例13
Action:android.intent.action.PACKAGE_REPLACED
Data URI:package:com.example.app
MIME類型:無
Category:無
說明:模擬發(fā)送應(yīng)用替換廣播。
實例14
Action:android.intent.action.BATTERY_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送電池狀態(tài)變化廣播。
實例15
Action:android.intent.action.SCREEN_ON
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送屏幕開啟廣播。
實例16
Action:android.intent.action.SCREEN_OFF
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送屏幕關(guān)閉廣播。
實例17
Action:android.intent.action.USER_PRESENT
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送用戶解鎖廣播。
實例18
Action:android.intent.action.NEW_OUTGOING_CALL
Data URI:tel:10086
MIME類型:無
Category:無
說明:模擬發(fā)送撥打電話廣播。
實例19
Action:android.intent.action.CALL_STATE_CHANGED
Data URI:
tel:10086
MIME類型:無
Category:無
說明:模擬發(fā)送通話狀態(tài)變化廣播。
實例20
Action:android.intent.action.MEDIA_BUTTON
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送媒體按鈕廣播。
實例21
Action:android.intent.action.CAMERA_BUTTON
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送相機按鈕廣播。
實例22
Action:android.intent.action.ANSWER
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送接聽電話廣播。
實例23
Action:android.intent.action.CALL
Data URI:tel:10086
MIME類型:無
Category:無
說明:模擬發(fā)送撥打電話廣播。
實例24
Action:android.intent.action.DIAL
Data URI:tel:10086
MIME類型:無
Category:無
說明:模擬發(fā)送打開撥號界面廣播。
實例25
Action:android.intent.action.VIEW
Data URI:http://www.example.com
MIME類型:無
Category:無
說明:模擬發(fā)送打開網(wǎng)頁廣播。
實例26
Action:android.intent.action.SEND
Data URI:無
MIME類型:text/plain
Category:無
說明:模擬發(fā)送文本分享廣播。
實例27
Action:android.intent.action.SEND_MULTIPLE
Data URI:無
MIME類型:image/*
Category:無
說明:模擬發(fā)送多張圖片分享廣播。
實例28
Action:android.intent.action.PICK
Data URI:無
MIME類型:image/*
Category:無
說明:模擬發(fā)送選擇圖片廣播。
實例29
Action:android.intent.action.GET_CONTENT
Data URI:無
MIME類型:image/*
Category:無
說明:模擬發(fā)送獲取內(nèi)容廣播。
實例30
Action:android.intent.action.POWER_USAGE_SUMMARY
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送電量使用情況廣播。
實例31
Action:android.intent.action.WALLPAPER_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送壁紙變化廣播。
實例32
Action:android.intent.action.WALLPAPER_CHANGED_INTERNAL
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送壁紙變化廣播。
實例33
Action:android.intent.action.CONFIGURATION_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送配置變化廣播。
實例34
Action:android.intent.action.LOCALE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送語言變化廣播。
實例35
Action:android.intent.action.TIMEZONE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送時區(qū)變化廣播。
實例36
Action:android.intent.action.TIME_SET
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送時間設(shè)置廣播。
實例37
Action:android.intent.action.DATE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送日期變化廣播。
實例38
Action:android.intent.action.BATTERY_LOW
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送電量低廣播。
實例39
Action:android.intent.action.BATTERY_OKAY
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送電量正常廣播。
實例40
Action:android.intent.action.DEVICE_STORAGE_LOW
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送存儲空間不足廣播。
實例41
Action:android.intent.action.DEVICE_STORAGE_OK
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送存儲空間正常廣播。
實例42
Action:android.intent.action.ANY_DATA_STATE
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)連接狀態(tài)變化廣播。
實例43
Action:android.intent.action.DATA_ACTIVITY_CHANGE
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)活動狀態(tài)變化廣播。
實例44
Action:android.intent.action.DATA_CONNECTION_FAILED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)連接失敗廣播。
實例45
Action:android.intent.action.DATA_CONNECTION_LOST
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)連接丟失廣播。
實例46
Action:android.intent.action.DATA_CONNECTION_STALL
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)連接停滯廣播。
實例47
Action:android.intent.action.DATA_CONNECTION_UNSTABLE
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)連接不穩(wěn)定廣播。
實例48
Action:android.intent.action.DATA_CONNECTION_USE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)連接使用情況變化廣播。
實例49
Action:android.intent.action.ANY_DATA_CONNECTION_STATE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)連接狀態(tài)變化廣播。
實例50
Action:android.intent.action.ANY_DATA_CONNECTION_STATE
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)連接狀態(tài)變化廣播。
實例51
Action:android.intent.action.DATA_SMS_RECEIVED
Data URI:sms://10086
MIME類型:無
Category:無
說明:模擬發(fā)送數(shù)據(jù)短信接收廣播。
實例52
Action:android.intent.action.NEW_VOICEMAIL
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送新語音郵件廣播。
實例53
Action:android.intent.action.VOICE_COMMAND
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送語音命令廣播。
實例54
Action:android.intent.action.MEDIA_BUTTON
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送媒體按鈕廣播。
實例55
Action:android.intent.action.CAMERA_BUTTON
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送相機按鈕廣播。
實例56
Action:android.intent.action.HEADSET_PLUG
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送耳機插入廣播。
實例57
Action:android.intent.action.ACTION_SHUTDOWN
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送關(guān)機廣播。
實例58
Action:android.intent.action.SIM_STATE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送SIM卡狀態(tài)變化廣播。
實例59
Action:android.intent.action.BATTERY_SAVER_MODE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送省電模式狀態(tài)變化廣播。
實例60
Action:android.intent.action.AIRPLANE_MODE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送飛行模式狀態(tài)變化廣播。
實例61
Action:android.intent.action.USER_BACKGROUND
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送用戶進入后臺廣播。
實例62
Action:android.intent.action.USER_FOREGROUND
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送用戶進入前臺廣播。
實例63
Action:android.intent.action.USER_INITIALIZE
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送用戶初始化廣播。
實例64
Action:android.intent.action.USER_UNLOCKED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送用戶解鎖廣播。
實例65
Action:android.intent.action.DOCK_EVENT
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送Dock事件廣播。
實例66
Action:android.intent.action.DREAMING_STARTED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送屏保啟動廣播。
實例67
Action:android.intent.action.DREAMING_STOPPED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送屏保停止廣播。
實例68
Action:android.intent.action.ACTION_BOOT_IPO
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送IPO啟動廣播。
實例69
Action:android.intent.action.ACTION_SHUTDOWN_IPO
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送IPO關(guān)機廣播。文章來源地址http://www.zghlxwxcb.cn/news/detail-696708.html
實例70
Action:android.intent.action.ACTION_POWER_SAVE_MODE_CHANGING
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送省電模式狀態(tài)變化廣播。
實例71
Action:android.intent.action.ACTION_POWER_SAVE_MODE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送省電模式狀態(tài)變化廣播。
實例72
Action:android.intent.action.MEDIA_EJECT
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡彈出廣播。
實例73
Action:android.intent.action.MEDIA_CHECKING
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡檢查廣播。
實例74
Action:android.intent.action.MEDIA_BAD_REMOVAL
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡異常彈出廣播。
實例75
Action:android.intent.action.MEDIA_UNMOUNTABLE
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡無法掛載廣播。
實例76
Action:android.intent.action.MEDIA_NOFS
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡格式錯誤廣播。
實例77
Action:android.intent.action.MEDIA_MOUNTED
Data URI:file:///mnt/external_sd
MIME類型:無
Category:無
說明:模擬發(fā)送外部SD卡掛載廣播。
實例78
Action:android.intent.action.MEDIA_SCANNER_FINISHED
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送媒體掃描完成廣播。
實例79
Action:android.intent.action.MEDIA_SCANNER_STARTED
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送媒體掃描開始廣播。
實例80
Action:android.intent.action.MEDIA_SHARED
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡共享廣播。
實例81
Action:android.intent.action.MEDIA_UNSHARED
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡取消共享廣播。
實例82
Action:android.intent.action.MEDIA_REMOVED
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡移除廣播。
實例83
Action:android.intent.action.MEDIA_SHARED
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡共享廣播。
實例84
Action:android.intent.action.MEDIA_UNMOUNTED
Data URI:file:///mnt/sdcard
MIME類型:無
Category:無
說明:模擬發(fā)送SD卡卸載廣播。
實例85
Action:android.intent.action.MEDIA_BUTTON
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送媒體按鈕廣播。
實例86
Action:android.intent.action.CAMERA_BUTTON
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送相機按鈕廣播。
實例87
Action:android.intent.action.HEADSET_PLUG
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送耳機插入廣播。
實例88
Action:android.intent.action.ACTION_SHUTDOWN
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送關(guān)機廣播。
實例89
Action:android.intent.action.SIM_STATE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送SIM卡狀態(tài)變化廣播。
實例90
Action:android.intent.action.BATTERY_SAVER_MODE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送省電模式狀態(tài)變化廣播。
實例91
Action:android.intent.action.AIRPLANE_MODE_CHANGED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送飛行模式狀態(tài)變化廣播。
實例92
Action:android.intent.action.USER_BACKGROUND
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送用戶進入后臺廣播。
實例93
Action:android.intent.action.USER_FOREGROUND
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送用戶進入前臺廣播。
實例94
Action:android.intent.action.USER_INITIALIZE
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送用戶初始化廣播。
實例95
Action:android.intent.action.USER_UNLOCKED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送用戶解鎖廣播。
實例96
Action:android.intent.action.DOCK_EVENT
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送Dock事件廣播。
實例97
Action:android.intent.action.DREAMING_STARTED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送屏保啟動廣播。
實例98
Action:android.intent.action.DREAMING_STOPPED
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送屏保停止廣播。
實例99
Action:android.intent.action.ACTION_BOOT_IPO
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送IPO啟動廣播。
實例100
Action:android.intent.action.ACTION_SHUTDOWN_IPO
Data URI:無
MIME類型:無
Category:無
說明:模擬發(fā)送IPO關(guān)機廣播。
到了這里,關(guān)于adb shell模擬發(fā)送安卓廣播的入門知識和100個實例講解的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!