【问题标题】:Programmaitcally making a VOIP call with Zoiper on an android tablet在 Android 平板电脑上以编程方式使用 Zoiper 进行 VOIP 通话
【发布时间】:2014-06-26 20:06:20
【问题描述】:

我正在编写一个简单的 Android 应用程序,该应用程序有一个按钮,可以对预先指定的号码进行 SIP 呼叫。我使用的是 Android 平板电脑,版本 4.0.4。我已将按钮处理程序设置为:

Button button = (Button) rootView.findViewById(R.id.btnOpenDoor);
        button.setOnClickListener(new OnClickListener() {
            @Override
              public void onClick(View arg0) {
                Intent callIntent = new Intent(Intent.ACTION_CALL);
                callIntent.setData(Uri.parse("tel:123456789"));
                startActivity(callIntent);
              }
        });

我预计会弹出“您想使用哪个应用程序来拨打此号码”弹出窗口(我安装了 Zoiper 和 CSipSimple)。但它只是弹出一个对话框,询问我是否想将此号码添加到我的联系人中。我觉得这是因为我使用的是平板电脑而不是手机。我尝试将 Uri 更改为 sip:123456789zoiper:123456789。我也尝试过像这样设置意图的包:

callIntent.setPackage("com.zoiper.android.app");

一切都无济于事。我的权限如下:

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

有人可以帮忙吗?

编辑:我应该说,我不限于使用 Zoiper。任何 SIP 应用程序都应该这样做。但是,当我尝试从拨号器外部(使用 zoiper、skype 和实际拨号器以及其他任何支持的拨号器)拨打电话号码时,我肯定会在手机上弹出“请选择使用哪个应用程序来完成此操作”对话框拨号。

【问题讨论】:

  • Aaltan> 你解决了吗?

标签: android android-intent sip voip


【解决方案1】:

这对我有用,灵感来自@user2999943 的回答:

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("tel://" + 123456789));
startActivity(intent);

【讨论】:

    【解决方案2】:

    我在 Zoiper 应用程序中遇到过类似的问题。对我有用的解决方案是将 HTML 字符串传递给 TextView。现在,当我单击该 TextView 时,我会看到一个对话框“使用...完成操作”,其中 Zoiper 应用程序填充在列表中。

    在你的布局中添加 TextView:

    <TextView
        android:id="@+id/numberField"
        android:layout_width="match_parent"
        android:layout_height="98dp"        
        android:background="#FFFFFF"
        android:gravity="left|center_vertical"
        android:hint="No phone number"        
        android:paddingLeft="5dp"
        android:textColor="#000000"
        android:textColorLink="#000000"
        android:textSize="40sp" />
    

    在你的活动中:

    TextView numberField = (TextView) findViewById(R.id.numberField);
    numberField.setMovementMethod(LinkMovementMethod.getInstance());
    
    
    String htmlText = "<a href=tel:555>555</a>";                
    
    Spannable s = (Spannable) Html.fromHtml(htmlText);
    for (URLSpan u: s.getSpans(0, s.length(), URLSpan.class)) 
    {
        s.setSpan(new UnderlineSpan() 
        {
            public void updateDrawState(TextPaint tp) 
            {
                 tp.setUnderlineText(false);
            }
        }, s.getSpanStart(u), s.getSpanEnd(u), 0);
    }
    numberField.setText(s);
    

    【讨论】:

      【解决方案3】:

      我不知道 zoiper 怎么样,但这段代码可以与 CSIPSimple 一起调用:

                  Intent callIntent = new Intent(Intent.ACTION_DIAL);
                  callIntent.setPackage("com.csipsimple");
                  callIntent.setData(Uri.parse("sip:123456789"));
                  startActivity(callIntent);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-04
        • 2016-03-15
        相关资源
        最近更新 更多