my application always crash whenever it reach Toast(parent) part. i tried emptying the entire run() and there were no problem.
this codes work fine in emulator but not on device.
please ignore the Toast if you would like to, my main problem is not the Toast but its the codes onwards. they crash on device.
im merely using the Toast to know where the application crashed.
public class LoadingActivity extends Activity {
/** Duration of wait **/
private final int SPLASH_DISPLAY_LENGTH = 2000;
Intent intent;
LoadingActivity parent;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_loading);
intent = getIntent();
parent = this;
ImageView logo = (ImageView) findViewById(R.id.imageView);
TextView splash = (TextView) findViewById(R.id.splash);
splash.setText(intent.getStringExtra(Constant.SPLASH_TEXT));
TranslateAnimation animator = new TranslateAnimation(logo.getX(), logo.getX(), logo.getY(), logo.getY() + 300);
animator.setDuration(2000);
animator.setFillAfter(true);
logo.startAnimation(animator);
/* New Handler to start the Menu-Activity
* and close this Splash-Screen after some seconds.*/
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
//error on here
Toast.makeText(parent, "im still fine", Toast.LENGTH_LONG).show();
/* Create an Intent that will start the Menu-Activity. */
Intent nextIntent = new Intent(parent, HomeActivity.class);
nextIntent.putExtra(Constant.LOGIN_USERNAME, intent.getStringExtra(Constant.LOGIN_USERNAME));
parent.startActivity(nextIntent);
Toast.makeText(parent, "passed", Toast.LENGTH_LONG).show();
LoadingActivity.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
}