Reputation: 1401
When I call startActivityForResult (or startActivity) the "onCreate" of the MainActivity is being called even before the new activity is created. It doesn't happen with other intents.
This is the code inside click handler of a button in a listview that has an adapter (inside a fragment inside a tab of SherlockActionBar):
((MainActivity)context).setVideoId(v.getTag().toString());
Intent videoIntent = YouTubeStandalonePlayer.createVideoIntent((Activity) context, "AIzaSyC1sF6kq9hHGrQvRSiU8Ks5iYfVCbdg7zA", v.getTag().toString(), 0, true, false);
((Activity)context).startActivityForResult(videoIntent, 12);
and this is the constructor of the adapter:
public ItemAdapter(Context c, int textViewResourceId) {
super(c, textViewResourceId);
this.layoutResourceId = textViewResourceId;
this.context = c;
Upvotes: 1
Views: 1385
Reputation: 463
It's happened because activity change orientation. Add this in the manifest:
<activity
android:configChanges="orientation|screenSize|keyboardHidden"
...
Upvotes: 5