簡體   English   中英

Activity 沒有啟動,它的當前任務已經被放到了前面

[英]Activity not started, its current task has been brought to the front

我有一個非常簡單的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> 

這不是錯誤消息,而是警告。 這意味着應用程序(的任務)正在運行,並且即使發出了“startActivity”請求來運行該任務或應用程序中的其他活動。 系統只是將該應用程序的當前任務帶到前台。 (如果您使用模擬器在 Eclipse 或 AndroidStudio 中運行,就會發生這種情況。)

系統試圖告訴您什么:設備上的應用程序與您在 Eclipse 中的應用程序相同。 並且因為應用程序已經在設備上運行,系統會告訴你它不會殺死並重新啟動它,而是將你已經運行的應用程序的活動帶到前台。 這是很正常的。 ;-)

如果您編輯代碼並運行它(因為應用程序隨后被終止、重新安裝並啟動),或者如果您在電話上終止您的進程,例如通過 DDMS,警告將不會繼續。

我以前見過這個 - 即使您可能沒有進行任何代碼更改,您也想重新運行您的應用程序。 在模擬器上,單擊后退按鈕(在菜單按鈕的右側),然后像往常一樣從 Eclipse 運行您的應用程序。

如果您從 Eclipse 運行應用程序而不重新編譯(如果您沒有更改代碼,則不會進行重新編譯),它不會通過卸載-安裝過程,而是將應用程序推到前面,就像您啟動應用程序一樣從主頁啟動器。 這不是錯誤,而是“按預期工作”。

問候

Project > Clean然后再次啟動你的模擬器。

我發現 eclipse 不知何故進入了一種狀態,即使代碼更改,它也不會構建新的 apk。 刪除apk:

rm ./bin/"你的應用程序名稱".apk

並從 Eclipse 重新運行您的應用程序可以解決此問題。

如果您收到此警告,則表示您沒有更改任何代碼行,並且您的項目實例正在模擬器或您的設備上運行。 所以如果你想再次運行它,你可以:

1- 對代碼進行一些更改,然后再次編譯。

2- 或者您可以輕松關閉應用程序,然后使用 eclipse 或 android studio 或...

如果問題仍然存在,請嘗試卸載該應用程序並再次運行。

在模擬器上,

  • 按“主頁”
  • “菜單”按鈕 -> 滾動列表並選擇您正在運行的應用程序
  • 按“強制停止”。

這是警告它說應用程序已經在運行..我已經通過重新編譯我的代碼解決了這個問題,你可以關閉你的模擬器並重新運行你的應用程序..好運快樂編碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM