Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8860147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:12:46+00:00 2026-06-14T15:12:46+00:00

I like to pass data from ServicesActivity.java to NotificationView.java through notification services. But the

  • 0

I like to pass data from ServicesActivity.java to NotificationView.java through notification services. But the data passing is correct at the first times, when I send another data into it, it doesn’t updated its previous data.As you seen, the logcat output below,first times, I sent two data into notification and the output it passed at the NotificationView.java is no problem.After that,I re-send three data into it and its output at NotificationView.java still is two data. Whatever I sent how many data into notification, its output at NotificationView.java still follow its first times output.Here is the logcat output:

11-21 10:42:03.645: D/String(25694): admin,admin
11-21 10:42:33.645: D/String(25694): admin,admin,admin
11-21 10:42:06.308: D/how(25694): admin,admin
11-21 10:42:36.518: D/how(25694): admin,admin

**The Log.d(“String”,str) is at displayNotification() of ServicesActivity.java and Log.d(“how”,i) is at NotificationView.java.

ServicesActivity.java

public class ServicesActivity extends Activity {

IntentFilter intentFilter;
int notification = 1;
String datapassed; 
String str = "";
String[] data;
int dlength;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_services);

    intentFilter = new IntentFilter();
    intentFilter.addAction(MyService.MY_ACTION);
    registerReceiver(intentReceiver, intentFilter);
}

public void startService(View view){
    startService(new Intent(getBaseContext(),MyService.class));
    Toast.makeText(getBaseContext(), "start",
            Toast.LENGTH_SHORT).show();
}

public void stopService(View view){
    stopService(new Intent(getBaseContext(),MyService.class));
    Toast.makeText(getBaseContext(), "stop",
            Toast.LENGTH_SHORT).show();
}


private BroadcastReceiver intentReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
    datapassed = intent.getStringExtra("DATAPASSED");
    if(datapassed.length()>0){

        data = datapassed.split("[*]");
        dlength = data.length;

        for(int i=0;i<dlength;i++){
            if(i==dlength-1){
                str += String.valueOf(data[i]);                 
            }else{
                str += String.valueOf(data[i]) + ",";
            }   
        }
        Log.d("dataServices",str);
        displayNotification();
            str = "";           
    }
    }
    };

    protected void displayNotification(){
        Intent i = new Intent(this,NotificationView.class);
        i.putExtra("notification", notification);
        i.putExtra("name",str);
        Log.d("String",str);
        PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);

        NotificationManager mnotis =(NotificationManager)getSystemService(NOTIFICATION_SERVICE);

        Notification notis = new Notification(R.drawable.notices2,"Reminder:You have " + dlength + " new friend request",System.currentTimeMillis());
        notis.setLatestEventInfo(this,"Friend Request", str + "has sent you a friend request",pi);
        notis.vibrate = new long[]{100,250,100,500};
        mnotis.notify(0, notis);
    }
  }

NotificationView.java

public class NotificationView extends Activity{

String[] people;
ListView lv;
Button btn1,btn2;

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view);  
    NotificationManager mnotis =(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    mnotis.cancel(getIntent().getExtras().getInt("notificationID"));
    String i = getIntent().getExtras().getString("name");
    people = i.split("[,]");
    Log.d("how",i);

    lv= (ListView) findViewById(android.R.id.list);
    btn1 = (Button)findViewById(R.id.acceptbtn);
    btn2 = (Button)findViewById(R.id.closebtn);
    ArrayAdapter<String> list = new ArrayAdapter<String>(NotificationView.this,R.layout.friendlist_item, R.id.friend_name,people);
    lv.setAdapter(list); 

    btn2.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View v)
        {
            finish();
        }
    });
}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:12:47+00:00Added an answer on June 14, 2026 at 3:12 pm

    By default, if you only change the extras, Android will use the existing (cached) PendingIntent. Use the FLAG_UPDATE_CURRENT flag to force it to create a new one with the specified extras.

    http://developer.android.com/reference/android/app/PendingIntent.html#FLAG_UPDATE_CURRENT

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to pass some data structures from java to perl. In perl,
I would like to pass data from a database column to another page via
I'd like to pass data from one asp.net page to another. I've seen that
I've found two parameters defined like these: &TM_PERIOD+4&/&TM_PERIOD(4)& It's to pass data from a
I would like to pass certain data from an instance of an object to
I would like to know how can I pass data from controller to view
I'm trying to pass data from one activity to another via Intent.putExtras like this:
I would like to pass data from a dynamically built form via ajax to
I'd like to pass some data from a foreground activity to another that is
I usually pass data through .post() like this: $.post( /ajax.php, $(#form).serialize(), function(responseJSON) { console.log(responseJSON);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.