android 调用系统的视频播放器和调用系统的图片浏览器

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

猜你喜欢

转载自haiyang08101.iteye.com/blog/1612504