android活动是什么意思,android – 活动生命周期方法:onPostResume的意义

关于

Activity的官方文件列出了7种生命周期方法.

onPostResume()没有引用为生命周期方法.

但我觉得这种方法是重要的方法.

在生命周期中,当一个活动从隐藏到显示状态可见时,

onRestart()

onStart()

onResume()

onPostResume()

已被调用顺序.

我的代码段:

package ravindra.projects.my_app_1;

import android.content.Intent;

import android.content.IntentFilter;

import android.os.PersistableBundle;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

private EditText txtUserName;

private EditText txtPassword;

Button loginButton;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Log.d("Ravi","Main OnCreate");

txtUserName=(EditText) findViewById(R.id.username);

txtPassword=(EditText) findViewById(R.id.password);

loginButton = (Button) findViewById(R.id.login);

loginButton.setOnClickListener(this);

}

@Override

public void onClick(View view) {

Log.d("Ravi", "Login processing initiated");

Intent intent = new Intent(this,LoginActivity.class);

Bundle bundle = new Bundle();

bundle.putString("userName",txtUserName.getText().toString());

bundle.putString("password",txtPassword.getText().toString());

intent.putExtras(bundle);

startActivityForResult(intent,1);

// IntentFilter

}

public void onActivityResult(int requestCode, int resultCode, Intent resIntent){

Log.d("Ravi back result:", "start");

String result = resIntent.getStringExtra("result");

Log.d("Ravi back result:", result);

TextView txtView = (TextView)findViewById(R.id.txtView);

txtView.setText(result);

}

@Override

protected void onStart() {

super.onStart();

Log.d("Ravi","Main Start");

}

@Override

protected void onRestart() {

super.onRestart();

Log.d("Ravi","Main ReStart");

}

@Override

protected void onPause() {

super.onPause();

Log.d("Ravi","Main Pause");

}

@Override

protected void onResume() {

super.onResume();

Log.d("Ravi","Main Resume");

}

@Override

protected void onStop() {

super.onStop();

Log.d("Ravi","Main Stop");

}

@Override

protected void onDestroy() {

super.onDestroy();

Log.d("Ravi","Main OnDestroy");

}

@Override

protected void onPostResume() {

super.onPostResume();

Log.d("Ravi","Main PostResume");

}

@Override

public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {

super.onSaveInstanceState(outState, outPersistentState);

}

@Override

protected void onRestoreInstanceState(Bundle savedInstanceState) {

super.onRestoreInstanceState(savedInstanceState);

}

}

通过跳过下面的方法实现onPostResume()不能达到目的?

onRestart(), onStart(), onResume()

如果我实现onPostResume(),实现这三种方法有什么好处?

onRestart(), onStart(), onResume()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值