Could you tell me how to show the screensaver using a timer in android.I can show using the stream, But the stream is a good choice, can you please tell me the best way to handle this? Stream usage like this
package com.example.splash_test;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
public class MainActivity extends Activity {
protected int _splashTime = 5000;
private Thread splashTread;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
splashTread = new Thread() {
@Override
public void run() {
try {
synchronized(this){
wait(_splashTime);
}
} catch(InterruptedException e) {}
finally {
finish();
Intent i = new Intent();
i.setClass(MainActivity.this, SecondActivity.class);
startActivity(i);
}
}
};
splashTread.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
user1542984
source
share