Reputation: 44278
I am using some various ad networks, they all require their own activity names to be added to the manifest.
I want to know when users click them, so I put in an override for startActivity(Intent intent)
but I need to inspect the intent object to conditionally set some values.
for instance, with tap for tap's network, it will launch an activity from the class com.ads.TapForTap
.. upon a click this will call startActivity(Intent intent) how do I get the name of the class from the intent?
thanks
Upvotes: 5
Views: 25432
Reputation: 381
You can use the given intent argument's component class name. Remember the class name might be empty!
intent.getComponent().getClassName()
Upvotes: 28
Reputation: 36449
The following line should return the fully qualified name of the Activity you want to start if you have:
getPackageManager()
).String className = myIntent.resolveActivity (myContext.getPackageManager()).getClassName();
For more info, see the Intent
documentation for resolveActivity()
.
Upvotes: 4
Reputation: 513
try below line to get current activity name,
this.getClass().getSimpleName()
Upvotes: 9