2017-11-03 36 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)の代わりにWearableExtendersetBackground(Bitmap)メソッドを使用してください。また、tutorialに、Android Wear用ウォッチフェイスの作成方法を確認することもできます。

さらなる参照は、Android Wear通知の背景画像を設定する:Background image for android wear notification

正方形時計用解像度は今のように対向する円形の時計面は、(320×320の解像度を有するのに対し、280x280である

本の一部であるが明らかに切断される)。

しかし、Android Wearは大きな画像ではデフォルトで一種の視差スクロールを実装しているため、大きな画像を簡単に扱うことができます(see this previous answer)。ですから、カスタムUI要素の代わりに特定のインタラクション領域を持つ静的でフルスクリーンの画像を作成しようとしていない限り、イメージのサイズについて心配するべきではありません。物事を単純にするために、画面上にはインタラクションの領域が1つしかないことが推奨されています。

視差スクロールの背景に複数の画像が使用されていることを確認するには、APIレベル20のウェアラブルサブフォルダのSDKサンプルにあるGridViewPagerサンプルプロジェクトをチェックすることをおすすめします。

関連する問題