Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I differentiate an android Activity from a SubActivity programatically?

How can I differentiate an android Activity from a SubActivity programmatically? Is there any API for that?

like image 548
daniel dreiberg Avatar asked Mar 01 '23 16:03

daniel dreiberg


1 Answers

I am assuming you are referring to detecting whether an activity was started via startActivityForResult() or not.

In that case, try getCallingActivity(). To quote the documentation, "Note: if the calling activity is not expecting a result (that is it did not use the startActivityForResult(Intent, int) form that includes a request code), then the calling package will be null."

like image 65
CommonsWare Avatar answered Apr 29 '23 22:04

CommonsWare