- Add Foreground Service - Reviewed Progress Method - Reviewed Transfer Object Integration - Fix Some Error
42 lines
1.1 KiB
Java
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");
|
|
}
|
|
} |