0

in my application, when i click list view item one notification will display, Now when i click that notification open another activity and display the notification content in another activity. Here when i select list view item notification will come with selected item text. After i select another list view item then also notification come with related text, but exact problem is when i open that notification, only one text will display in another activity.please fix it.

rmdListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
                    showNotification();

                           }

Now the notification method is

public void showNotification() {
    Uri soundUri = RingtoneManager
            .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    // intent triggered, you can add other intent for other actions
    Intent intent = new Intent(updateActivity.this,
            NotificationReceiver.class);        
    intent.putExtra("Name", noti);
    PendingIntent pIntent = PendingIntent.getActivity(updateActivity.this,
            0, intent, 0);  
    Notification mNotification = new Notification.Builder(this)

    .setContentTitle("Reminder!").setContentText(timeList + ":" + noti)
            .setSmallIcon(R.drawable.logosmall).setContentIntent(pIntent)
            .setSound(soundUri)             
            .build();
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);     
    mNotification.flags |= Notification.FLAG_AUTO_CANCEL;

    notificationManager.notify(0, mNotification);
}
venki
  • 77
  • 2
  • 10
  • 1
    Use SharedPref for better approach – IntelliJ Amiya Dec 26 '14 at 12:53
  • 1
    I am still not sure of your problem. Can you rephrase your post? – Jay Dec 26 '14 at 12:53
  • 1
    Are you aware how to retrieve `extra` data from an intent? Just do getIntent().getStringExtra("Name") in your called activity. – Jay Dec 26 '14 at 12:55
  • yes, i know how to retrieve data from intent, but problem is " i get some instructions from database to my list view, now when i select that list view item, display a notification with selected item instruction it is work fine " But, select that notification open one activity, then display that instruction , here i facing a problem,means that another activity display list view first item instruction only. – venki Dec 26 '14 at 13:23

1 Answers1

0

Finally i found answer for this task.First write this line into onNewIntent(getIntent()); Oncreate() method. After add this code to your Activity.

protected void onNewIntent(Intent intent) {
    // TODO Auto-generated method stub
    Bundle extras = getIntent().getExtras();
    if(extras != null){
        if(extras.containsKey("Name")){             
            setContentView(R.layout.notification);
            // extract the extra-data in the Notification
            ok_btn=(Button)findViewById(R.id.not_ok);
            String msg = extras.getString("Name");
            not_data = (TextView) findViewById(R.id.noti_txt);
            not_data.setText(msg);              
        }
    }       
    super.onNewIntent(intent);
}   

any doubts in this task plse post ur question.

venki
  • 77
  • 2
  • 10