1
What I must do ?
intro.java
public class intro extends AppCompatActivity {
protected static final int TIMER_RUNTIME =5000;
protected boolean mbActive;
protected ProgressBar mProgressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.intro);
mProgressBar = (ProgressBar) findViewById(R.id.barrinha);
final Thread timerThread = new Thread() {
@Override
public void run() {
mbActive = true;
try {
int waited = 0;
while (mbActive && (waited < TIMER_RUNTIME)) {
sleep(5);
if (mbActive) {
waited += 5;
updateProgress(waited);
}
}
} catch (InterruptedException e) {
//Caso erro!!f
} finally {
onContinue();
}
}
};
timerThread.start();
}
public void updateProgress(final int timePassed) {
if (null != mProgressBar) {
final int progress = mProgressBar.getMax() * timePassed / TIMER_RUNTIME;
mProgressBar.setProgress(progress);
}
}
public void onContinue() {
Log.d("messagemFinal", "Sua barra de loanding acabou de Carregar!");
TimerTask task=new TimerTask() {
@Override
public void run() {
Intent mainIntent=new Intent().setClass(intro.this,main.class);
startActivity(mainIntent);
finish();
}
};
Timer timer=new Timer();
}
}
In what part does it give error ? its Log. d is called ?
– Lucas Queiroz Ribeiro
I may be mistaken, but perhaps the problem is that your Intent is called in a different Thread, I believe that the Intent should be called in the main thread
– Lucas Queiroz Ribeiro
No error just don’t jump to next screen after you load
– Jhonny Nery
I don’t know exactly why another Task is used to start the other Task Force, try to do this without putting it in another thread
– Lucas Queiroz Ribeiro