i wanted to start an activity and be able to have an animation with it. So after the animation, the intent should start but when i run the program, the animation wont animate, it will just show the 1st frame and then waits for a couple of seconds and goes to the 2nd activity, is there a way i can finish the animation first and go to another activity? this is my code:
public void onTextChanged(CharSequence sa, int start,
int before, int count) {
if (sa.length() == 4) {
final Intent Menu = new Intent(LogIn.this, Menu.class);
progressDialog = ProgressDialog.show(LogIn.this, "", "Loading..");
password = getPass("password", getApplicationContext());
Runnable runnable = new Runnable() {
@Override
public void run() {
if ((password.equals(""))) {
if (s.toString().equals("1234")) {
findBT();
try {
openBT();
}
catch (IOException e) {}
beginListenForData();
handler.post(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
connectedAnim();
LogIn.this.startActivity(Menu);
}
});
/*Intent Menu = new Intent(LogIn.this, Menu.class);
LogIn.this.startActivity(Menu);*/
} else {
Toast.makeText(LogIn.this, "Incorrect Password", Toast.LENGTH_SHORT).show();
}
} else {
realpass = getPass("password", getApplicationContext());
if (s.toString().equals(realpass)) {
findBT();
} else {
Toast.makeText(LogIn.this, "Incorrect Password", Toast.LENGTH_SHORT).show();
}
}
}
};
new Thread(runnable).start();
}
}
});
connectedAnim()
public void connectedAnim(){
final Dialog dialog = new Dialog(LogIn.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.connected);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
IVcon = (ImageView)dialog.findViewById(R.id.IVcon);
IVcon.setBackgroundResource(R.anim.connectedanim);
final AnimationDrawable animcon = (AnimationDrawable)IVcon.getBackground();
dialog.setCancelable(true);
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
animcon.start();
}
});
dialog.show();
new Handler().postDelayed(new Runnable() {
public void run() {
dialog.dismiss();
/*Intent Menu = new Intent(LogIn.this, Menu.class);
Menu.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
LogIn.this.startActivity(Menu);*/
}
}, 1000);
}