Android——Intent(意图)

//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(意图)的更多相关文章
- Android 之 Intent(意图)
Intent是 Android中重要的桥梁之一,它分为显式意图和隐式意图.接下来分别针对这两种意图进行讲解. 显式意图:通过指定一组数据或动作,激活应用内部的 activity:(相比隐式意图,此做法 ...
- android intent 隐式意图和显示意图(activity跳转)
android中的意图有显示意图和隐式意图两种, 显示意图要求必须知道被激活组件的包和class 隐式意图只需要知道跳转activity的动作和数据,就可以激活对应的组件 A 主activity B ...
- Android组件--意图(Intent)
1. 隐示调用和显示调用 参考资料:http://blog.csdn.net/harvic880925/article/details/38399723 1.概念 1). 显式意图: 能从intent ...
- android:Intent匹配action,category和data原则
1.当你在androidmanifest里面定义了一个或多个action时 你使用隐式意图其他activity或者service时,规定你隐式里面的action必须匹配XML中定义的action,可以 ...
- Android Intent
Intent在Android中的重要性不言而喻.本文主要总结下Intent使用过程中需要注意的一些问题. 1.隐式Intent AndroidManifest.xml声明时<intent-fil ...
- Android总结篇系列:Android Intent
Intent在Android中的重要性不言而喻.本文主要总结下Intent使用过程中需要注意的一些问题. 1.隐式Intent AndroidManifest.xml声明时<intent-fil ...
- Android Intent (可通过URL启动 Activity)
Intent分为两大类: (1)显性的(Explicit) (2)隐性的(Implicit) 对于隐性意图,在某些时候, 应用程序只是想启动具有某种特征的组件, 并不想和某个特定的组件耦合. 使用In ...
- [Android] Intent详解
[转]http://www.cnblogs.com/engine1984/p/4146621.html [正文] Intent组件虽然不是四大组件,但却是连接四大组件的桥梁,学习好这个知识,也非常的重 ...
- Intent(意图)
Intent的中文意思是“意图,目的”的意思,可以理解为不同组件之间通信的“媒介”或者“信使”. 目标组件一般要通过Intent来声明自己的条件,一般通过组件中的<intent-filter&g ...
随机推荐
- 微软小冰你这么智能 .net知道吗?
- (C++)C++多态性中的静态绑定和动态绑定
静态绑定和动态绑定是C++多态性的一种特性. 1.对象的静态类型和动态类型: 对象的静态类型: 对象在声明是采用的类型,在编译期确定: 对象的动态类型: 当前对象所指的类型,在运行期决定,对象的动态类 ...
- onvif获取摄像头的流媒体地址完整流程
linux设备上的Onvif 实现6:获取摄像头的流媒体地址完整流程 整体流程: Probe: 发现网络摄像头,获取webserver地址 http://192.168.15.240/onvif/de ...
- win7 配置IIS + php 环境
一:开启win7 的IIS功能:并开启 CGI 二:下载php5 for windows 解压 三:打开IIS --->>处理程序映射- 参考:http://php.net/manual/ ...
- 格式化文本数据抽取工具awk
在管理和维护Linux系统过程中,有时可能需要从一个具有一定格式的文本(格式化文本)中抽取数据,这时可以使用awk编辑器来完成这项任务.发明这个工具的作者是Aho.Weinberg和Kernighan ...
- Spring整合JDBC实现简单的增删改
Spring整合JDBC实现简单的增删改: 1.导入Spring的包和数据库的驱动包: 2.选择一个数据源(dbcp和C3P0) 3.导入数据源的包(这里我们使用dbcp) <span styl ...
- windows 磁盘加密
windows 磁盘加密 CreateTime--2018年4月25日18:37:45 Author:Marydon 以win10为例 选中磁盘-->你会发现上面的管理BitLocker是置 ...
- JVM是怎么工作的?
了解JVM的工作机制能够更好的帮助我们理解java语言本身,规避各种可能的错误.所以,今天趁此机会好好复习一下.来看看JVM是怎么工作的. 一.啥是JVM JVM可以理解为用来运行java程序的一种运 ...
- iOS_数据库2_基础知识
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcHJlX2VtaW5lbnQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...
- Android访问php webservice
如果是PHP做的服务端,而我们要用android去访问,怎么办?当然可以用REST,但也可以用点笨的方法,比如可以让PHP的服务端返回JSON或XML数据,而Android端则可以用APACHE的ht ...