Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get name of activity within Intent

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

like image 309
CQM Avatar asked Nov 28 '22 01:11

CQM


2 Answers

You can use the given intent argument's component class name. Remember the class name might be empty!

intent.getComponent().getClassName()

like image 107
user3294126 Avatar answered Dec 05 '22 23:12

user3294126


try below line to get current activity name,

this.getClass().getSimpleName()
like image 42
abhi Avatar answered Dec 05 '22 23:12

abhi