首页  >  问答  >  正文

编程 - android虚拟机跑不起:Activity not started, its current task has been brought to the front

第一次 用虚拟机跑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

巴扎黑巴扎黑2764 天前256

全部回复(2)我来回复

  • PHP中文网

    PHP中文网2017-04-17 11:52:50

    这只是一个警告信息,并不是错误,系统只是通过这个信息告诉你,你的Eclipse将要调试的程序和你当前虚拟机正在运行的程序一模一样,并且因为你原来的程序已经在虚拟机上运行,所以系统不会杀死他或者重启他,只是把这个原来的程序带到前台(当前运行),这很正常。
    如果你稍微修改下你的代码然后再运行或者把这个程序关掉再运行,这个警告就不会再有了。因为他已经被杀掉或者重启了。翻译自http://stackoverflow.com/questions/3781182/activity-not-started-its-current-task-has-been-brought-to-the-front

    回复
    0
  • 天蓬老师

    天蓬老师2017-04-17 11:52:50

    你要退出程序。再开始运行。

    回复
    0
  • 取消回复