intent对于电话和浏览器调用
xml
创建
文件
浏览器
电话
调用
1、创建xml文件及按钮LinearLayout xmlns:android=http://schemas.android.com/apk/res/androidandroid:orientation=verticalandroid:layout_width=match_parentandroid:layout_height=match_parentButtonandroid:id=@ id/intentbtnandroid:布局宽度=fil
1、创建xml文件及按钮 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/intentbtn" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="intent调用浏览器" android:layout_marginTop="100dp"/> <Button android:id="@+id/intentbtncall" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="intent调用电话"/> </LinearLayout> 2、新创建一个Intent的java文件 ublic class Intent_s extends Activity { //定义两个属性 private Button mbutton,callbutton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.intent); //初始化属性 mbutton = (Button) findViewById(R.id.intentbtn); callbutton=(Button)findViewById(R.id.intentbtncall); //监听intent调用电话的按钮 callbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //标示地址 Uri uri = Uri.parse("tel:13881715535"); //新创建intent调用 Intent it = new Intent(Intent.ACTION_DIAL, uri); //启动 startActivity(it); } }); //监听intent调用浏览器的监听 mbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //标示地址 Uri uri = Uri.parse("http://www.baidu.com"); //新创建intent Intent intent = new Intent(); //调用intent intent.setAction(Intent.ACTION_VIEW); //向intent放入数据 intent.setData(uri); //启动 startActivity(intent); } }); }
登录后复制
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 个月前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
1 个月前
By 尊渡假赌尊渡假赌尊渡假赌
刺客信条阴影:贝壳谜语解决方案
3 周前
By DDD
Windows 11 KB5054979中的新功能以及如何解决更新问题
2 周前
By DDD
威尔R.E.P.O.有交叉游戏吗?
1 个月前
By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

在Safari中使用自定义样式表的问题探讨今天我们来探讨一个关于Safari浏览器的自定义样式表应用问题。前端新手...

CSS自定义resize符号的方法与背景色统一在日常开发中,我们经常会遇到需要自定义用户界面细节的情况,比如调...

如何使用JavaScript或CSS控制浏览器打印设置中的页首和页尾在浏览器的打印设置中,有一个选项可以控制是否显�...

在网页中使用本地安装的字体文件最近,我从网上下载了一种免费字体,并成功将其安装到了我的系统中。现在...

使用CSS实现响应式布局当我们希望在网页设计中实现不同屏幕尺寸下的布局变化时,CSS...
