Android的Intent.ACTION_CALL,乌里 [英] Android Intent.ACTION_CALL, Uri

查看:101
本文介绍了Android的Intent.ACTION_CALL,乌里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Intent.Action类。我知道如何使用ACTION_VIEW显示一个URL,但我想用 Intent.ACTION_DIAL 拨打号码时,应用程序启动。该文件说,你需要分析一个URI转换成字符串,然后把它添加到我试过这个意图:

 开放的电话= Uri.parse(7777777777);
意图冲浪=新的意图(Intent.ACTION_DIAL,电话);
startActivity(冲浪);
 

这不工作,我得到一个错误消息说:

不幸的是,项目已经停止。我试着调试code和在我看来,指向意图,不知道我做错了,如果我只是做它的工作原理,并提出了拨号器。

  //开放的呼叫= Uri.parse(7777777777);
意图冲浪=新的意图(Intent.ACTION_DIAL);
startActivity(冲浪);
 

解决方案

电话

 串号=23454568678;
    意向意图=新的意图(Intent.ACTION_CALL);
    intent.setData(Uri.parse(电话:+号));
    startActivity(意向);
 

使用权限

 <使用-权限的Andr​​oid:名称=android.permission.CALL_PHONE>< /使用-许可>
 

I am trying to use the Intent.Action class. I know how to use the ACTION_VIEW to display a URL but I wanted to use the Intent.ACTION_DIAL to call number when the application is launched. The documentation says you need to parse a URI into a string and then add it to the Intent I tried this:

Uri call = Uri.parse("7777777777");             
Intent surf = new Intent(Intent.ACTION_DIAL, call); 
startActivity(surf);

This doesn't work I get an error message saying:

Unfortunately, Project has stopped. I tried to debug the code and it seems to point me to the intent line not sure what I doing wrong if I just do this it works and brings up the dialer.

//Uri call = Uri.parse("7777777777");               
Intent surf = new Intent(Intent.ACTION_DIAL);   
startActivity(surf);

解决方案

tel

String number = "23454568678";
    Intent intent = new Intent(Intent.ACTION_CALL);
    intent.setData(Uri.parse("tel:" +number));
    startActivity(intent);

Use Permission

<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>   

这篇关于Android的Intent.ACTION_CALL,乌里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆