Files
androidApp/app/src/main/java/com/localtransfer/TransferService.java
lionel 168e01e09a Foreground Service Integration
- Add Foreground Service
- Reviewed Progress Method
- Reviewed Transfer Object Integration
- Fix Some Error
2021-03-17 23:09:23 +01:00

42 lines
1.1 KiB
Java

package com.localtransfer;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import androidx.core.app.NotificationCompat;
public class TransferService extends Service {
@Override
public void onCreate() {
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
0, notificationIntent, 0);
Notification notification = new NotificationCompat.Builder(this, "CHANNEL_ID")
.setContentIntent(pendingIntent)
.build();
startForeground(Transfer.NOTIF_SERVICE, notification);
//do heavy work on a background thread
//stopSelf();
return START_NOT_STICKY;
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
}