2015-05-03 3 views
0

два вопроса:Отклонить Android уведомления Wear после действия и не маленький значок

  • Как я могу отклонить уведомление после пользователь нажал кнопку действия
  • Маленький значок всегда не отображается зеленый Android логотип

Мой код:

int notificationId = 001; 

// Reply action 
Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setData(Uri.parse("google.navigation:///?q=48.193479,11.569957&mode=w")); 
PendingIntent actionPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); 

// Create the action 
    Notification.Action action = 
new Notification.Action.Builder(R.drawable.map_white, 
"Open Navigation", actionPendingIntent) 
.build(); 


Notification notification = 
new Notification.Builder(getApplicationContext()) 
    .setPriority(Notification.PRIORITY_HIGH) 
    .setSmallIcon(R.drawable.map_icon_notification) 
    .setContentTitle("Navigation Notification") 
    .setContentText("Please swipe left to start navigation.") 
    .extend(new Notification.WearableExtender().addAction(action).setBackground(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.background_notification))) 
    .setAutoCancel(true) 
    .build(); 


NotificationManagerCompat notificationManager = 
NotificationManagerCompat.from(ListenerService.this); 

notificationManager.notify(notificationId, notification); 
+0

В общем, если у вас есть два отдельных вопроса, то лучше размещать их отдельно на стек Переполнение. Это помогает другим людям легче находить их в будущем :-) – stkent

+0

@stkent Я помню об этом! Благодаря! – Philipp

ответ

1

Отклонить уведомление

notificationManager.cancel(notificationId) 

В Android Wear, значок уведомления отображать значок приложения

AndroidManifest.xml

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" <--- change this 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme"> 
+0

Есть ли способ сделать это автоматически? Например. как с помощью метода setAutoCancel() в NotificationBuilder: http://developer.android.com/reference/android/app/Notification.Builder.html#setAutoCancel(boolean) –