Oooh. Don't call Activities from a Service. If you do that, in essence
you're popping something to the foreground independent of the user's
actions, which is a Bad Thing.
Why call Activity B? Can't you do the work in the Service? If you need user
input, try using an AsyncTask instead of a Service.
It's hard to tell you what the right thing to do is, given that you don't
say much about what you're trying to accomplish. But *don't* call an
Activity from a Service.
On Thursday, October 25, 2012 1:28:27 AM UTC-7, Archana wrote:
>
> Hi, I want to call an Activity A from a Service in Android(and pass some
> Strings to it). This activity A inturns calls another activity B with
> startActivityForResult(). Basically, I want my service to wait till the
> result from activity B is obtained. Please give me some idea of how this
> implementation can be done(and which flag to set in intent)?
>
> Service:
> Intent intent = new Intent(getBaseContext(),ActivityA.class);
> intent.putExtra("code",script);
> intent.putExtra("type", type);
> intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> startActivity(intent);
> ActivityA:
> Intent intent = new Intent(this,ActivityB.class);
> intent.putExtra("code",code);
> intent.putExtra("type", type);
> startActivityForResult(intent,REQUEST_CODE);
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en