Add new Intent demos.

Change-Id: Iad47cca8c3fc5ccd184e07e95c9c13877f1d4ff0
This commit is contained in:
Dianne Hackborn
2013-07-31 16:38:48 -07:00
parent 16616daef7
commit b3e4bab48d
3 changed files with 35 additions and 13 deletions

View File

@@ -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"));
}
}