请教,如何从onPause到onResumeDOC上有一个ACTIVITY的生命周期的图,,其中有从onPause到onResume
的状态改变,,如何才可以从onPause下一步直接触发onResume事件呢???请给代码:,帮忙啊,

解决方案 »

  1.   

    那你需要看activity的源码了。是系统触发的事件,将activity置回top
      

  2.   

    package test.run;import android.app.Activity;
    import android.app.AlertDialog;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;public class Index extends Activity { private static final String TAG = "IndexActivity"; @Override
    protected void onStart() {
    super.onStart();
    Log.v(TAG, "protected void onStart()");
    } @Override
    protected void onPause() {
    super.onPause();
    Log.v(TAG, "protected void onPause()");
    } @Override
    protected void onResume() {
    super.onResume();
    Log.v(TAG, "protected void onResume()");
    } @Override
    protected void onStop() {
    super.onStop();
    Log.v(TAG, "protected void onStop()");
    } @Override
    protected void onDestroy() {
    super.onDestroy();
    Log.v(TAG, "protected void onDestroy()");
    } @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.v(TAG, "public void onCreate"); Button button1 = (Button) this.findViewById(R.id.button1);
    button1.setOnClickListener(new OnClickListener() {
    public void onClick(View arg0) {
    new AlertDialog.Builder(Index.this).setTitle("标题").setMessage(
    "简单消息框").setPositiveButton("确定", null).show();
    }
    }); }
    }不触发onPause事件啊,怎么办,点击按钮也不行,
      

  3.   

    按home键 不只是调用onpause 还会调用onstop 所以没法直接跳到onresume直接从onpause到onresume的情况比如 弹出一个对话框, 但此时主activity还是可见的,只调用onpause 从对话框返回后 再调用onresume
      

  4.   

    TO jxnktjlfr1
    上面的代码就是弹出对话框,但还是不执行onPause事件,,
      

  5.   

    启动你的界面后,按back就会进onPause了
      

  6.   

    dinjay  按BACK不光ONPAUSE了,还ONSTOP了,我不想ONSTOP
      

  7.   

    我的问题也就是如何重现DOC中的ONPAUSE到ONRESUME的效果
      

  8.   

    我试了下  我弹出的对话框是activity的  就是activity 设置成android:theme="@android:style/Theme.Dialog"     这样弹出对话框后确实只调用了 onpause  
    之后再按返回键 再调用的 onresume  (注意一定要按返回键,如果你在弹出的对话框中有什么操作比如输入或单击一个button之类的话,这时还会调用onstop ,因为焦点已经转移到了对话框)
      

  9.   

    andorid开发文档上就有啊!http://blog.csdn.net/Android_Tutor/article/details/5789203  希望对你有用