简体   繁体   English

Android:如何使用谷歌语音启动呼叫意图?

[英]Android: How to launch call intent using google voice?

How to launch specific intent (such as call) using google voice?如何使用谷歌语音启动特定意图(例如呼叫)? How to pass phone number using intent?如何使用意图传递电话号码? Following code launches google voice but what value to be passed for making call using google voice as intent extras?以下代码启动了谷歌语音,但是使用谷歌语音作为意图附加功能进行呼叫要传递什么价值?

final Intent intent = new Intent();
intent.setComponent(new ComponentName("com.google.android.apps.googlevoice", "com.google.android.apps.googlevoice.activity.conversationlist.ConversationListActivity"));

intent.putExtra("label", "<phone number>");

startActivity(intent);

Here what should i put in label to start the intent that launches a call using google voice?在这里我应该在 label 中输入什么来启动使用谷歌语音发起呼叫的意图? Any help is appreciated... Thanks in Advance...任何帮助表示赞赏...提前致谢...

What @JoxTraex said makes sense. @JoxTraex 说的有道理。 However some clients need funny features like this, so we have no way but to implement this:但是有些客户需要这样有趣的功能,所以我们只好实现这个:

try {
        Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:" + mobile));
        intent.setPackage("com.google.android.apps.googlevoice");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    } catch (ActivityNotFoundException anfe) {
        GMHintManager.getInstance().showError(context, "Google Voice not installed");
    }

Yes, you should try-catch ActivityNotFoundException.是的,你应该 try-catch ActivityNotFoundException。

NEVER target applications directly like that UNLESS it is in your package. 除非直接放在包装中,否则切勿直接将应用程序作为目标。 You should be using the Intent filter to catch that particular application. 您应该使用Intent过滤器来捕获该特定应用程序。 Sometimes you have to target an application like this, but this brings up the risk of change in package name errors. 有时您必须像这样针对应用程序,但这带来了更改程序包名称错误的风险。

To handle your particular application, you need to look at how information is being passed into Google voice. 要处理您的特定应用程序,您需要查看如何将信息传递到Google语音中。 this will give you insight and how to target it WITHOUT targeting the exact package name. 这将为您提供见解,以及如何在定位确切软件包名称的情况下将其定位。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM