ActivityManager:警告:Activity没有启动,它的当前任务已经被提前

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" 

我认为这意味着蓝牙function的意图和button意图只能在层次结构系统上运行。 我的意思是,如果我要移动蓝牙button上方的button操作button将工作,但目前当应用程序运行蓝牙工程,但是当我按searchbutton什么也没有发生。

还有什么可能是有用的是我的button的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> 

————————————– …

有任何想法吗? 任何事情都会很棒! 谢谢

您是否在启动应用程序或单击button时收到警告? 如果你从eclipse运行一个应用程序而不需要重新编译(即没有代码改变),它不会经过卸载 – 安装过程,它只是把应用程序推到前面就像你从电话中恢复。 这不是一个错误,而是一个“按预期工作”

多数民众赞成在日食用adt插件这个问题是显而易见的。 主要问题是…你的应用程序是在仿真器/设备上启动的,现在你尝试再次启动它,而不需要对源代码进行任何修改。 可能的解决scheme:1重build项目,并再次启动应用程序(花更多的时间)2添加一些空格/新行代码,并再次启动应用程序

我更喜欢第二个选项因为它非常快。 但恕我直言,我认为它的愚蠢的问题侧插件的开发人员

在我的情况下,问题是我的HTC连接到PC的configuration错误。 尝试在断开电话的情况下运行模拟器 –

如果您的AVD已启动并locking,则可能。 你需要解锁AVD显示。

这意味着您试图在模拟器中解压的应用程序和已经存在的模拟器中的相同应用程序是相同的。 他们两个都没有变化

你仍然得到错误,然后项目 – “从Eclipse清洁,重新启动avd和deply了..

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

1-在代码中进行一些更改,然后重新编译。

2-或者你可以轻松closures应用程序,然后重新启动与Eclipse或Android工作室或…

如果问题仍然存在,请尝试卸载应用程序并重新运行。