Wie kann ich einen Dienst in Android anfangen und an einen Dienst binden?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie kann ich einen Dienst in Android anfangen und an einen Dienst binden?

by Anonymous » 18 Apr 2025, 00:05

Ich versuche einen Dienst in Android :

zu starten

Code: Select all

Log.d("BLE", "Start Service");
Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
startService(gattServiceIntent);
Log.d("BLE", "Service Started");
In der BluetootherService Ich überschreibe die Funktion des OnStartCommand () , was bedeutet, dass ich das Protokoll sehen würde, wenn der Dienst gestartet wird

Code: Select all

public class BluetoothLeService extends Service {
....
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Let it continue running until it is stopped.
Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
Log.d("BLE", "onStartCommand");
return START_STICKY;
}
< /code>

ist jedoch das Log < /code> wie folgt: < /p>

07-14 21:30:23.676: D/BLE(28327): Start Service
07-14 21:30:23.676: D/BLE(28327): Service Started
Aber der OnStartCommand () wurde im Protokoll nie angezeigt. Wie kann ich den Service beginnen?

Top