
我的问题是登录活动无法从暂停状态恢复.当我点击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 }@OverrIDepublic voID onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.initializeInterface(); // fIElds filled here,Listener added to buttons} 编辑:根据请求在SplashScreen中创建活动
public class SplashScreen extends Activity {/** Called when the activity is first created. */@OverrIDepublic 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();} }
解决方法 找到并修复了错误.活动在清单中标记为SingleInstance.我将其更改为Singletop,现在它按预期工作.有关原因的更多文档可在此处找到:http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
@H_419_0@ 总结以上是内存溢出为你收集整理的android – 活动不会从Pause返回全部内容,希望文章能够帮你解决android – 活动不会从Pause返回所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)