How to get main Activity class or class name of my application?
Thanks a lot!
This can be found in the application's manifest. The main activity is the activity with the intent-filter whose name is android. intent. action.
The only required attribute for this element is android:name, which specifies the class name of the activity.
An activity represents a single screen with a user interface just like window or frame of Java. Android activity is the subclass of ContextThemeWrapper class. The Activity class defines the following call backs i.e. events. You don't need to implement all the callbacks methods.
This worked perfectly for me in Kotlin:
callingActivity::class.simpleName
or in Java:
activity.getClass().getSimpleName()
To get your launcher activity use http://developer.android.com/reference/android/content/pm/PackageManager.html#getLaunchIntentForPackage(java.lang.String)
getLaunchIntentForPackage
On this Intent call getComponentName
and from the returned CompomemtName call getClassName
http://developer.android.com/reference/android/content/ComponentName.html
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