Image on startup / loading

I am developing an application that at the time of loading from the onCreate point I just have a black screen (until the application receives support). If you look at other applications, they have a company logo or a cool image that appears in a few seconds, can someone tell me how to do this, please?

And if you can set it to display in the minimum amount of time?

+8
android oncreate image loading
source share
3 answers

Create a new action that displays the image in a few seconds and redirects to your main activity:

public class SplashActivity extends Activity { private static final long DELAY = 3000; private boolean scheduled = false; private Timer splashTimer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); splashTimer = new Timer(); splashTimer.schedule(new TimerTask() { @Override public void run() { SplashActivity.this.finish(); startActivity(new Intent(SplashActivity.this, MainActivity.class)); } }, DELAY); scheduled = true; } @Override protected void onDestroy() { super.onDestroy(); if (scheduled) splashTimer.cancel(); splashTimer.purge(); } } 

Set the image as the background for this operation. Hope this helps. Good luck

+10
source share

This is the initial image, also known as the โ€œsplash screenโ€. Here you can find how to make a screensaver.

+1
source share

Your needs are a pop-up screen. Here is my screensaver code.

Just add a new activity and install the application to open this operation.

public class SplashActivity extends DeviceInfoAbstractActivity {

 @SuppressLint("MissingSuperCall") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.activity_splash); passScreen(); } private void passScreen() { new CountDownTimer(1000, 2000) { @Override public void onTick(long millisUntilFinished) { } @Override public void onFinish() { Intent intent = RDAIntentHelpers.getClearCacheIntent(); intent.setClass(SplashActivity.this, MainActivity.class); startActivity(intent); } }.start(); } @Override public void onBackPressed() { //no exit } } 

and this getClearCacheIntent () method

 public static Intent getClearCacheIntent() { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); return intent; } 

After that, your splash screen will remain on the screen for 2 seconds. Do whatever you want =)

0
source share

All Articles