I am not certain how to resolve this, but in one Activity I call
startService, and then immediately call to start the next Activity:
Intent myIntent = new Intent(mContext, MyService.class);
      myIntent.putExtra("data1", data1Array);
      myIntent.putExtra("data2", data2Array);
      myIntent.putExtra("names", namesList.toArray(new String[0]));
      startService(myIntent);   // <== This works, the service starts,
begins to process the data

      Intent intent = new Intent();
      myIntent.putExtra("data1", data1Array);
      myIntent.putExtra("data2", data2Array);
      myIntent.putExtra("names", namesList.toArray(new String[0]));

intent.setClassName(
"my.package",
"my.package.SecondActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);  // <== This works, goes to the next activity

This works, the service starts, and begins to process the data as expected.

This works, so I am now in the new Activity, and want to connect to my
Service so I can get data from the callback interface.

So I have this in the second Activity:
@Override
protected void onResume() {
super.onResume();
if (bindService(new Intent(IMyService.class.getName()),
                mConnection, Context.BIND_AUTO_CREATE)) {
Toast.makeText(mContext, "Bound to service succeeded",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(mContext, "Bound to service failed",
Toast.LENGTH_LONG).show();
}
}

And this fails.

So, if the service is already running, how do I connect to this service so
I can get the updates?

IMyService is created by using a .aidl file, btw.

-- 
"I know that you believe you understand what you think I said, but I'm not
sure you realize that what you heard is not what I meant."
- Robert McCloskey

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to