Android中開發Service

來源:互聯網
上載者:User

標籤:

Service的開發分為兩個步驟:定義Service和配置Service
1、定義Service
定義一個Service子類繼承於Service
2、配置Service
在AndroidManifest.xml檔案中,配置該Service。有兩種配置方法。
第一種是顯示配置,只需要使用<Service.../>標籤聲明Service的名稱。<Service.../>與其他組件標籤(例如<activity></activity>)並列位於<application></application>標籤內,為同一個應用程式所用。
第二種是隱式配置,除了聲明Service名稱之外,還需要為Service配置<intent-filter.../>子標籤。通過匹配Action屬性,說明該Service可以被那些Intent啟動。

Android中開發Service

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.