使用按钮 onClick 发起 Skype 通话
Initiating a Skype Call with Button onClick
我想在单击按钮时发起 Skype 通话。我查找了几种可用的解决方案,但我猜大多数都已经过时并且无法正常工作。有人可以帮我解决这个问题吗?我对 Android 编程很陌生。我已经包含在下面的代码中。任何帮助将不胜感激。
public class 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 phone 呼叫:
CallVideo(getApplicationContext(), "tel:" + phoneNumber);
使用Intent.ACTION_VIEW将打开Skype通话页面,但不会发起通话。
如果需要启动 Skype phone 呼叫,则需要 Intent.ACTION_CALL 并添加权限
<uses-permission android:name="android.permission.CALL_PHONE" />
是的,不要忘记在调用 intents 之前检查是否安装了 Skype。
我想在单击按钮时发起 Skype 通话。我查找了几种可用的解决方案,但我猜大多数都已经过时并且无法正常工作。有人可以帮我解决这个问题吗?我对 Android 编程很陌生。我已经包含在下面的代码中。任何帮助将不胜感激。
public class 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 phone 呼叫:
CallVideo(getApplicationContext(), "tel:" + phoneNumber);
使用Intent.ACTION_VIEW将打开Skype通话页面,但不会发起通话。
如果需要启动 Skype phone 呼叫,则需要 Intent.ACTION_CALL 并添加权限
<uses-permission android:name="android.permission.CALL_PHONE" />
是的,不要忘记在调用 intents 之前检查是否安装了 Skype。