Add new Intent demos.
Change-Id: Iad47cca8c3fc5ccd184e07e95c9c13877f1d4ff0
This commit is contained in:
@@ -17,7 +17,8 @@
|
|||||||
<!-- Demonstrates launching various intents.
|
<!-- Demonstrates launching various intents.
|
||||||
See corresponding Java code com.example.android.apis.app.Intents.java. -->
|
See corresponding Java code com.example.android.apis.app.Intents.java. -->
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical" android:padding="4dip"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||||
|
|
||||||
@@ -29,9 +30,22 @@
|
|||||||
|
|
||||||
<Button android:id="@+id/get_music"
|
<Button android:id="@+id/get_music"
|
||||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
android:text="@string/get_music">
|
android:text="@string/get_music"
|
||||||
|
android:onClick="onGetMusic">
|
||||||
<requestFocus />
|
<requestFocus />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<Button android:id="@+id/get_image"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
|
android:text="@string/get_image"
|
||||||
|
android:onClick="onGetImage">
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button android:id="@+id/get_stream"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
|
android:text="@string/get_stream"
|
||||||
|
android:onClick="onGetStream">
|
||||||
|
</Button>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -467,6 +467,8 @@
|
|||||||
<string name="activity_intents">App/Activity/Intents</string>
|
<string name="activity_intents">App/Activity/Intents</string>
|
||||||
<string name="intents">Example of launching various Intents.</string>
|
<string name="intents">Example of launching various Intents.</string>
|
||||||
<string name="get_music">Get Music</string>
|
<string name="get_music">Get Music</string>
|
||||||
|
<string name="get_image">Get Image</string>
|
||||||
|
<string name="get_stream">Get Stream</string>
|
||||||
|
|
||||||
<!-- ============================== -->
|
<!-- ============================== -->
|
||||||
<!-- app/intents activity flags examples strings -->
|
<!-- app/intents activity flags examples strings -->
|
||||||
|
|||||||
@@ -31,17 +31,23 @@ public class Intents extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.intents);
|
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 onGetMusic(View view) {
|
||||||
public void onClick(View v) {
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
intent.setType("audio/*");
|
||||||
intent.setType("audio/*");
|
startActivity(Intent.createChooser(intent, "Select music"));
|
||||||
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user