I am trying to establish a connection between my phone and bluetooth card within service in android, But i have a problem with service. Service does an auto restart after half an hour. My goal is to keep my service running as long as possible.
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();
}