【问题标题】:Launch Skype from an App Programmatically & Pass Number - Android以编程方式从应用程序启动 Skype 并通过号码 - Android
【发布时间】:2011-06-20 16:32:41
【问题描述】:

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

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

Skype 已启动,但无法获取号码。

【问题讨论】:

标签: android android-intent android-activity skype


【解决方案1】:

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

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

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

        <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。

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

        <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 处理 tel: URI 的优先级为零,这是最低的。所以如果安装了Phone App,它可能会得到Intent。

【讨论】:

  • 使用最新的 Skype 版本,此答案不再有效 - 请参阅下面 Martin 的答案并包含 URI 扩展名。
  • 好吧,我试过了,但它只打开了 Skype 应用程序,没有拨打电话号码。有什么想法吗?
  • 谁能帮我解决这个问题? stackoverflow.com/questions/35353839/…
  • 如何调用。有什么想法吗。它只是在使用 Skye 应用程序。
【解决方案2】:

如果您想触发视频通话,您必须将“?call&video=true”添加到您的 Skype URI。

Intent skypeVideo = new Intent("android.intent.action.VIEW");
skypeVideo.setData(Uri.parse("skype:" + "<username>" + "?call&video=true"));
startActivity(skypeVideo);

有关 Skype URI 的更多信息记录在: http://developer.skype.com/skype-uris-program/skype-uri-ref

编辑:

没有任何意图选择器的直接 Skype 通话:

如果您想在没有任何意图选择器的情况下直接进行 Skype 通话,请在清单文件中添加这些行...

               <intent-filter
                    android:icon="@drawable/skype"
                    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-filter>
                    <intent-filter
                        android:icon="@drawable/skype"
                        android:priority="0" >
                        <action android:name="android.intent.action.VIEW" />
                        <action android:name="android.intent.action.CALL" />

                        <category android:name="android.intent.category.BROWSABLE" />
                        <category android:name="android.intent.category.DEFAULT" />

                        <data android:scheme="skype" />
                    </intent-filter>


                </intent-filter>

【讨论】:

【解决方案3】:

将此代码用于 Skype 版本 2:

Intent skype_intent = new Intent("android.intent.action.VIEW");
skype_intent.setClassName("com.skype.raider", "com.skype.raider.Main");
skype_intent.setData(Uri.parse("skype:skypeusername"));
startActivity(skype_intent);

【讨论】:

    【解决方案4】:

    使用此代码,您将获得 Skype 活动的意图,而不是呼叫者活动。因此,您必须找到具有动作 CALL 的意图过滤器的活动的意图。但更清楚 Skype 使用了动作android.intent.action.CALL_PRIVILEGED,所以通过这个过滤器找到。 仅提供调用者活动为 cmp=com.skype.raider.contactsync.ContactSkypeOutCallStartActivity 的信息。

    【讨论】:

    • 使用 CALL 是可以的,因为您无法使用 Skpye 拨打紧急电话;但如果您想始终启动 Skype,请使用具有指定 Activity 类的 Intent,或者用户可以选择其他应用程序。
    • 成功了!通过此代码:Intent sky = new Intent("android.intent.action.CALL_PRIVILEGED"); sky.setClassName("com.skype.raider", "com.skype.raider.contactsync.ContactSkypeOutCallStartActivity"); sky.setData(Uri.parse("tel:65465446")); startActivity(sky);
    • 这仅适用于Skype。请参阅我的答案以获得更完整的解决方案。
    • @ruben ContactSkypeOutCallStartActivity 的代码是什么?
    【解决方案5】:

    Skype 2.X 的清单与 Skype 1.X 明显不同。那里没有 ContactSkypeOutCallStartActivity。新清单包含代码:

    <activity android:name="com.skype.raider.Main" android:launchMode="singleTask"  android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="adjustResize">
    ...
      <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>
    ...
    </activity>
    

    所以你应该写:

    Intent skype_intent = new Intent("android.intent.action.CALL_PRIVILEGED");
    skype_intent.setClassName("com.skype.raider", "com.skype.raider.Main");
    skype_intent.setData(Uri.parse("tel:65465446")); 
    context.startActivity(skype_intent);
    

    请注意,此方法不允许您使用 Skype 开始通话/聊天。它仅适用于 Skype Out。

    【讨论】:

      【解决方案6】:

      我发现上面的代码不起作用...

      Intent i = packageManager.getLaunchIntentForPackage("com.skype.raider");
      // i.setAction("android.intent.cation.CALL_PRIVILEGED");
      // i.setClassName("com.skype.raider", "com.skype.raider.contactsync.ContactSkypeOutCallStartActivity");
      // i.setData(Uri.parse("tel:5551234")); 
      startActivity(i);
      

      被注释掉的行要么停止运行,要么什么都不做!

      显示的代码将调用 Skype 并到达您可以选择 Skype 联系人的页面 欢迎提供更多信息 约翰

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-04-29
        • 2010-11-01
        • 1970-01-01
        • 2011-03-27
        • 1970-01-01
        • 2013-02-05
        • 1970-01-01
        相关资源
        最近更新 更多