在編譯NDK程序時,因爲修改了一下C++代碼,用Cygwin從新編譯後,而後在eclipse中運行程序時, console輸出界面顯示android
Warning:Activity not started, its current task has been brought to the frontapp
這時候發現模擬器上顯示的內容仍是原來的;eclipse
對於這個問題具體緣由還不是很清楚,但在調式的時候發現,這樣作能夠解決這個問題;首先在Package Explorer中找到要運行的程序,而後點擊右鍵,選中 refresh, 而後再選中run as -----> android application,最後解決了問題;spa
對比沒有通過 refresh 和 通過 refresh 這步, 觀察console輸出時,發現二者有不一樣的部分code
如下是通過 refresh 這步在console輸出的信息orm
[2011-05-08 19:13:11 - HelloWjr] Android Launch!
[2011-05-08 19:13:11 - HelloWjr] adb is running normally.
[2011-05-08 19:13:11 - HelloWjr] Performing com.wjr.hellowjr.HelloWjr activity launch
[2011-05-08 19:13:11 - HelloWjr] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'android2.2'
[2011-05-08 19:13:11 - HelloWjr] Uploading HelloWjr.apk onto device 'emulator-5554'
[2011-05-08 19:13:11 - HelloWjr]Installing HelloWjr.apk...
[2011-05-08 19:13:17 - HelloWjr]Success!
[2011-05-08 19:13:17 - HelloWjr] Starting activity com.wjr.hellowjr.HelloWjr on device emulator-5554
[2011-05-08 19:13:20 - HelloWjr] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.wjr.hellowjr/.HelloWjr }ip
如下是沒有通過 refresh 這步在console輸出的信息get
[2011-05-08 19:12:55 - HelloWjr] Android Launch!
[2011-05-08 19:12:55 - HelloWjr] adb is running normally.
[2011-05-08 19:12:55 - HelloWjr] Performing com.wjr.hellowjr.HelloWjr activity launch
[2011-05-08 19:12:55 - HelloWjr] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'android2.2'
[2011-05-08 19:12:57 - HelloWjr]Application already deployed. No need to reinstall.
[2011-05-08 19:12:57 - HelloWjr] Starting activity com.wjr.hellowjr.HelloWjr on device emulator-5554
[2011-05-08 19:12:59 - HelloWjr] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.wjr.hellowjr/.HelloWjr }
[2011-05-08 19:13:00 - HelloWjr] ActivityManager: Warning: Activity not started, its current task has been brought to the frontit
在網上找到比較靠譜的解釋:Are you getting the warning when you start the app? If you run an app from eclipse without it having to recompile (ie no code changes), it doesn't go through the uninstall-install process, it just pushes the application to the front just like you would if you resumed it from the phone. It's not an error but a 'working as intended'!io
也就是在修改了代碼後,在沒有從新編譯這步, 模擬器原來的.apk就不會通過卸載跟從新安裝這一步;因此當在eclipse中只是點擊運行時,因爲如今的程序沒有通過編譯這一步,因此安裝的程序跟原來的同樣, 因此在console輸出的信息中會出現這一行信息: