0
我正在構建一段代碼,用於模擬電話接收活動藍牙連接時的活動。這是作爲一項服務運行,因此它可以在當下被採用。Android:藍牙活動啓動
這是我正在使用的代碼。目前它沒有啓動意圖,但也沒有失敗。我如何才能正確運行?
import android.app.Service;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
public class detectService extends Service{
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
private BroadcastReceiver ConnectListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action))
{
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
//Start Second Activity
Intent secondIntent = new Intent(detectService.this, otherClass.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(secondIntent);
}
}
};
}
甜,剛纔它給了我一個問題,我可以由於我的手機沒有連接到我的電腦,因此我需要logcat。感謝您的提示,但! – CodeMonkeyAlx