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 ...
随机推荐
- SVN-如何删除 SVN 文件夹下面的小图标
第一步:右键新建文本文件. 第二步:打开 并复制一下文件 到 新建文本文件. @echo on color 2f mode con: cols=80 lines=25 @REM ...
- 开发自己的One Page Scroll插件(二)
开发自己的One Page Scroll插件(一) 5. 在其他浏览器中的特性 我经常会不停地发布当前的版本,从而可以在GitHub上得到不断的反馈.我的开发模式是不断的迭代.在开始的时候,我不会太关 ...
- URL转发
原理:iframe 代码: <?php if($_SERVER['HTTP_HOST']=="i.mansions.com.cn"){ $html = <<< ...
- [CALayer release]: message sent to deallocated instance iOS内存过度释放问题
[CALayer release]: message sent to deallocated instance iOS内存过度释放问题 解决方式: 1:先找到过度释放的 内存指针 开启-僵尸模式:xc ...
- ubuntu 下安装 VIM 依赖vim-common错误
ubuntu 下安装 VIM 依赖vim-common错误 sudo apt-get remove vim-common 先把上面的错误依赖删除 sudo apt-get install vim ...
- Linux下统计当前文件夹下的文件个数、目录个数(转)
1) 统计当前文件夹下文件的个数 代码如下: ls -l |grep "^-"|wc -l 2) 统计当前文件夹下目录的个数 代码如下: ls -l |grep "^d& ...
- iOS中使用iCloud一些须要注意的地方(Xcode7.2)
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 假设认为写的不好请多提意见,假设认为不错请多多支持点赞.谢谢! hopy ;) 在自己的App中怎样使用iCloud有非常多文章能够查阅,这里 ...
- linux sort 、uniq 命令
以文件的每行为单位,从左往右依次按ascii码进行比较 sort sort.txt #默认为升序 -u:去除重复行 sort -u sort.txt -r:降序排列 sort -r sort.txt ...
- [精]Oracle APEX 5.0 入门教程(一) Form表单
Oracle APEX Tutorial for Beginners (APEX 5.0) 1- Introduction 2- Create Workspace 3- Work with Works ...
- 【JS】jQuery中将数组转换成字符串join()和push()使用
1.push()将元素依次添加至数组:2.join()将数组转换成字符串,里面可以带参数分隔符,默认[,] <script type = text/javascript> $(docume ...