android進程優先順序

來源:互聯網
上載者:User

標籤:load   enabled   span   android   系統   blog   ons   for   nbsp   

1、前台進程

2、可見進程

3、服務進程

4、後台進程

5、空進程

 

Service中新開線程和直接開線程的區別:

直接在activity中新開線程會被任務是後台進程

service中新開線程屬於服務進程,所以後台上傳圖片等都是在Service中新開線程來做這件事情

 

盡量保證Service不死的方式

1、

<service       android:name="com.dbjtech.acbxt.waiqin.UploadService"       android:enabled="true" >       <intent-filter android:priority="1000" >  //設定為1000是指線程優先順序最高,同時適用於廣播         <action android:name="com.dbjtech.myservice" />       </intent-filter>  </service> 

2、在onStartCommand()裡面調用startForeground()把Service提升為前台進程,然後再onDestroy裡面調用stopForeground()

4、在onDestroy裡面發廣播重啟Service

    stopForeground(true),並且發送廣播

5、監聽系統廣播重啟service

android進程優先順序

相關文章

聯繫我們

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