activity A starts activity B (in another app) with
Intent i;
PackageManager manager = getPackageManager();
try {
i = manager.getLaunchIntentForPackage("my.other.app.package.name");
if (i == null)
throw new PackageManager.NameNotFoundException();
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivityForResult(i, 1);
} catch (PackageManager.NameNotFoundException e) {
}
this is my activity B:
setContentView(R.layout.main_layout);
Button mybutton = (Button) findViewById(R.id.button1);
mybutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ArrayList<String> data = new ArrayList<String>();
data.add("1.2");
Intent returnIntent = new Intent();
returnIntent.putExtra("data", data);
setResult(RESULT_OK, returnIntent);
finish();
}
});
My problem is that onActivityResult()
in activity A is called immediately (resultCode=0) when activity B is started, instead of waiting for me to press the button. I have tried setting the launchmode of both activities to singleTop or standard (as suggested here) but that did not solve it:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="standard">
What am I doing wrong?