当前位置: 动力学知识库 > 问答 > 编程问答 >

Android studio 2.1.2 taking too much time to launch the application in my android Samsung S3 mini

问题描述:

I can be able to run the previous application. but if I create the new application its not launching I got the screen shot after the 5mins, but still installing.

this is my code for in the splash screen

 new Handler().postDelayed(new Runnable() {

@Override

public void run() {

startActivity(new Intent(SplashScreen.this, MainActivity.class));

finish();

}

}, 2500);

Can anyone suggest the idea for this issue?

网友答案:

The problem is not is your code problem is in Android studio. Just follow this steps, and it works fine.

Go to Settings -> Build, Execution, Deployement -> Instant Run ->

Uncheck 1 and last option.

  1. uncheck enable instant run to....
  2. Show instant run status notification

    ============================ OR ========================================

Try this code it works fine.

try {
        Thread splashThread = new Thread() {
            public void run() {
                try {
                    sleep(2500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                handler.sendEmptyMessage(0);
            }
        };
        splashThread.start();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        System.gc();
    }

Now create Handle outside the OnCreate().

private Handler handler = new Handler() {
    @Override
    public void handleMessage(android.os.Message msg) {
        startActivity(new Intent(SplashScreen.this, MainActivity.class));
        finish()
    }
};
分享给朋友:
您可能感兴趣的文章:
随机阅读: