Created
March 21, 2017 18:28
-
-
Save kmerrell42/5b0cac77dca89bb688d1e94c909c1105 to your computer and use it in GitHub Desktop.
Android createIntent() example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MovieDetailActivity extends AppCompatActivity { | |
private static final String EXTRA_MOVIE_ID = "extra:movieId"; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_movie_detail); | |
String movieId = savedInstanceState.getString(EXTRA_MOVIE_ID); | |
displayMovieDetail(movieId); | |
} | |
private void displayMovieDetail(String id) { | |
... | |
} | |
public static Intent createIntent(Context context, String id) { | |
Intent intent = new Intent(context, MovieDetailActivity.class); | |
intent.putExtra(EXTRA_MOVIE_ID, id); | |
return intent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment