Fonction de notification personnalisée avec une vue à distance sur Android

J'ai édité le code à l'aide de setOnClick dans l'attente de l'intention, et ce code fonctionne pour ImageView et les notifications de texte séparé que je veux, mais j'ai encore besoin d'un peu d'aide.

Je veux mettre en pause ou jouer mediaplayer de ma classe de service, alors comment pourrais-je accéder à l'arrêt ou de lecture, méthode de service de Notification en attente d'intention?

Dit récepteurs de radiodiffusion va vous aider, mais je ne comprends pas exactement comment cela va fonctionner.
J'ai réussi à ouvrir un navigateur web à partir du bouton pause à partir de la notification, mais je ne sais pas comment accéder au service méthodes. Partager les exemples de code si vous en avez.

@SuppressWarnings("deprecation")
void showNotification() {
int pendingRequestCode = 0;
int pendingFlag = 0;
final Resources res = getResources();
final NotificationManager notificationManager = (NotificationManager) getSystemService(
NOTIFICATION_SERVICE);
Intent intent = new Intent(this,MainActivity.class);
PendingIntent pi= PendingIntent.getActivity(this, 0, intent, 0);
Notification.Builder builder = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_action_search)
.setAutoCancel(true)
.setTicker("this is notification")
.setContentIntent(pi);
//Sets a custom content view for the notification, including an image button.
RemoteViews layout = new RemoteViews(getPackageName(), R.layout.notification);
layout.setTextViewText(R.id.notification_title, getString(R.string.app_name));
Intent clickIntent = new Intent(Intent.ACTION_VIEW, Uri_myBlog);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),pendingRequestCode,  clickIntent, pendingFlag);
layout.setOnClickPendingIntent(R.id.notification_button,pendingIntent);
builder.setContent(layout);
//Notifications in Android 3.0 now have a standard mechanism for displaying large
//bitmaps such as contact avatars. Here, we load an example image and resize it to the
//appropriate size for large bitmaps in notifications.
Bitmap largeIconTemp = BitmapFactory.decodeResource(res,
R.drawable.pause);
Bitmap largeIcon = Bitmap.createScaledBitmap(
largeIconTemp,
res.getDimensionPixelSize(android.R.dimen.notification_large_icon_width),
res.getDimensionPixelSize(android.R.dimen.notification_large_icon_height),
false);
largeIconTemp.recycle();
builder.setLargeIcon(largeIcon);
notificationManager.notify(NOTIFICATION_DEFAULT, builder.getNotification());
}
PendingIntent getDialogPendingIntent(String dialogText) {
return PendingIntent.getActivity(
this,
dialogText.hashCode(), //Otherwise previous PendingIntents with the same
//requestCode may be overwritten.
new Intent(ACTION_DIALOG)
.putExtra(Intent.EXTRA_TEXT, dialogText)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
0);
}
  • Donne-moi une suggestion. - Je construire une notification du grand écran à l'aide de RemoteView de contrôle lecture/pause comme ce lien (stackoverflow.com/questions/14508369/...) Tous les sont à droite, mais quand je clique sur l'appareil touche retour et de l'application cliquez sur l'événement(Play/Pause/Avance/Fermer) bouton ne fonctionne pas.S'il vous plaît aider moi.
InformationsquelleAutor | 2012-08-31