Android - startActivityForResult immediately triggering onActivityResult

前端 未结 13 1163
感情败类
感情败类 2020-11-27 10:54

I am launching activities from the main activity in my app using the call startActivityForResult(intent, ACTIVITY_TYPE), and they are all working but one.

13条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 11:27

    I'd also like to add that you could call an external app with:
    Intent in = caller.getPackageManager().getLaunchIntentForPackage("com.your.package.here");
    Which would create an intent with Intent.FLAG_ACTIVITY_NEW_TASK added by default, so call:
    in.setFlags(0);
    Which will clear that flag, and then you can proceed to: startActivityForResult(in, action);

    Reason I'm doing this is that I have a utility app that has common functionality between a few other apps and I can keep the code changes to one location instead of worrying about multiple updates.

提交回复
热议问题