/**
* 隐式意图的方法启动系统短信
*
* 简单概括就是: 意图包括:Action(动作),Category(附加信息),Data(数据,具体内容),Tpye(类型)等等,举个例子,
* 说白了意图就是启动一个组件的的完整的动作信息
* ,就像打人,打就是Action动作,人就是Data内容,而Type就是类型,打什么人呢?打坏人,type就是坏指的类型
* ,只有这些信息全了才能执行一个完整的意图
* ,当然还有一些信息,比如scheme就是URI类型的数据的前缀,就像这个例子当中的sms:,还有host主机名,path路径等
*
* @param view
*/
public void startOne(View view) {
Intent intent = new Intent();
intent.setAction("android.intent.action.SENDTO");// 发送信息的动作
intent.addCategory("android.intent.category.DEFAULT");// 附加信息
intent.setData(Uri.parse("sms:10086"));// 具体的数据,发送给10086
startActivity(intent);
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.loonggg.intent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="net.loonggg.intent.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="net.loonggg.intent.SecondActivity" >
<intent-filter>
<!-- 自定义的动作 -->
<action android:name="net.loonggg.xxx" />
<!-- 自定义的scheme和host -->
<data
android:host="www.baidu.com"
android:path="/person"
android:scheme="loonggg" />
<!-- 自定义的类型 -->
<data android:mimeType="person/people" />
<!-- 附加信息 -->
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
<activity android:name="net.loonggg.intent.SecondActivity" > <intent-filter> <!-- 自定义的动作 --> <action android:name="net.loonggg.xxx" /> <!-- 自定义的scheme和host --> <data android:host="www.baidu.com" android:path="/person" android:scheme="loonggg" /> <!-- 自定义的类型 --> <data android:mimeType="person/people" /> <!-- 附加信息 --> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
/**
* 通过自定义的隐式意图启动
*
* @param view
*/
public void startTwo(View view) {
Intent intent = new Intent();
intent.setAction("net.loonggg.xxx");
intent.addCategory("android.intent.category.DEFAULT");
intent.setDataAndType(Uri.parse("loonggg://www.baidu.com/person"),
"person/people");
startActivity(intent);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有