Thursday, October 25, 2012

[android-developers] Calling Activity from Service

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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate