以编程方式从应用程序启动Skype&传递号码 - Android

时间:2011-06-20 16:32:42

标签: android android-intent android-activity skype

尝试启动并传递电话。没有。通过我的应用程序中的代码来skype:

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

Skype已启动,但无法识别该号码。

6 个答案:

答案 0 :(得分:35)

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

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

要找到这个(以及其他人),请使用apktool打开Skype APK。查看AndroidManifest.xml,您将看到他们了解的所有意图过滤器。如果要触发其中一个intent过滤器,则需要创建一个与之匹配的intent。这是上面代码匹配的intent过滤器:

        <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:URIs的intent过滤器如下所示:

        <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的正确提供者。它可能会让用户输入在Phone App和Skype之间进行选择。 Skype处理tel的优先级:URI为零,这是最低的。因此,如果安装了电话应用程序,它可能会获得意图。

答案 1 :(得分:17)

如果您想要触发视频通话,则必须在Skype URI中添加“?call&amp; video = true”。

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>

答案 2 :(得分:4)

将此代码用于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);

答案 3 :(得分:1)

使用此代码,您将获得Skype活动的意图而非呼叫者活动。因此,您必须找到具有针对操作CALL的intent过滤器的活动的意图。但更明显的是Skype使用了android.intent.action.CALL_PRIVILEGED动作,所以请通过此过滤器查找。 仅用于呼叫者活动为cmp=com.skype.raider.contactsync.ContactSkypeOutCallStartActivity的信息。

答案 4 :(得分:0)

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

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联系人的页面 欢迎提供更多信息 约翰

答案 5 :(得分:0)

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。