diff options
Diffstat (limited to 'Android/02-Intents/IntentsLab/src/course/labs/intentslab/ActivityLoaderActivity.java')
-rw-r--r-- | Android/02-Intents/IntentsLab/src/course/labs/intentslab/ActivityLoaderActivity.java | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/Android/02-Intents/IntentsLab/src/course/labs/intentslab/ActivityLoaderActivity.java b/Android/02-Intents/IntentsLab/src/course/labs/intentslab/ActivityLoaderActivity.java index 407b371..abd912a 100644 --- a/Android/02-Intents/IntentsLab/src/course/labs/intentslab/ActivityLoaderActivity.java +++ b/Android/02-Intents/IntentsLab/src/course/labs/intentslab/ActivityLoaderActivity.java @@ -56,30 +56,29 @@ public class ActivityLoaderActivity extends Activity { // Start the ExplicitlyLoadedActivity private void startExplicitActivation() { Log.i(TAG,"Entered startExplicitActivation()"); - // TODO - Create a new intent to launch the ExplicitlyLoadedActivity class - // TODO - Start an Activity using that intent and the request code defined above + Intent intent = new Intent(ActivityLoaderActivity.this, ExplicitlyLoadedActivity.class); + startActivityForResult(intent, GET_TEXT_REQUEST_CODE); } // Start a Browser Activity to view a web page or its URL private void startImplicitActivation() { Log.i(TAG, "Entered startImplicitActivation()"); - // TODO - Create a base intent for viewing a URL - // (HINT: second parameter uses parse() from the Uri class) - // TODO - Create a chooser intent, for choosing which Activity - // will carry out the baseIntent. Store the Intent in the - // chooserIntent variable below. HINT: using the Intent class' - // createChooser()) - Intent chooserIntent = null; + Uri webpage = Uri.parse("http://asynk.ch"); + Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage); + Intent chooserIntent = Intent.createChooser(webIntent, "Choose damn it!"); Log.i(TAG,"Chooser Intent Action:" + chooserIntent.getAction()); - // TODO - Start the chooser Activity, using the chooser intent - startActivity(chooserIntent); + if (chooserIntent.resolveActivity(getPackageManager()) != null) { + startActivity(chooserIntent); + } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i(TAG, "Entered onActivityResult()"); - // TODO - Process the result only if this method received both a - // RESULT_OK result code and a recognized request code - // If so, update the Textview showing the user-entered text. + if (requestCode == GET_TEXT_REQUEST_CODE) { + if (resultCode == RESULT_OK) { + mUserTextView.setText(data.getStringExtra("data")); + } + } } } |