ActivityManager: Warning: Activity not started, its current task has been brought to the front 的的問題

來源:互聯網
上載者:User

標籤:android   style   blog   http   color   io   strong   for   ar   

運行android程式的時候提示:ActivityManager: Warning: Activity not started, its current task has been brought to the front

但是在模擬器上顯示出了程式介面,後來google了一下,

有一組提問和回答引起了我的注意:

[html] view plaincopy
  1. Hi,  
  2.   
  3. I have a very simple android project. I got the following error message when I try to run it. The emulator is running but the application doesn‘t come up. I couldn‘t find any useful information online. Can anyone help me?  
  4.   
  5. Thanks,  
  6.   
  7. arning: Activity not started, its current task has been brought to the front public class Profile extends Activity { /Button button1; CheckBox check1, check2; EditText text1;/  


Answer:

[html] view plaincopy
  1. Hi Lewis!  
  2.   
  3. It is not an error message, it is a warning. What the system is trying to tell you: The application on the device is the same as your application in Eclipse. And because the application is already running on the device, the system tells you that it is not going to kill and restart it, but bring the activity of your already running app into the foreground. This is pretty normal. ;-)  
  4.   
  5. The warning will not continue if you edit your code and run it (because the app is then killed, reinstalled and started) or if you kill your process on the phone, e.g. via the DDMS.  


解釋:

這個不是Android平台的Bug,而是Android本身就是這樣一種處理機制。
我們在Android平台下,通過返回按鈕,或者程式本身的退出操作,去結束一個進程的時候,實際上Android虛擬機器未必會將這個進程真正的結束掉,在記憶體允許的情況下,這個程式會以緩衝的形式存在Android虛擬機器中。只有在記憶體不足的情況下時,Android系統會清理長時間不被啟用的任務,以為其他程式提供記憶體。
Android這樣做,是為了你下一次更加快速的啟動這個程式。
所以,出現樓主這種情況,是在你的程式沒有發生任何變化,並且記憶體足夠的情況下,會將上一次執行的程式,從緩衝Cached狀態直接放置到任務棧的頂端,則你的程式又可以繼續執行了。

消除警告解決辦法:

退出虛擬機器的程式從新運行一遍。

ActivityManager: Warning: Activity not started, its current task has been brought to the front 的的問題

聯繫我們

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