//选择图片 requestCode 返回的标识
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); //"android.intent.action.GET_CONTENT"
intent.setType(contentType); //查看类型 String IMAGE_UNSPECIFIED = "image/*";
Intent wrapperIntent = Intent.createChooser(intent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
//添加音频
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = Intent.createChooser(intent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
//拍摄视频
int durationLimit = getVideoCaptureDurationLimit(); //SystemProperties.getInt("ro.media.enc.lprof.duration", 60);
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationLimit);
startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO);
//视频
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = Intent.createChooser(intent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
//录音
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(ContentType.AUDIO_AMR); //String AUDIO_AMR = "audio/amr";
intent.setClassName("com.android.soundrecorder",
"com.android.soundrecorder.SoundRecorder");
((Activity) context).startActivityForResult(intent, requestCode);
//拍照 REQUEST_CODE_TAKE_PICTURE 为返回的标识
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //"android.media.action.IMAGE_CAPTURE";
intent.putExtra(MediaStore.EXTRA_OUTPUT, Mms.ScrapSpace.CONTENT_URI); // output,Uri.parse("content://mms/scrapSpace");
startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE);
//浏览器
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setType("plain/text");
browserIntent.setData(Uri.parse("www.baidu.com"));
startActivity(browserIntent);
//下载市场
//search
Uri uri = Uri.parse("market://search?q=pname:pkg_name");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//where pkg_name is the full package path for an application
//show program detail page
Uri uri = Uri.parse("market://details?id=app_id");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
显示Web网页:
1. Uri uri = Uri.parse(”http://www.android123.com.cn”);
2. Intent it = new Intent(Intent.ACTION_VIEW,uri);
3. startActivity(it);
显示Google地图:
1. Uri uri = Uri.parse(”geo:38.899533,-77.03****76″);
2. Intent it = new Intent(Intent.Action_VIEW,uri);
3. startActivity(it);
Maps路径规划:
1. Uri uri = Uri.parse(”http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en”);
2. Intent it = new Intent(Intent.ACTION_VIEW,URI);
3. startActivity(it);
拨打电话:
1. Uri uri = Uri.parse(”tel:xxxxxx”);
2. Intent it = new Intent(Intent.ACTION_DIAL, uri);
3. startActivity(it);
1. Uri uri = Uri.parse(”tel.xxxxxx”);
2. Intent it =new Intent(Intent.ACTION_CALL,uri);
注意需要权限
发送SMS/MMS
1. Intent it = new Intent(Intent.ACTION_VIEW);
2. it.putExtra(”sms_body”, “android开发网欢迎您”);
3. it.setType(”vnd.android-dir/mms-sms”);
4. startActivity(it);
发送短信
1. Uri uri = Uri.parse(”smsto:10086″);
2. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
3. it.putExtra(”sms_body”, “10086″); //正文为10086
4. startActivity(it);
发送彩信
1. Uri uri = Uri.parse(”content://media/external/images/media/10″); //该Uri根据实际情况修改,external代表外部存储即sdcard
2. Intent it = new Intent(Intent.ACTION_SEND);
3. it.putExtra(”sms_body”, “android123.com.cn”);
4. it.putExtra(Intent.EXTRA_STREAM, uri);
5. it.setType(”image/png”);
6. startActivity(it);
发送Email
2. Uri uri = Uri.parse(”mailto:android123@163.com”);
3. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
4. startActivity(it);
1. Intent it = new Intent(Intent.ACTION_SEND);
2. it.putExtra(Intent.EXTRA_EMAIL, “android123@163.com”);
3. it.putExtra(Intent.EXTRA_TEXT, “android开发网测试”);
4. it.setType(”text/plain”);
5. startActivity(Intent.createChooser(it, “选择一个Email客户端”));
1. Intent it=new Intent(Intent.ACTION_SEND);
2. String[] tos={”android123@163.com”}; //发送到
3. String[] ccs={”ophone123@163.com”}; //抄送
4. it.putExtra(Intent.EXTRA_EMAIL, tos);
5. it.putExtra(Intent.EXTRA_CC, ccs);
6. it.putExtra(Intent.EXTRA_TEXT, “正文”);
7. it.putExtra(Intent.EXTRA_SUBJECT, “标题”);
8. it.setType(”message/rfc822″); //编码类型
9. startActivity(Intent.createChooser(it, “选择一个Email客户端”));
Email添加附件
1. Intent it = new Intent(Intent.ACTION_SEND);
2. it.putExtra(Intent.EXTRA_SUBJECT, “正文”);
3. it.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/nobody.mp3″); //附件为sd卡上的nobody MP3文件
4. sendIntent.setType(”audio/mp3″);
5. startActivity(Intent.createChooser(it, “选择一个Email客户端”));
播放多媒体
1.
2. Intent it = new Intent(Intent.ACTION_VIEW);
3. Uri uri = Uri.parse(”file:///sdcard/nobody.mp3″);
4. it.setDataAndType(uri, “audio/mp3″);
5. startActivity(it);
1. Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, “1″); //从系统内部的MediaProvider索引中调用播放
2. Intent it = new Intent(Intent.ACTION_VIEW, uri);
3. startActivity(it);
Uninstall卸载程序
1. Uri uri = Uri.fromParts(”package”, packageName, null); //packageName为包名,比如com.android123.apkInstaller
2. Intent it = new Intent(Intent.ACTION_DELETE, uri);
3. startActivity(it);
分享到:
相关推荐
android 利用intent调用activity 简明精炼的例子 传递数据,并且有返回值
本文实例讲述了Android中简单调用图片、视频、音频、录音和拍照的方法。分享给大家供大家参考,具体如下: //选择图片 requestCode 返回的标识 Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT); //...
Android中的 Intent 详细讲解Android中的 Intent 详细讲解Android中的 Intent 详细讲解
添加本地图片和调用系统拍照图片主要是通过调用acitivity跳转startActivityForResult Intent intent int requestCode 方法和activity返回结果onActivityResult int requestCode int resultCode Intent data 方法来...
主要介绍了Android 通过Intent调用系统拍照程序出现图片太小的问题解决办法的相关资料,需要的朋友可以参考下
我们可以通过Intent类中的putExtra方法可以将简单的数据类型和序列化对象保存到Intent对象中,然后在目标的Activity中使用getXxx方法取出对应的数据。
应开发需要,不想调用第三方库实现功能。调用系统相机拍照,系统相册进行多选。注意多选照片时要长按一张图片变为多选。
Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面.
Android应用核心Intent
android Intent例子源码android Intent例子源码android Intent例子源码android Intent例子源码android Intent例子源码android Intent例子源码
Intent是Android中用来调用其它组件的类,通过Intent,我们可以非常方便的调用Activity,Broadcast Receiver和Service。 Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse...
通过一个实验,讲解Android的使用方法,总结详细
android开发中Intent在两个Activity间传值示例
Android 用Intent调用系统中经常被用到的组件 android用于打开各种文件的intent
android activityIntent 传值 传对象
主要为大家详细介绍了Android利用Intent启动和关闭Activity的相关操作,感兴趣的小伙伴们可以参考一下
android调用系统邮件组件 Intent匹配流程 csdn博客地址
源程序关于android平台中intent的使用小示例,仅供参考
Android源码——Intent切换.zip
Android 广播大全 Intent Action 事件.