Say I have an Intent like this:
Intent intent = new Intent(context, MyActivity.class);
I then want a method that will return true for the following:
boolean found = intent.getSomeMethodToRetrieveActivity() instanceof MyActivity;
Basically is there any way to find out what Activity the intent resolves to?
any ideas?
EDIT
Perusing the src I can see I can get the class name like this:
intent.getComponent().getClassName()
which will return "com.my.package.MyActivity
" which is close but I'd like to use instanceof
To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.
First you use startActivityForResult() with parameters in the first Activity and if you want to send data from the second Activity to first Activity then pass the value using Intent with the setResult() method and get that data inside the onActivityResult() method in the first Activity .
I just ended up using equals()
like in my question with:
intent.getComponent().getClassName()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With