my question is for I can't see the background in my Android Wear emulator, I declare .setBackgroung with a validated image but when I run the App and send me a notification the background does not show.
Any help?
public class NotificationService extends FirebaseMessagingService {
public static final String TAG = "FIREBASE";
public static final int NOTIFICATION_ID = 001;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
//super.onMessageReceived(remoteMessage);
Log.d(TAG, "From: " + remoteMessage.getFrom());
Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
enviarNotificacion(remoteMessage);
}
public void enviarNotificacion(RemoteMessage remoteMessage){
Intent i = new Intent();
i.setAction("TOQUE_ANIMAL");
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
Uri sonido = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.drawable.ic_full_poke,
getString(R.string.texto_accion_toque), pendingIntent)
.build();
NotificationCompat.WearableExtender wearableExtender =
new NotificationCompat.WearableExtender()
.setHintHideIcon(true)
.setBackground(BitmapFactory.decodeResource(getResources(),
R.drawable.bk_androidwear_notification))
.setGravity(Gravity.CENTER_VERTICAL);
NotificationCompat.Builder notificacion = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notificacion)
.setContentTitle("Notificacion")
.setContentText(remoteMessage.getNotification().getBody())
.setAutoCancel(true)
.setSound(sonido)
.setContentIntent(pendingIntent)
.extend(wearableExtender.addAction(action))
//.addAction(R.drawable.ic_full_poke, getString(R.string.texto_accion_toque), pendingIntent)
;
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
notificationManager.notify(NOTIFICATION_ID, notificacion.build());
}
}
You may refer with this SO post. Try to use setBackground(Bitmap)
method from WearableExtender
instead of setLargeIcon(Bitmap)
. You may also check this tutorial on how to create a watchface for Android Wear.
Additional reference to set background image for Android Wear notification: Background image for android wear notification
The resolution for square watch faces as of right now is 280x280, whereas the circular watch face has a resolution of 320x320 (although some of this will be cut off, obviously).
However, Android Wear implements a sort of parallax scrolling by default for larger images, so it can handle larger images with great ease, and it is even recommended that you do so (see this previous answer). So you really shouldn't worry about the size of the image, unless you were trying to create a static, full-screen image with specific areas of interaction as a substitute for custom UI elements (which you can do, I might add, although Google recommends you have only one area of interaction per screen on the watch to keep things simple).
If you want to see a good example of multiple images being used for backgrounds with parallax scrolling, I recommend you check out the GridViewPager sample project, which can be found in the SDK samples in the wearable subfolder for API level 20.
Hope this helps!