以编程方式从应用程序启动 Skype &通行证号码 - 安卓 [英] Launch Skype from an App Programmatically & Pass Number - Android

查看:31
本文介绍了以编程方式从应用程序启动 Skype &通行证号码 - 安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试启动并传递电话.不.从我的应用程序通过此代码进行 Skype:

Trying to launch and pass tel. no. to skype by this code from my app:

PackageManager packageManager = getPackageManager();
Intent skype = packageManager.getLaunchIntentForPackage("com.skype.raider");
skype.setData(Uri.parse("tel:65465446"));
startActivity(skype);

Skype 已启动,但无法接听号码.

Skype is launched but it can't catch the number.

推荐答案

此代码适用于我在两个 Skype 用户之间发起通话:

This code works for me to start a call between two Skype users:

Intent sky = new Intent("android.intent.action.VIEW");
sky.setData(Uri.parse("skype:" + user_name));
startActivity(sky);

要找到这个(和其他),使用 apktool 打开 Skype APK.查看 AndroidManifest.xml,您将看到他们知道的所有意图过滤器.如果您想触发其中一个意图过滤器,您需要创建一个与其中一个匹配的意图.这是上面代码匹配的意图过滤器:

To find this (and others), use apktool to open up the Skype APK. Look at the AndroidManifest.xml and you'll see all the intent filters they know about. If you want to trigger one of those intent filters, you need to make an intent that will match one. Here's the intent filter that the code above is matching:

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="skype" />
        </intent-filter>

您可以从 {{new Intent()}} 免费获得类别android.intent.category.DEFAULT",因此剩下的就是设置操作和 URI.

You get the category "android.intent.category.DEFAULT" for free from {{new Intent()}}, so all that remains is to set the action and the URI.

tel: URI 的意图过滤器如下所示:

The intent filter for tel: URIs looks like this:

        <intent-filter android:icon="@drawable/skype_blue" android:priority="0">
            <action android:name="android.intent.action.CALL_PRIVILEGED" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="tel" />
        </intent-filter>

所以你开始行动并给 Intent 一个 tel: URI 和正确的事情发生".发生的情况是 Android 为 tel: URI 找到了正确的提供者.它可能会获得用户的输入以在电话应用程序和 Skype 之间进行选择.Skype 处理电话的优先级:URI 为零,最低.因此,如果安装了电话应用程序,它可能会获得 Intent.

So you set to the action and give the Intent a tel: URI and "the right thing happens". What happens is that Android finds the correct provider for the tel: URI. It might get the user's input to choose between the Phone App and Skype. The priority for Skype to handle tel: URIs zero, which is lowest. So if the Phone App is installed, it will probably get the Intent.

这篇关于以编程方式从应用程序启动 Skype &amp;通行证号码 - 安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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