Android学习笔记(十七)——使用意图调用内置应用程序
2014-05-20 10:53
555 查看
使用意图调用内置应用程序
1、创建一个新的Android项目并命名为Intents,在main.xml文件中添加两个Button:
<Button
android:id="@+id/btn_webbrowser"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onClickWebBrowser"
android:text="Web Browser" />
<Button
android:id="@+id/btn_makecalls"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onClickMakeCalls"
android:text="Make Calls" />
2、在IntentsActivity.java文件中添加如下代码:
public void onClickWebBrowser(View v) {//浏览器
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://网址"));//网址处输入百度网址,CSDN不让直接写网址...
startActivity(intent);
}
public void onClickMakeCalls(View v) {//打电话
Intent intent = new Intent(android.content.Intent.ACTION_DIAL,
Uri.parse("tel:+651234567"));
startActivity(intent);
}
3、运行程序,效果如下:
点击Web Browser:
点击Make Calls:
总结:
在Android中,意图通常是成对出项:动作(Action)和数据(data)。动作描述了要执行什么,数据则指定了受影响的对象。
动作的一些示例:Action_VIEW、ACTION_DIAL、ACTION_PICK;
数据的一些示例:tel:+651234567、geo:37.827500,-122.481670、content://contacts。
1、创建一个新的Android项目并命名为Intents,在main.xml文件中添加两个Button:
<Button
android:id="@+id/btn_webbrowser"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onClickWebBrowser"
android:text="Web Browser" />
<Button
android:id="@+id/btn_makecalls"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onClickMakeCalls"
android:text="Make Calls" />
2、在IntentsActivity.java文件中添加如下代码:
public void onClickWebBrowser(View v) {//浏览器
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://网址"));//网址处输入百度网址,CSDN不让直接写网址...
startActivity(intent);
}
public void onClickMakeCalls(View v) {//打电话
Intent intent = new Intent(android.content.Intent.ACTION_DIAL,
Uri.parse("tel:+651234567"));
startActivity(intent);
}
3、运行程序,效果如下:
点击Web Browser:
点击Make Calls:
总结:
在Android中,意图通常是成对出项:动作(Action)和数据(data)。动作描述了要执行什么,数据则指定了受影响的对象。
动作的一些示例:Action_VIEW、ACTION_DIAL、ACTION_PICK;
数据的一些示例:tel:+651234567、geo:37.827500,-122.481670、content://contacts。
相关文章推荐
- Android学习笔记(十七)——使用意图调用内置应用程序
- Android学习笔记(十七)——使用意图调用内置应用程序
- Android开发之使用意图调用内置应用程序
- Android学习笔记之使用意图打开内置应用程序组件
- android学习笔记---53_采用网页设计软件界面,以及使用android系统内置的浏览器,利用js调用java方法
- 使用Intent调用内置应用程序
- 【Android 开发教程】使用Intent调用内置应用程序
- android学习笔记---53_采用网页设计软件界面,以及使用android系统内置的浏览器,利用js调用java方法
- 第三部分 02 在ASP.NET AJAX应用程序中使用JavaScript异步调用Page的方法
- Android 程式开发:(四)使用Intent调用“内置”应用 —— 4.4添加Category属性
- Javascript prototype属性使用(给内置对象添加新的方法,方便调用)
- Android学习笔记(九)—— 调用另外一个Activity — Intent对象的使用
- Android图像处理简介の使用内置Camera应用程序进行图像捕获
- android学习笔记---1.为应用添加新的Activity,中使用Intent(意图),结果码,请求码,得到新打开Activity 关闭后返回的数据,Bundle类的作用
- Android 程式开发:(四)使用Intent调用“内置”应用 —— 4.2浅析Intent
- Android 程式开发:(四)使用Intent调用“内置”应用 —— 4.1范例
- Android学习笔记:如何使用真机调试应用程序
- Enterprise Library3.1 使用数据访问模块时,调用Microsoft.Practices.EnterpriseLibrary.Data报出源文件与当前应用程序不一致和创建dataconfiguration的配置节处理程序出错
- 使用Spring内置拦截器为Struts的Action在每个方法调用之前打印一句话
- Android 程式开发:(四)使用Intent调用“内置”应用 —— 4.3配置Intent-Filter