2017-11-03 18 views
0

내 질문은 Android Wear 에뮬레이터에서 배경을 볼 수 없다는 것입니다. 유효화 된 이미지로 .setBackgroung을 선언하지만 앱을 실행하고 배경 알림이 표시되지 않습니다.내 Android Wear 에뮬레이터의 배경을 볼 수 없습니다.

누군가가 도와 주시면 감사하겠습니다. 탱크를 미리 읽어보십시오.

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()); 
} 

}

답변

0

당신이 SO post로 참조 할 수 있습니다. setLargeIcon(Bitmap) 대신 WearableExtender에서 setBackground(Bitmap) 메서드를 사용해보십시오. Android Wear 시계 모드를 만드는 방법에 대해서는 tutorial을 확인하시기 바랍니다.

추가 참조 Android Wear 통지 배경 이미지를 설정하려면 Background image for android wear notification

사각형 시계의 해상도 지금 현재의 대향하는 원형 시계면이 (에서 320x320의 해상도를 갖는 반면, 280x280이다

이 일부 있지만 분명히 잘릴 것이다).

그러나 Android Wear는 큰 이미지의 경우 기본적으로 일종의 시차 스크롤을 구현하므로 더 큰 이미지를 쉽게 처리 할 수 ​​있으며 그렇게 할 것을 권장합니다 (see this previous answer). 따라서 사용자 정의 UI 요소를 대신하여 특정 상호 작용 영역이있는 정적 전체 화면 이미지를 만들려고하지 않는 한 이미지의 크기는 걱정할 필요가 없습니다. Google은 시계의 화면 당 하나의 상호 작용 영역 만 사용하여 작업을 단순하게 유지할 것을 권장합니다.

시차 스크롤이있는 배경에 여러 이미지가 사용되는 좋은 예를 보려면 API 레벨 20의 웨어러블 하위 폴더에있는 SDK 샘플에서 찾을 수있는 GridViewPager 샘플 프로젝트를 확인하는 것이 좋습니다.

희망이 있습니다.