Button videoButton;
Button imageButton;
videoButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent mIntent = new
Intent(Intent.ACTION_VIEW);//用户可选择已安装的视频播放器
mIntent.setDataAndType(Uri.parse("/sdcard/test.mp4"),"video/mp4");
startActivity(mIntent);
}
});
imageButton.setOnClickListener(new OnClickListener() {
private File tempFile;
public void onClick(View v) {
this.tempFile = new File("/sdcard/a.jpg");//用户可选择已安装的图片浏览器
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("output", Uri.fromFile(tempFile));
intent.putExtra("outputFormat", "JPEG");
startActivity(intent);
}
});