活动尚未开始,其当前任务已被置于最前面


73

我有一个非常简单的android项目。我尝试运行它时收到以下错误消息。模拟器正在运行,但应用程序未启动。我在网上找不到任何有用的信息。谁能帮我?

Warning: Activity not started, its current task has been brought to the front

public class Profile extends Activity {
        /*Button button1;
        CheckBox check1, check2;
        EditText text1;*/

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     }
}

<EditText android:text="@+id/EditText01" android:id="@+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:enabled="false"></
EditText><CheckBox android:text="@+id/CheckBox03" android:id="@+id/
CheckBox03" android:layout_width="fill_parent"
android:layout_height="wrap_content">
</CheckBox>
<CheckBox android:text="@+id/CheckBox02" android:id="@+id/CheckBox02"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</CheckBox>
<CheckBox android:text="@+id/CheckBox01" android:id="@+id/CheckBox01"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:checked="true">
</CheckBox>

</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.seiservices.blending"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".Profile"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
                <category
android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="8" />

</manifest> 

Answers:


105

这不是错误消息,而是警告。这意味着该应用程序(的一个任务)正在运行,即使发出了“ startActivity”请求来运行该任务或应用程序中的另一个活动。系统只是将应用程序的当前任务放在前台。(如果您使用模拟器在Eclipse或AndroidStudio中运行,则会发生这种情况。)

系统试图告诉您的内容:设备上的应用程序与Eclipse中的应用程序相同。并且由于该应用程序已经在设备上运行,因此系统会告诉您它不会终止并重新启动它,而是将已经在运行的应用程序的活动置于前台。这很正常。;-)

如果您编辑代码并运行它(因为该应用程序随后被终止,重新安装并启动),或者您在电话上(例如通过DDMS)终止了进程,则警告将不会继续。


1
感谢您的快速评论。但是我看不到我的应用程序在模拟器中运行。模拟器正在运行,我只能看到主屏幕。我应该怎么做才能查看我的应用程序?首次创建应用程序时,我可以看到它在模拟器中运行。
露茵·孙

我认为您可能会为罗伯特的解决方案出个主意-也许这是您的问题。否则:将您的AndroidManifest.xml上传到pastebin.com,并在此处发布链接,以便我们进行查看。:-)
mreichelt 2010年

1
单击窗口>打开透视图>其他...> DDMS:从Eclipse中运行DDMS,
威尔

3
@mreichelt:“罗伯特的解决方案”在哪里或什么地方?除了您的评论外,我在该问题或其答案或评论中的任何地方都没有看到“罗伯特”的出现。
OR Mapper

21

我以前见过-即使您可能没有进行任何代码更改,您也想重新运行您的应用程序。在模拟器上,单击“后退”按钮(位于菜单按钮右侧),然后像往常一样从Eclipse运行您的应用程序。


8

如果您从eclipse运行应用程序而没有重新编译(如果您没有更改代码,则不会重新编译),则它不会通过卸载-安装过程,而是像启动应用程序一样将应用程序推到最前面,就会发生这种情况从家庭启动器。这不是错误,而是“按预期工作”。

问候



4

我发现eclipse以某种方式进入一种状态,即即使代码发生了变化,它也无法构建新的apk。删除apk:

rm ./bin/“您的应用名称” .apk

然后从eclipse重新运行您的应用程序即可解决此问题。


1

如果收到此警告,则意味着您没有更改任何代码行,并且此项目实例正在模拟器或设备上运行。因此,如果您想再次运行它,可以:

1-在您的代码中进行一些更改,然后再次编译。

2-或者您可以轻松关闭应用程序,然后使用eclipse或android studio或...重新启动它

如果问题仍然存在,请尝试卸载该应用程序,然后再次运行。


0

在模拟器上

  • 按“主页”
  • “菜单”按钮->滚动浏览列表,然后选择要运行的应用
  • 按“强制停止”。

0

这是警告,表明应用程序已在运行。.我已经通过重新编译代码解决了该问题,您可以关闭模​​拟器并重新运行您的应用程序。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.