我有一個應用程序與三個活動:splashscreen(默認),登錄,主。應用程序以飛濺啓動,幾秒鐘後更改爲登錄。如果登錄過程是正確的,那麼我們轉到main。活動不會從暫停返回
我的問題是登錄活動無法從暫停狀態恢復。當我點擊Home按鈕時,onPause()被正確調用,onDestroy()不被調用。然後,當試圖返回到應用程序時,它開始啓動,但從來沒有達到登錄,它只是回到主頁。 logcat不顯示任何錯誤,調試器表明應用程序仍然處於打開狀態(就像它應該)。飛濺和主屏幕上的行爲是預期的。
public class LoginActivity extends Activity {
/* UI ELEMENTS */
private OnClickListener mOnClickListener;
private EditText mPasswordField;
private EditText mUserField;
private ProgressDialog mProgressDialog;
/* LOGIC ELEMENTS */
/** handler to update interface */
private static Handler sInterfaceUpdateHandler;
public static class UpdateHandler extends Handler {
private final WeakReference<LoginActivity> mLogin;
UpdateHandler(final LoginActivity loginActivity) {
super();
mLogin = new WeakReference<LoginActivity>(loginActivity);
}
/**
* handle events from other threads in UI thread.
*
* @param message message data. Property what determines action.
*/
@Override
public void handleMessage(final Message message) {
// STUFF HERE
}
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.initializeInterface(); // fields filled here, listener added to buttons
}
編輯:活動創建在閃屏作爲每個請求
public class SplashScreen extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.splashscreen);
final Thread splashThread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while (waited < 2000) {
sleep(100);
waited += 100;
}
} catch (final InterruptedException catchException) {
LoggerFactory.consoleLogger().printStackTrace(catchException);
}
SplashScreen.this.finish();
final Intent loginIntent = new Intent(SplashScreen.this, LoginActivity.class);
SplashScreen.this.startActivity(loginIntent);
}
};
splashThread.start();
}
}
我認爲你需要調用startActicity呼籲LoginScreen –
您的代碼是不相關的,以你描述的問題之前完成()。你的飛濺如何加載登錄活動? – Lieuwe
final Intent loginIntent = new Intent(SplashScreen.this,LoginActivity.class); SplashScreen.this.startActivity(loginIntent); –