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