在编译NDK程序时,由于修改了一下C++代码,用Cygwin重新编译后,然后在eclipse中运行程序时, console输出界面显示 Warning:Activity not started, its current task has been brought to the front 这时候发现模拟器上显示的内容还是原来的; 对于这个问题具体原因还不是很清楚,但在调式的时候发现,这样做可以解决这个问题;首先在Package Explorer中找到要运行的程序,然后点击右键,选中 refresh, 然后再选中run as -----> android application,最后解决了问题; 对比没有经过 refresh 和 经过 refresh 这步, 观察console输出时,发现两者有不同的部分
以下是经过 refresh 这步在console输出的信息 [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 }
以下是没有经过 refresh 这步在console输出的信息 [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 front
在网上找到比较靠谱的解释: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'! 也就是在修改了代码后,在没有重新编译这步, 模拟器原来的.apk就不会经过卸载跟重新安装这一步;所以当在eclipse中只是点击运行时,由于现在的程序没有经过编译这一步,所以安装的程序跟原来的一样, 所以在console输出的信息中会出现这一行信息: |