I read that a class that extends application is first run when my app is opened by my user. So I'm trying to give my application class a layout, so it may looks like a splash screen. But setContentView()
is not working on class that extends application, is there any approach to do that?
Asked
Active
Viewed 154 times
0

VincentTheonardo
- 329
- 1
- 6
- 18
-
2Application class can't have graphical representation. It can't show any UI, any View. To use splash screen - add another activity before starting your main activity. – Vladyslav Matviienko Feb 15 '17 at 10:57
-
You need to create an activity called like SplashActivity which will be an entry point for your app. You can load there whatever you want and once you're done just launch another activity and clear a backstack history. There are tons of questions about that. http://stackoverflow.com/questions/5486789/how-do-i-make-a-splash-screen – andrei_zaitcev Feb 15 '17 at 10:57
1 Answers
1
Application
Class can't be used for GUI. Instead create an Activity Splashscreen and set intent filter action as Main
and category as Launcher
<activity android:name=".SplashScreen"
android:theme="@style/Launcher.Theme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Shashank Kumar
- 1,210
- 10
- 18