Android APP代码拨打电话、打开手机分享功能等隐式意图
2015-06-03 16:42
726 查看
Android APP拨打电话:
Intent intent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+110));
startActivity(intent);
}
Android APP打开电话薄:
Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(intent, 2);
Android APP打开相机:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path)));
startActivityForResult(intent, 2);
Android APP打开相册:
Intent intent = new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(intent, 2);
Android APP短信分享:
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "#短信分享#");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
打开手机的分享功能:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
// sendIntent.setType("image/png");//图片
// File f = new File(Environment.getExternalStorageDirectory() + "/Pictures/2.png");
// Uri u = Uri.fromFile(f);
// sendIntent.putExtra(Intent.EXTRA_STREAM, u);
sendIntent.setType("text/plain");//文字
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "#好友分享#");
// 自动添加的发送的具体信息
sendIntent.putExtra(Intent.EXTRA_TEXT, "我现在正在玩应用,一起加入吧!更多资讯详见:http://www.xx.com");
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(sendIntent, getTitle()));
打开应用商店进行评价:
Uri uri=Uri.parse("market://details?id=" + Activity.this.getPackageName());
Intent intent=new Intent(Intent.ACTION_VIEW, uri);
PackageManager pm = this.getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
if(list.size()==0){
Toast.makeText(this, "还未安装软件商店", Toast.LENGTH_SHORT).show();
}else{
startActivity(intent);
}
创建桌面快捷图标:
MIME TYPE对照表:http://tool.oschina.net/commons http://blog.sina.com.cn/s/blog_446cc66b0100ublv.html
Intent intent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+110));
startActivity(intent);
}
Android APP打开电话薄:
Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(intent, 2);
Android APP打开相机:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path)));
startActivityForResult(intent, 2);
Android APP打开相册:
Intent intent = new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(intent, 2);
Android APP短信分享:
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "#短信分享#");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
打开手机的分享功能:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
// sendIntent.setType("image/png");//图片
// File f = new File(Environment.getExternalStorageDirectory() + "/Pictures/2.png");
// Uri u = Uri.fromFile(f);
// sendIntent.putExtra(Intent.EXTRA_STREAM, u);
sendIntent.setType("text/plain");//文字
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "#好友分享#");
// 自动添加的发送的具体信息
sendIntent.putExtra(Intent.EXTRA_TEXT, "我现在正在玩应用,一起加入吧!更多资讯详见:http://www.xx.com");
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(sendIntent, getTitle()));
打开应用商店进行评价:
Uri uri=Uri.parse("market://details?id=" + Activity.this.getPackageName());
Intent intent=new Intent(Intent.ACTION_VIEW, uri);
PackageManager pm = this.getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
if(list.size()==0){
Toast.makeText(this, "还未安装软件商店", Toast.LENGTH_SHORT).show();
}else{
startActivity(intent);
}
创建桌面快捷图标:
//发送广播的意图,要创建快捷图标了 Intent intent = new Intent(); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); //快捷方式 要包含3个重要的信息 1,名称 2.图标 3.干什么事情 intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "仔仔手机安全卫士"); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)); //桌面点击图标对应的意图。 Intent shortcutIntent = new Intent(); shortcutIntent.setAction("android.intent.action.MAIN"); shortcutIntent.addCategory("android.intent.category.LAUNCHER"); shortcutIntent.setClassName(getPackageName(), "com.zaizai.safty.MainActivity"); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); sendBroadcast(intent);
需添加权限
com.android.launcher.permission.INSTALL_SHORTCUT
MIME TYPE对照表:http://tool.oschina.net/commons http://blog.sina.com.cn/s/blog_446cc66b0100ublv.html
相关文章推荐
- Android Studio Note
- Android android:gravity与 android:layout_gravity的区别
- android 多个Icon启动多个入口Activity
- android AsyncTask介绍
- android 高德地图出现【定位失败key鉴权失败】
- Android传感器的运用之ACCELEROMETER
- 3.Android-传感器开发-处理各种传感器配置
- 浏览器网页判断手机是否安装IOS/Android客户端程序
- Android-自定义AttributeSet属性
- 关于Android软键盘弹出,会把原来的界面挤上去的问题
- 【Android个人理解(八)】跨应用调用不同组件的方法
- 【Android笔记】EditText密码框中字体和普通输入框不同
- Android DrawerLayout 抽屉
- Android PopupWindows
- Android中自定义checkbox样式
- Android fill_parent、wrap_content和match_parent的区别
- 兼容 Android 4.4 透明状态栏与导航栏
- Android自定义组合标题控件
- Android——SlidingMenu学习总结
- Android ViewPager+Fragment 仿 Google Play 带箭头的导航栏