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 ...
随机推荐
- linux shell的执行方式
./ ping.sh 这个意思 ,'./'的意思是在当前目录执行, ping.sh----------------------------------------------------------- ...
- 美团的android多渠道包的3种方法
转: http://tech.meituan.com/mt-apk-packaging.html 美团Android自动化之旅—生成渠道包 zhihu2014-06-13 10:06 概述 每当发新版 ...
- [Firebase] 3. Firebase Simple Login Form
Using $firebaseSimpleLogin service. Here we use three methods for login, logout, register and getCur ...
- Java取出String字符串括号中的内容
形如: String idStr="dfda(2018)41324"; private int getId(String gSQL){ String quStr=gSQL.subs ...
- Log4j配置文件例子
Log4j配置文件例子: # Define somedefault values that can be overridden by system properties hbase.root.logg ...
- TP框架ajax U方法不解析怎么办?
TP框架中ajax U方法不解析 ajax U方法不解析 ajax url不解析 问题: 造成问题原因: Js 存在单独的 js文件中和html分离了.造成不解析! 解决方法: 方法一:将js放到ht ...
- [Exception JavaWeb 1] - javax.el.PropertyNotFoundException: Property 'id' not found on ..........
好久不写Web应用了,今天碰到这个问题的时候,还一时半会没反应过来.实体类在jsp无法找对应的值. 最后发现是实体bean的属性的开头字母不能与次字母不能大写+小写或小写+大写,最后改成小写+小写就好 ...
- jquery获取json对象中的key小技巧,遍历json串所有key,value
比如有一个json var json = {"name" : "Tom", "age" : 18}; 想分别获取它的key 和 value ...
- java线程-synchronized实现可见性代码
以下是一个普通线程代码: package com.Sychronized; public class SychronizedDemo { //共享变量 private boolean ready=fa ...
- screen 命令使用及示例
screen 是一个非常有用的命令,提供从单个 SSH 会话中使用多个 shell 窗口(会话)的能力.当会话被分离或网络中断时,screen 会话中启动的进程仍将运行,你可以随时重新连接到 scre ...