Note that there are some explanatory texts on larger screens.

plurals
  1. POPush notifications don't work
    text
    copied!<p>I am newbie to android. I had tried the sample given in documentation., but iam not getting any push notification only iam getting the notification icon but no content and title. Can anyone help me in getting cleared??????</p> <ol> <li>Will push notification works in emulator or not?</li> <li>In this sample i found a class as "Resultactivity". Purpose of using this<br> class?</li> </ol> <p>I had given the code below.</p> <pre><code>package com.example.pushnotification; import android.os.Bundle; import android.app.Activity; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.support.v4.app.NotificationCompat; import android.support.v4.app.TaskStackBuilder; import android.view.Menu; public class Pushactivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pushactivity); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Check Notification") .setContentText("This is to test push!"); Intent resultIntent = new Intent(this, ResultActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(ResultActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); int mId = 10; mNotificationManager.notify(mId, mBuilder.build()); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.pushactivity, menu); return true; } } </code></pre> <p>Thanks in advance </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload