意向Skype for Business呼叫

时间:2017-01-09 18:27:07

标签: android android-intent skype-for-business

我在Android设备上安装了Skype和Skype for Business。我想以编程方式与Skype for Business进行VOIP通话。 我创建了这样的意图:

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

当我开始打电话时,会出现一个弹出窗口:

完成操作使用:
Skype的
电话
一次性

Skype for Business不在那里。

我尝试了跟进但它崩溃了(IllegalArgument)

intent.setData(Uri.parse("skype for business:" +  somePhoneNumber));

我该怎么办?

2 个答案:

答案 0 :(得分:2)

我是这样做的:

的strings.xml

<!-- skype -->
<string name="skype_activity_title">Skype for Business call</string>
<string name="make_skype_call">Make Skype Call</string>
<string name="video_call">Video call</string>
<string name="permission_rationale">"Contacts permissions are needed for providing email completions."</string>
<string name="skypeEmailAddress">skypeEmailAddress</string>

RES / layout.skype.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/skype_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="20dp">

    <EditText
        android:id="@+id/skypeEmailAddress"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="20dp"
        android:hint="jsmith@somewhere.com"
        android:inputType="textEmailAddress"
        android:textSize="30sp"/>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <Button
            android:id="@+id/skype_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="20dp"
            android:textSize="30sp"
            android:text="@string/make_skype_call" />

        <CheckBox
            android:id="@+id/videoCheck"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/video_call"
            android:textSize="30sp"/>

    </LinearLayout>
</LinearLayout>

的AndroidManifest.xml

<!-- Skype Activity -->
<activity
    android:name="com.somwhere.myproject.SkypeActivity"
    android:label="@string/skype_activity_title"
    android:theme="@style/Theme.AppCompat">
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value=".MainActivity"/>
</activity>

SkypeActivity.java

package com.somwhere.myproject;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;

public class SkypeActivity extends AppCompatActivity {

    private static final String TAG = "SkypeActivity";
    private static final int REQUEST_READ_CONTACTS = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = getIntent();
        final String skypeEmailAddress = intent.getStringExtra(getResources().getString(R.string.skypeEmailAddress));

        setContentView(R.layout.skype);

        final EditText skypeEmailAddressText = (EditText) findViewById(R.id.skypeEmailAddress);
        skypeEmailAddressText.setText(skypeEmailAddress);

        Button skypeButton = (Button) findViewById(R.id.skype_button);

        Log.i(TAG, "skypeEmailAddress: " + skypeEmailAddress);
        final CheckBox videoCall = (CheckBox) findViewById(R.id.videoCheck);
        skypeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                String uriString = "ms-sfb://call?id=" + skypeEmailAddress;
                if (videoCall.isChecked()) {
                    uriString += "&video=true";
                }
                Uri uri = Uri.parse(uriString);
                Intent callIntent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(callIntent);
            }
        });

    }
}

MainActivity.java(可能在点击按钮上)

Intent intent = new Intent(activity, SkypeActivity.class);
intent.putExtra(activity.getResources().getString(R.string.skypeEmailAddress), "jsmith@somewhere.com");
activity.startActivity(intent);

答案 1 :(得分:0)

如MSDN docs中所述,使用此方法呼叫Skype for business Intent:

Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse("ms-sfb://call?id=" +  somePhoneNumber));
context.startActivity(intent);