使用隐式的Intent Implicit Intents一般用于从一个app到另一个app
而显示的Intent是用于一个app内页面的跳转
需要声明指定的动作
如Uri number = Uri.parse(“tel:5551234”);
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
指定电话号码的intent
// Map point based on address
Uri location = Uri.parse(“geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+California”);
// Or map point based on latitude/longitude
// Uri location = Uri.parse(“geo:37.422219,-122.08364?z=14”); // z param is zoom level
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
查看地图
Uri webpage = Uri.parse(“http://www.android.com“);
Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage);
查看网页
没有Uri数据类型则用setType()方法来指定intent附带的数据类型,用putextra()来装在mime型数据
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// The intent does not have a URI, so declare the “text/plain” MIME type
emailIntent.setType(HTTP.PLAIN_TEXT_TYPE);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {“jon@example.com”}); // recipients
emailIntent.putExtra(Intent.EXTRA_SUBJECT, “Email subject”);
emailIntent.putExtra(Intent.EXTRA_TEXT, “Email message text”);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(“content://path/to/email/attachment”));
// You can also attach multiple items by passing an ArrayList of Uris

验证是否有App去接收这个Intent
PackageManager packageManager = getPackageManager();
List activities = packageManager.queryIntentActivities(mapIntent, 0);
boolean isIntentSafe = activities.size() > 0;

            // Start an activity if it's safe            if (isIntentSafe) {                startActivity(mapIntent);            }

更多相关文章

  1. Android(安卓)Gradle 插件版本说明 以及 gradle插件版本和gradle
  2. android学习笔记22:可展开的ListView
  3. android 指定组件的圆角图片处理
  4. Android用于提示等待的ProgressDialog
  5. Android(安卓)获取sdcard音乐文件
  6. Android(安卓)RecyclerView更新某条/一条数据
  7. Android的 EditText的inputType类型
  8. AndroidManifest.xml里加入不同package的component
  9. 安卓利用百度api定位遇到 经纬度经纬度返回4.9E-324

随机推荐

  1. Android 版权介绍
  2. Android中Handler的使用
  3. Android View相关文章精选
  4. Android各版本对照及版本差异 (版本一)
  5. USB开发------android AOA开发
  6. [笔记]2012年移动大趋势(上)
  7. Android加载Gif和ImageView的通用解决方
  8. android之switch控件的用法
  9. Hybrid App混合开发实战
  10. Android电池管理系统系统分析