Access intent after starting new activity android
I am having an issue with something and I don't really know where to look or how to search for this, so I am asking here. Basically, I am starting a new activity from my main activity using this bit of code:
Intent intent = new Intent(v.getContext(), AlarmViewer.class);
startActivity(intent);
And start my AlarmViewer
class with a normal onCreate
, that looks like this:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
}
So, I am trying trying to figure out how to access the intent I used to start the activity to get some extras that I put on it. Anyone have any idea how I can do that? If this has been ask开发者_StackOverflow中文版ed before I'm sorry, wasn't really sure how to search for this.
To get the intent, use getIntent().
To get your information, you use getIntent().getExtras()
which returns an object of type Bundle. From that object, you can call the different get*
methods depending on the type you have passed it from the calling activity
You can have a look at this thread for an example
精彩评论