I am using parse push notification for my app , the notification comes fine but on clicking the notification I need to show them in a list view , I searched for tutorials but I could not find any . Please help me . Please explain with code , I am new to android . Thanks in advance. here is my custom receiver.
public class CustomReciever extends BroadcastReceiver {
NotificationCompat.Builder mBuilder;
Intent resultIntent;
int mNotificationId = 001;
Uri notifySound;
String alert;
@Override
public void onReceive(Context context, Intent intent) {
try{
JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
alert = json.getString("alert").toString();
}catch (JSONException e){
}
mBuilder = new NotificationCompat.Builder(context);
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(alert));
mBuilder.setPriority(Notification.PRIORITY_HIGH);
mBuilder.setSmallIcon(R.drawable.syncytium);
mBuilder.setContentText(alert);
mBuilder.setContentTitle("Syncytium");
mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
mBuilder.setAutoCancel(true);
resultIntent = new Intent(context, com.omc.sunny.syncytium.syncytium.Notification.class);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(context,0,resultIntent,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
(NotificationManager)context.getSystemService(context.NOTIFICATION_SERVICE);
notificationManager.notify(mNotificationId,mBuilder.build());
}
}
here is my Notification class
public class Notification extends AppCompatActivity {
TextView notifTv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification);
notifTv = (TextView)findViewById(R.id.notif);
}
@Override
protected void onNewIntent(Intent intent) {
String message = getIntent().getExtras().getString("alert");
notifTv.setText(message);
}
}
At first add this to your manifest
add it to application tag
then create class in packaje
YOURPACKAJE.notifications.MyReceiver
in wersite parse.com send notification like JSON
dont use
getIntent()
, useintent
in method: