Skip to content

Commit

Permalink
Small tracking notification improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed May 6, 2024
1 parent b828888 commit 7f99253
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 5 deletions.
24 changes: 24 additions & 0 deletions app/android/res/drawable/ic_notification.xml
@@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
android:viewportWidth="234"
android:viewportHeight="234"
android:width="234dp"
android:height="234dp">
<group
android:scaleX="1.393633"
android:scaleY="1.393633"
android:translateX="-46.05505"
android:translateY="-46.05505">
<path
android:pathData="M117 159.67h42.66V74.34H117V53h64v128h-64z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M82.4724 117c0 19.072 15.4555 34.517 34.5176 34.517V82.4819C97.9179 82.4819 82.4724 97.9374 82.4724 117Z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M117 159.67H74.33V74.34H117V53H53v128h64z"
android:fillColor="#FFFFFF" />
<path
android:pathData="M151.518 117c0 19.072 -15.456 34.517 -34.518 34.517V82.4819c19.072 0 34.518 15.4555 34.518 34.5181z"
android:fillColor="#FFFFFF" />
</group>
</vector>
Expand Up @@ -143,22 +143,22 @@ public int onStartCommand( Intent intent, int flags, int startId ) {
NotificationChannel serviceChannel = new NotificationChannel(
CHANNEL_ID,
"Foreground Service Channel",
NotificationManager.IMPORTANCE_HIGH
NotificationManager.IMPORTANCE_LOW
);

NotificationManager manager = getSystemService( NotificationManager.class );
manager.createNotificationChannel( serviceChannel );

// Build notification for position tracking
Intent notificationIntent = new Intent( this, PositionTrackingService.class );
Intent notificationIntent = new Intent( this, InputActivity.class );

PendingIntent pendingIntent = PendingIntent.getActivity( this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE );

Notification notification = new Notification.Builder( this, CHANNEL_ID )
.setContentTitle( getText( R.string.notification_title ) )
.setContentText( getText( R.string.notification_message ) )
.setSmallIcon( R.drawable.ic_notification )
.setContentTitle( "Tracking" )
.setForegroundServiceBehavior( Notification.FOREGROUND_SERVICE_IMMEDIATE )
.setContentIntent( pendingIntent )
.setTicker( getText( R.string.ticker_text ) )
.build();

startForeground( SERVICE_ID, notification );
Expand Down
36 changes: 36 additions & 0 deletions app/icons/android-foreground-service-notification-icon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7f99253

Please sign in to comment.