使用Button onClick启动Skype通话

时间:2015-12-09 01:02:33

标签: java android android-intent skype

我想点击按钮发起Skype通话。我查找了几种可用的解决方案,但我估计大多数解决方案都已过时且无法正常工作。有人可以帮我这个吗?我是Android编程的新手。我已经通过以下代码包含在内。任何帮助将不胜感激。

公共类MainActivity扩展了AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

public void CallVideo(Context myContext,String mySkypeUri){

   Uri skypeUri = Uri.parse(mySkypeUri);
   Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);

   myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
   myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

   myContext.startActivity(myIntent);

   return;

} }

activity_main.xml中

  <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Video Call"
    android:id="@+id/button"
    android:layout_below="@+id/textView3"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="37dp"
    android:onClick="CallVideo"/>

1 个答案:

答案 0 :(得分:1)

方法是正确的。

对于Skype语音通话:

 CallVideo(getApplicationContext(), "skype:" + skypeUserName + "?call");

对于Skype视频通话:

CallVideo(getApplicationContext(), "skype:" + skypeUserName + "?call&video=true");

对于Skype聊天:

 CallVideo(getApplicationContext(), "skype:" + skypeUserName + "?chat");

对于Skype电话:

 CallVideo(getApplicationContext(), "tel:" + phoneNumber);

使用Intent.ACTION_VIEW将打开Skype调用页面,但不会启动调用。

如果需要启动Skype电话,则意图操作需要是Intent.ACTION_CALL并添加权限

 <uses-permission android:name="android.permission.CALL_PHONE" />

是的,不要忘记在调用意图之前检查Skype是否安装。

相关问题