android am命令以及hotkey檔案的編寫,

來源:互聯網
上載者:User

android am命令以及hotkey檔案的編寫,

1.撥打到電話:am start -a android.intent.action.CALL -d tel:10086

            這裡-a表示動作,-d表述傳入的資料,還有-t表示傳入的類型。

2. 開啟一個網頁:am start -a android.intent.action.VIEW -d  http://www.baidu.com (這裡-d表示傳入的data)

3.啟動一個activity:am start -n com.hysmarthotel.movie/com.hysmarthotel.movie.MainActivity

4:啟動一個服務:am startservice -n com.android.music/com.android.music.MediaPlaybackService (這裡-n表示組件)

5:發送一個廣播:am broadcast -a com.smz.mybroadcast  am broadcast -a <廣播動作>

另外am命令可以編寫進android系統中,存到到system/etc/hotkey.xml中,

hotkey.xml編寫格式如下:

<?xml version="1.0" encoding="utf-8"?>
<hotkey>
<event
code="00b7"
cmd="am start -n com.amlogic.tvplay/com.amlogic.tvplay.MainActivity"/>
<event
code="00b8"
cmd="am start -n com.hysmarthotel.movie/com.hysmarthotel.movie.MainActivity"/>
<event
code="003f"
cmd="am start -n sdmc.hotel.remote/sdmc.hotel.remote.KeXinListView"/>
</hotkey>

其中event表示索引值對,code表示你遙控器的碼值(16進位)cmd表示你需要發送的廣播或者啟動的activity

當你配置好hotkey的時候,你在android應用程式層按相關的鍵,系統就會執行hotkey裡面相關的命令

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.