开发者

Question about Intent, android

I am confused, and need to get my concepts straight.

After executing the last statement, which function is called,开发者_如何学Python in MapsActivity? is it onResume? and under which function (onResume()?) should i put getExtra()?

Log.i("onMenuAnimate", "Attempting to animate to:");
Intent intent = new Intent(SearchDB.this, MapsActivity.class);
intent.putExtra("com.gpsdroid.SearchDB.Lat", nameLatitude.getText());
intent.putExtra("com.gpsdroid.SearchDB.Long", nameLatitude.getText());
SearchDB.this.startActivity(intent);


Take some time to read up on Activity Life cycle; trust me it will help you a lot.

Under the given circumstances, when you call startActivity(..), MapsActivity will be first started by the Activity Manager. In an activity's life cycle, onCreate(..) is called whenever an activity is first created. So this could be one of the places that you can call getExtra().

AFAICT, you can call getIntent.getXXXExtra() in any of the Life Cycle Methods. The answer regarding which of the life cycle methods to choose depends on what is being passed and where/when the information is to be used.


after this statement the next activity which is going to be called.then whenever the back button is pressed the a\first activity will be resumed. the code you want to execute you should put it in overrided method onResume.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜