I want to make custom notification in my application, I found an example of what I need on en-So . I did everything as in the example, but the notification does not pop up, although it is displayed in the dock.
How can I make the notification pop up? Or maybe there are some other alternative ways?
Here is the code I use:
RemoteViews remoteViews = new RemoteViews(activity.getPackageName(), R.layout.notification_widget); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( activity).setContentTitle("sdgasgsag").setSmallIcon(R.drawable.icon).setContent( remoteViews); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(activity, activity.getClass()); // The stack builder object will contain an artificial back stack for // the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(activity); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(activity.getClass()); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.button1, resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(100, mBuilder.build());
notification не всплывает хотя в доке он отображается.- Yuriy SPb ♦