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>
----------------- --------------------- ...
有什么想法吗? 任何事情都会很棒! 谢谢
添加到Falmari @ David只是做一个Project> Clean来重新编译项目 – 100rabh 2011-01-20 05:28:13
我有一个与ant目标的一些strings.xml文件相同的问题,我想也许它会刷新项目(F5)然后在设备/模拟器:) thx中启动应用程序以获取答案 – 2013-10-18 12:56:41