2010-08-25 84 views
37
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); 
} 
}); 
} 
} 

--------------------------- ----------- ...ActivityManager:警告:活动未启动,其当前任务已提前

这是问题所在的代码....

它不给我它到底说这样的一个错误,当我运行Android模拟器

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

我认为这意味着蓝牙功能的意图和按钮意图只是操作o一个分级系统。我的意思是,如果我要将按钮操作器移动到蓝牙以上,按钮将起作用,但是当前应用程序运行时蓝牙工作正常,但是当我按下搜索按钮时,什么都不会发生。

还有什么可能是有益的是按钮我的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> 

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

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

回答

56

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

+30

添加到Falmari @ David只是做一个Project> Clean来重新编译项目 – 100rabh 2011-01-20 05:28:13

+0

我有一个与ant目标的一些strings.xml文件相同的问题,我想也许它会刷新项目(F5)然后在设备/模拟器:) thx中启动应用程序以获取答案 – 2013-10-18 12:56:41

2

这是可能的,以防万一,如果你的AVD启动和锁定。您需要解锁AVD显示器。

23

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

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

3

在我的情况下,问题是我的HTC连接到PC的配置不好。尝试运行与电话断开连接的模拟器 -

2

这意味着您尝试在模拟器中deply的应用程序和模拟器中已存在的相同应用程序是相同的。有一个在他们两人没有变化..

你仍然得到错误,那么项目 - >从日食清理并重新启动AVD和deply再次..

1

如果你得到这样的警告就意味着你没有任何改变你的代码行和你的项目的这个实例运行在模拟器或你的设备上。所以,如果你想再次运行,你可以:

1-在你的代码中做一些改变,然后再编译一遍。

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

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

相关问题