0
我想在我的手機和藍牙卡之間的服務在android中建立連接,但我有一個服務問題。服務半小時後會自動重新啓動。我的目標是儘可能保持我的服務運行。藍牙服務
public void onCreate() {
Log.d("PrinterService", "Service started");
super.onCreate();
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d("PrinterService", "Onstart Command");
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter != null) {
if(bluetoothProvider != null)
bluetoothProvider = null;
bluetoothProvider = new BluetoothProvider(getApplicationContext());
bluetoothProvider.startUpdates();
}
return Service.START_STICKY ;
}
@Override
public void onDestroy() {
super.onDestroy();
}
謝謝你,我也做了同樣的事情,但服務繼續做一個自動重新啓動半小時後 – user2838231
ü需要使用報警manager.do經過報警經理的教程。 –
,我也試過'android:process =「」'在我的清單中,服務做了一個自動重啓 – user2838231