gpt4 book ai didi

java - 使用按钮 onClick 发起 Skype 通话

转载 作者:行者123 更新时间:2023-11-30 01:43:03 26 4
gpt4 key购买 nike

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


公共(public)类 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"/>

最佳答案

方法正确。

对于 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需要是Intent.ACTION_CALL并添加权限

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

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

关于java - 使用按钮 onClick 发起 Skype 通话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34169003/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com