//Intent的属性
Intent in1 = new Intent(); ComponentName componentName = new ComponentName(this,Activity2.class); in1.setComponent(componentName);//设置显示意图 in1.setAction(Intent.ACTION_DIAL);//用特别的字符串规定一些功能的Activity 实现隐式意图 唯一性 in1.addFlags(1);//自己规定标记 多个 in1.addCategory("");//多个 //in1.setDataAndTypeAndNormalize();Type Intent intent = new Intent(this,Activity2.class);

main_layout.xml

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="隐式意图调用"
android:textSize="30dp"
android:onClick="onclick5" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="隐式意图调用打电话"
android:textSize="30dp"
android:onClick="onclick6" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="隐式意图直接拨打电话"
android:textSize="30dp"
android:onClick="onclick7" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="回到桌面"
android:textSize="30dp"
android:onClick="onclick8" />

MainActivity.java

//隐式意图的监听
public void onclick5(View view)
{
//只有action的隐式意图
Intent intent = new Intent("hello"); startActivity(intent);
}
public void onclick6(View view)
{
//action的隐式意图
//传数据 data Uri
Uri uri = Uri.parse("tel:110"); Intent intent = new Intent(Intent.ACTION_DIAL,uri); startActivity(intent);
}
public void onclick7(View view)
{
//action的隐式意图
//传数据 data Uri
Uri uri = Uri.parse("tel:110"); Intent intent = new Intent(Intent.ACTION_CALL,uri); startActivity(intent);
}
public void onclick8(View view)
{
//action的隐式意图 //回到桌面
Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent);
}

AndroidManifext.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.chenshuai.test321"> <uses-permission android:name="android.permission.CALL_PHONE" /> <application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="测试"
android:supportsRtl="true"
android:theme="@style/AppTheme"> <activity android:name=".MainActivity"
android:launchMode="standard">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity2">
<intent-filter>
<action android:name="hello" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Activity3">
<intent-filter>
<action android:name="hello" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application> </manifest>

效果

Android——Intent(意图)的更多相关文章

  1. Android 之 Intent(意图)

    Intent是 Android中重要的桥梁之一,它分为显式意图和隐式意图.接下来分别针对这两种意图进行讲解. 显式意图:通过指定一组数据或动作,激活应用内部的 activity:(相比隐式意图,此做法 ...

  2. android intent 隐式意图和显示意图(activity跳转)

    android中的意图有显示意图和隐式意图两种, 显示意图要求必须知道被激活组件的包和class 隐式意图只需要知道跳转activity的动作和数据,就可以激活对应的组件 A 主activity  B ...

  3. Android组件--意图(Intent)

    1. 隐示调用和显示调用 参考资料:http://blog.csdn.net/harvic880925/article/details/38399723 1.概念 1). 显式意图: 能从intent ...

  4. android:Intent匹配action,category和data原则

    1.当你在androidmanifest里面定义了一个或多个action时 你使用隐式意图其他activity或者service时,规定你隐式里面的action必须匹配XML中定义的action,可以 ...

  5. Android Intent

    Intent在Android中的重要性不言而喻.本文主要总结下Intent使用过程中需要注意的一些问题. 1.隐式Intent AndroidManifest.xml声明时<intent-fil ...

  6. Android总结篇系列:Android Intent

    Intent在Android中的重要性不言而喻.本文主要总结下Intent使用过程中需要注意的一些问题. 1.隐式Intent AndroidManifest.xml声明时<intent-fil ...

  7. Android Intent (可通过URL启动 Activity)

    Intent分为两大类: (1)显性的(Explicit) (2)隐性的(Implicit) 对于隐性意图,在某些时候, 应用程序只是想启动具有某种特征的组件, 并不想和某个特定的组件耦合. 使用In ...

  8. [Android] Intent详解

    [转]http://www.cnblogs.com/engine1984/p/4146621.html [正文] Intent组件虽然不是四大组件,但却是连接四大组件的桥梁,学习好这个知识,也非常的重 ...

  9. Intent(意图)

    Intent的中文意思是“意图,目的”的意思,可以理解为不同组件之间通信的“媒介”或者“信使”. 目标组件一般要通过Intent来声明自己的条件,一般通过组件中的<intent-filter&g ...

随机推荐

  1. 神奇的container_of

    container_of是linux内核中常用的一个宏,这个宏的功能是,根据某个结构体字段的指针,找到对应的结构体指针. 话不多说,先上源码: /** * container_of - cast a ...

  2. VMWARE虚拟机安装64位系统此主机支持IntelVTx 但IntelVTx处于禁用状态

    1.进入BIOS(我的电脑是Thinkpad e480,进入按钮是F12/ Fn+F12) 2.选择App Menu,再选择第一项Setup,进入 3.选择Security,选择下面第四项Virtua ...

  3. 使用ionic中的侧边栏以及angularjs中广播的使用

    接着之前的ionic的例子 查看例子:我的第一段ionic代码 demo3.html(黄底内容为增加或修改的内容) <!DOCTYPE html> <html ng-app=&quo ...

  4. ES PS TS 流的区别

    http://fengqing888.blog.163.com/blog/static/330114162012111805717584/ ES是原始码流,包含视频.音频或数据的连续码流.TS是传输流 ...

  5. GDB高级使用方法

    1.设置环境变量 用户可以在GDB的调试环境中定义自己需要的变量,用来保存一些调试程序中的运行数据.要定义一个GDB的变量很简单,只需使用GDB的set命令. GDB的环境变量和Linux一样,也是以 ...

  6. 算法笔记_040:二进制幂(Java)

    目录 1 问题描述 2 解决方案 2.1 从左至右二进制幂 2.2 从右至左二进制幂   1 问题描述 使用n的二进制表示,计算a的n次方. 2 解决方案 2.1 从左至右二进制幂 此方法计算a的n次 ...

  7. ant design pro(一)安装、目录结构、项目加载启动【原始、以及idea开发】

    一.概述 1.1.脚手架概念 编程领域中的“脚手架(Scaffolding)”指的是能够快速搭建项目“骨架”的一类工具.例如大多数的React项目都有src,public,webpack配置文件等等, ...

  8. thinkphp 重写

    我们知道,在thinkphp的案例中有一个.htaccess文件,里面配置了URL的一些重写规则,如: <IfModule mod_rewrite.c>  RewriteEngine on ...

  9. 如何用php启动exe程序,并在进程中查看?

    function query_process($service) { /* **查看WINDOWS系统进程列表,并查找指定进程是否存在 */ $tasklist = $_SERVER["WI ...

  10. STM32出现HardFault故障的解决方法

    https://wenku.baidu.com/view/a4a7499afad6195f312ba6d2.html https://wenku.baidu.com/view/085b6fbe5022 ...