Find out which activity started my activity?
I want to find 开发者_如何学JAVAout which activity started my activity in android. I can get the intent that started the activity using getIntent()
but I am not able to find out which activity started the intent in the first place.
Use getCallingActivity()
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
You can use ActivityCompat.getReferrer()
for this purpose.
精彩评论