第一次 用虚拟机跑android程序时,总是出现这个warning
贴出代码与console信息
activity_main.xml
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名"
android:textSize="28sp"
/>
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView1"
android:layout_alignParentRight="true"
android:layout_marginRight="17dp"
android:ems="10"
android:hint="请输入姓名" />
MainActivity
package com.example.test;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 将布局XML文件引入activity中
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
控制台提示
[2014-08-21 22:47:39 - test] ------------------------------
[2014-08-21 22:47:39 - test] Android Launch!
[2014-08-21 22:47:39 - test] adb is running normally.
[2014-08-21 22:47:39 - test] Performing com.example.test.MainActivity activity launch
[2014-08-21 22:47:40 - test] Application already deployed. No need to reinstall.
[2014-08-21 22:47:40 - test] Starting activity com.example.test.MainActivity on device 94488e54
[2014-08-21 22:47:41 - test] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.test/.MainActivity }
[2014-08-21 22:47:41 - test] ActivityManager: Warning: Activity not started, its current task has been brought to the front
PHP中文网2017-04-17 11:52:50
This is just a warning message, not an error. The system just uses this message to tell you that the program your Eclipse will debug is exactly the same as the program currently running on your virtual machine, and because your original program is already on the virtual machine Run, so the system will not kill him or restart him, but just bring the original program to the foreground (currently running), which is normal.
If you modify your code slightly and run it again or close the program and run it again, this warning will no longer appear. Because he has been killed or restarted. Translated from http://stackoverflow.com/questions/3781182/activity-not-started-its-current-task-has-been-brought-to-the-front