0

I am showing a wallpaper when the application starts and after a timeout second activity starts. I am using below code for this.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SharedPreferences pr = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String timer = pr.getString("timer", "15");
    long t = (long)Integer.parseInt(timer);
    new Handler().postDelayed(new Runnable() {
        public void run() {
            Intent intent = new Intent("com.example.Menu");
            startActivity(intent);
        }
    }, t);
}

When I am giving timeout dynamically using variable't', it is directly going to second activity without any wait.I am getting values properly from preference that I have checked. Giving hardcoded timeout value works perfectly fine. What could be the issue it is not working with dynamic timeout value?

0 Answers0