Skip to content

Commit

Permalink
Make notification not so useless
Browse files Browse the repository at this point in the history
  • Loading branch information
dic1911 committed May 8, 2020
1 parent 3b519fc commit 7a31c37
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/moe/dic1911/test4speed/NetworkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -49,12 +50,16 @@ public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
Toast.makeText(this, "Service Started", Toast.LENGTH_SHORT).show();


PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);

noti = new NotificationCompat.Builder(this, CHANNEL_ID)
.setOngoing(true)
.setContentTitle(getString(R.string.running_svc))
.setContentText(getString(R.string.running))
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher_foreground))
.setContentIntent(pi)
.setDefaults(Notification.DEFAULT_SOUND).setVibrate(new long[]{0L})
.setVibrate(null)
.setChannelId(CHANNEL_ID)
Expand Down

0 comments on commit 7a31c37

Please sign in to comment.