From b3e4bab48df4c835fafa50959f9d6cace1598ec7 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 31 Jul 2013 16:38:48 -0700 Subject: [PATCH] Add new Intent demos. Change-Id: Iad47cca8c3fc5ccd184e07e95c9c13877f1d4ff0 --- samples/ApiDemos/res/layout/intents.xml | 18 ++++++++++-- samples/ApiDemos/res/values/strings.xml | 2 ++ .../com/example/android/apis/app/Intents.java | 28 +++++++++++-------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/samples/ApiDemos/res/layout/intents.xml b/samples/ApiDemos/res/layout/intents.xml index aed709d76..e301b0bdf 100644 --- a/samples/ApiDemos/res/layout/intents.xml +++ b/samples/ApiDemos/res/layout/intents.xml @@ -17,7 +17,8 @@ - @@ -29,9 +30,22 @@ + + + + diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml index 897d67a89..8fd182a7f 100644 --- a/samples/ApiDemos/res/values/strings.xml +++ b/samples/ApiDemos/res/values/strings.xml @@ -467,6 +467,8 @@ App/Activity/Intents Example of launching various Intents. Get Music + Get Image + Get Stream diff --git a/samples/ApiDemos/src/com/example/android/apis/app/Intents.java b/samples/ApiDemos/src/com/example/android/apis/app/Intents.java index 8f02b8322..6207dd805 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/Intents.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/Intents.java @@ -31,17 +31,23 @@ public class Intents extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.intents); - - // Watch for button clicks. - Button button = (Button)findViewById(R.id.get_music); - button.setOnClickListener(mGetMusicListener); } - private OnClickListener mGetMusicListener = new OnClickListener() { - public void onClick(View v) { - Intent intent = new Intent(Intent.ACTION_GET_CONTENT); - intent.setType("audio/*"); - startActivity(Intent.createChooser(intent, "Select music")); - } - }; + public void onGetMusic(View view) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType("audio/*"); + startActivity(Intent.createChooser(intent, "Select music")); + } + + public void onGetImage(View view) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType("image/*"); + startActivity(Intent.createChooser(intent, "Select image")); + } + + public void onGetStream(View view) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType("*/*"); + startActivity(Intent.createChooser(intent, "Select stream")); + } }