簡體   English   中英

ActivityManager:警告:活動未啟動,其當前任務已被帶到前面

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

package supa.mack.doppler;

import java.util.Set;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.bluetooth.*; 
import android.widget.Toast;

public class doppler_test extends Activity {
TextView out;

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

out = (TextView) findViewById(R.id.out);

// Getting the Bluetooth adapter
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
out.append("\nAdapter: " + adapter);

// Check for Bluetooth support in the first place 
// Emulator doesn't support Bluetooth and will return null
if(adapter==null) { 
out.append("\nBluetooth NOT supported. Aborting.");
return;
}

// Starting the device discovery
out.append("\nStarting discovery...");
adapter.startDiscovery();
out.append("\nDone with discovery...");

// Listing paired devices
out.append("\nDevices Pared:");
Set<BluetoothDevice> devices = adapter.getBondedDevices();
for (BluetoothDevice device : devices) {
out.append("\nFound device: " + device);
}

Button searchButton=(Button) findViewById(R.id.search_button);
searchButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
Intent intent=new Intent(
doppler_test.this,
search_result.class
);

startActivity(intent);
}
}); 
}
} 

-------------------------------------- ...

這是問題所在的代碼....

當我運行android模擬器時,它並沒有給我一個錯誤

"[2010-08-25 09:12:42 - doppler_test] ActivityManager: Warning: Activity not started, its current task has been brought to the front"

我認為這意味着藍牙功能和按鈕意圖的意圖僅在層次結構系統上運行。 我的意思是,如果我將按鈕操作器移動到藍牙之上,按鈕就可以工作,但是當前應用程序運行時藍牙有效,但是當我按下搜索按鈕時沒有任何反應。

還有什么可能有用的是我的按鈕的XML代碼,所以這里......

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.co…
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:background="@color/purple_flurp"…
<TextView 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/hello"/>
<Button
android:id="@+id/search_button"
android:layout_height="wrap_content" 
android:text="@string/search" 
android:layout_width="fill_parent"/>

<TextView 
android:text="@+id/TextView01" 
android:id="@+id/out" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content">
</TextView>
</LinearLayout>

-------------------------------------- ...

有任何想法嗎? 什么都會很棒! 謝謝

您是否在啟動應用程序或單擊按鈕時收到警告? 如果您從eclipse運行應用程序而不必重新編譯(即沒有代碼更改),它不會通過卸載安裝過程,它只是將應用程序推送到前面,就像您從手機中恢復它一樣。 這不是錯誤,而是“按預期工作”

這個問題在eclipse上使用adt插件很明顯。 主要問題是...您的應用程序是在模擬器/設備上啟動的,現在您嘗試重新啟動它而不對源代碼進行任何更改。 可能的解決方案:1重建項目並再次啟動應用程序(需要更多時間)2為代碼添加一些空格/新行並再次啟動應用程序

我更喜歡第二種選擇。 但恕我直言,我認為它在側插件的開發人員的愚蠢問題

在我的情況下,問題是我的HTC連接到PC的錯誤配置。 嘗試在手機斷開連接的情況下運行模擬器

這意味着您嘗試在模擬器中執行的應用程序以及模擬器中已存在的相同應用程序是相同的。 兩者都沒有變化..

仍然你得到錯誤然后Project - >從eclipse清理並重新啟動avd並再次沉寂..

如果你的AVD啟動並鎖定,它是可行的。 您需要解鎖AVD顯示屏。

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

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

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

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

暫無
暫無

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

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