How to get result from external application's activity?
How to get result from an external application's activity so that my application that has triggered it could know the change.
For e.g:
My application needs to check if user has been logged in. If not logged in, it allows to login through external app.
So current app. would call onActiv开发者_运维百科ityForResult() to trigger external App's activity and onActivityResult() will be called processing the exit status of external App's activity.
Solved.
Sorry for my goof up.
I have realized that I made mistakes for entire session of testing. My understanding and code were fine, but every time I made changes to both the files, I never ran the external app. with updated code.
Even I found the solution myself, i am considering Nanne's answer as my hint to solution, thus marked as accepted answer.
Thanks and sorry for ur precious time.
Your activity you've started should set a result-value with setResult(intValue)
Your first activity, that called startActivityForResult()
can check this result with the code provided in the example
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == PICK_CONTACT_REQUEST) {
if (resultCode == RESULT_OK) {
//do something
}
}
}
this is the code that is useful to u for one app to another app
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent res = new Intent();
String mPackage = "com.ReachOut";
String mClass = ".splash1";
res.setComponent(new ComponentName(mPackage,mPackage+mClass));
startActivity(res);
}
});
精彩评论