Change imports

This commit is contained in:
jacques 2020-12-26 21:52:33 +01:00
parent a71be18adb
commit 8d2939fe09

View file

@ -2,13 +2,15 @@ package net.foucry.pilldroid;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.job.JobParameters; import android.app.job.JobParameters;
import android.app.job.JobService; import android.app.job.JobService;
import android.content.Context; import android.content.Intent;
import android.os.Build; import android.graphics.BitmapFactory;
import android.util.Log; import android.util.Log;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import java.util.List; import java.util.List;
@ -26,6 +28,7 @@ public class PillDroidJobService extends JobService {
@Override @Override
public boolean onStartJob(JobParameters params) { public boolean onStartJob(JobParameters params) {
Log.d(TAG, "Job started"); Log.d(TAG, "Job started");
createNotificationChannel();
doBackgroundWork(params); doBackgroundWork(params);
return false; return false;
@ -79,11 +82,12 @@ public class PillDroidJobService extends JobService {
*/ */
private void scheduleNotification() { private void scheduleNotification() {
Log.d(TAG, "schedule notification"); Log.d(TAG, "schedule notification");
/*createNotificationChannel(); createNotificationChannel();
Intent intent = new Intent(this, MedicamentListActivity.class); Intent intent = new Intent(this, MedicamentListActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,0); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID) NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "PillDroid")
.setSmallIcon(R.drawable.ic_pill_alarm) .setSmallIcon(R.drawable.ic_pill_alarm)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_foreground))
.setContentTitle(getString(R.string.app_name)) .setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.notification_text)) .setContentText(getString(R.string.notification_text))
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setPriority(NotificationCompat.PRIORITY_DEFAULT)
@ -92,9 +96,9 @@ public class PillDroidJobService extends JobService {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
int notificationId = 666; int notificationId = 666;
notificationManager.notify(notificationId, builder.build());*/ notificationManager.notify(notificationId, builder.build());
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); /*NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O){ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O){
NotificationChannel notificationChannel = new NotificationChannel("123", "Pilldroid", NotificationManager.IMPORTANCE_DEFAULT); NotificationChannel notificationChannel = new NotificationChannel("123", "Pilldroid", NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(notificationChannel); notificationManager.createNotificationChannel(notificationChannel);
@ -105,7 +109,7 @@ public class PillDroidJobService extends JobService {
.setContentText(getString(R.string.notification_text)) .setContentText(getString(R.string.notification_text))
.setSmallIcon(R.drawable.ic_pill_alarm); .setSmallIcon(R.drawable.ic_pill_alarm);
notificationManager.notify(1, notification.build()); notificationManager.notify(1, notification.build());
*/
} }
/** /**