Я пытаюсь отправить 2 строки с помощью Уведомления, но я не знаю, как мне это сделать. Я использовал putExtra для своих строк, но на другой активности я получаю нулевое значение. Я не знаю, что делать с другой деятельностью. Я читал об этом в сети, но я не понял. Кто-нибудь может мне помочь?
Вот мой код:
private void setNotifiy(){
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence NotificationTicket = "You have a notification";
//CharSequence NotificationContent = ;
CharSequence contentTitle = "You are close to "+name_shop+"!!!";
CharSequence contentText ="So,you can go for shopping:)";
long when = System.currentTimeMillis();
Notification notification = new Notification(R.drawable.icon,
NotificationTicket, when);
Context context = getApplicationContext();
Intent notificationIntent = new Intent(this, ShopsOnMap.class);
notificationIntent.putExtra("latshop",lat_choose);
notificationIntent.putExtra("longshop", long_choose);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notificationManager.notify(NOTIFICATION_ID, notification);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
}
В классе ShopsOnMap я написал так:
String q = getIntent().getStringExtra("latshop");
System.out.println("!!"+q+"$$");
и я получаю q = null.
Мне нужен простой пример или любая идея, которая могла бы мне помочь. Спасибо.