Notifications not shown on Gear Fit

1k Views Asked by At

I have a Samsung Gear Fit R350 connected on a Samsung S5. I have developed an app which creates notifications. Now I would like that the notifications appears at the gear fit too.

Here is my code, that doesn't work:

generateNotification(Context context, String message) {

    int icon = R.drawable.ic_launcher;

    NotificationCompat.Builder builder  = new  NotificationCompat.Builder(context)
            .setWhen(System.currentTimeMillis())
            .setAutoCancel(true)
            .setLights(Color.RED, 1000, 300)
            //.setVibrate(new long[]{off, on, off, on,})
            .setVibrate(new long[]{0, 500, 50, 500, 250, 500,500,750})
            .setContentTitle("Einbruch")
            .setContentText(message)
            .setSmallIcon(icon)
            .setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.sherwood_forest));

    Intent resultIntent = new Intent(context, MainActivity.class);
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent =
            stackBuilder.getPendingIntent(
                    0,
                    PendingIntent.FLAG_UPDATE_CURRENT
            );

    NotificationCompat.Action action =
            new NotificationCompat.Action.Builder(R.drawable.ic_launcher,"Alarm",resultPendingIntent)
                    .build();

    builder.setContentIntent(resultPendingIntent);
    builder.extend(new WearableExtender().addAction(action));



    NotificationManagerCompat nm = NotificationManagerCompat.from (context);
    
    nm.notify(0, builder.build());
}
1

There are 1 best solutions below

0
On

There are some differences between different Gear devices Samsung published so far. The Gear 2 (NEO) uses the Samsung Accessory Framework while the Gear Fit uses Samsung CUP (Companion UI Profile).

To my knowledge, the Gear Fit won't work with the WearableExtender at all. In order to bring up something on the watch you have basically two options:

a) (probably what you want): Show standard notifications from the phone on the gear fit. This is achieved by enabling notifications in the Gear Fit Manager under Notifications for your application. This seems to be a standard mechanism. b) if you want to achieve more - i.e. have functionality with the notification, you may need to write an application using Samsung CUP. The CUP framework has classes to create a UI on the gear. When you launch an CUP application you can bring the UI on the gear up and - for example - let it vibrate. That would be for more rich content or functions.