I'm having problem in trying to call another class called HomeActivity because I need add message "Please wait" in class MainActivity.
Here's my Main Activity, how to insert wait message?
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class MainActivity extends Activity {
private boolean mIsBackButtonPressed;
private static final int SPLASH_DURATION = 5000;
private Handler myhandler;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
myhandler = new Handler();
myhandler.postDelayed(new Runnable() {
@Override
public void run() {
finish();
if (!mIsBackButtonPressed) {
Intent intent = new Intent(MainActivity.this,
HomeActivity.class);
MainActivity.this.startActivity(intent);
}
}
}, SPLASH_DURATION);
}
@Override
public void onBackPressed() {
mIsBackButtonPressed = true;
super.onBackPressed();
}
}
Not sure what you are trying to achieve here but here goes.
You can use a progress bar to show the user that something is loading see the following:
http://developer.android.com/reference/android/widget/ProgressBar.html
You can indeterminate mode for when you can't produce indication of progress but if you can its best to show some progress as this follows the android design guidelines for responsiveness.
Its worth noting that a splash screen (which is what I think you are trying to achieve here) is only worth doing if you actually have something to load before use.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.