How to retrieve the activity requested by an Intent

Blundell picture Blundell · Feb 1, 2012 · Viewed 9.8k times · Source

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

Answer

Blundell picture Blundell · Feb 9, 2012

I just ended up using equals() like in my question with:

 intent.getComponent().getClassName()