不久前我创建了这篇文章,我和我的同事找到了两个不同的答案(他们都工作):
第一个解决方案是使用
意图 callIntent = new Intent("android.intent.action.CALL_PRIVILEGED");
这将打开一个新窗口,提供通过所有可能的方式拨打电话的电话 - 在这种特殊情况下,它们是拨号器、Viber 和 Skype(或以后添加的任何其他方法)。
第二种解决方案是显式呼叫 Viber 并放置一个要呼叫的电话号码
意图 viberCallIntent = new Intent("com.viber.voip.action.CALL"); viberCallIntent.setType("vnd.android.cursor.item/vnd.com.viber.voip.call"); viberCallIntent.setData(Uri.parse("tel:" + dialNumber)); viberCallIntent.putExtra("external_call", true); viberCallIntent.putExtra("contact_id", -1L); 开始活动(viberCallIntent);
自上次 Viber 更新(我们昨天注意到它)以来,这些方法都不起作用。第一个只是使用 Skype 通话,甚至不提供拨号器(!?!),但如果没有安装 Skype,那么它将回退到拨号器并拨打电话。第二个崩溃声称没有找到处理意图的活动?
知道发生了什么,如何解决?
错误日志如下:
01-27 17:35:03.794: E/AndroidRuntime(7738): FATAL EXCEPTION: main
01-27 17:35:03.794: E/AndroidRuntime(7738): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.viber.voip dat=tel:xxxxxxxxx (has extras) }
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1423)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.app.Activity.startActivityForResult(Activity.java:3388)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.app.Activity.startActivityForResult(Activity.java:3349)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.app.Activity.startActivity(Activity.java:3584)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.app.Activity.startActivity(Activity.java:3552)
01-27 17:35:03.794: E/AndroidRuntime(7738): at rs.limitline.maxitaxins.MainActivity.callViber(MainActivity.java:96)
01-27 17:35:03.794: E/AndroidRuntime(7738): at rs.limitline.maxitaxins.MainActivity.onClick(MainActivity.java:186)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.view.View.performClick(View.java:4212)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.view.View$PerformClick.run(View.java:17476)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.os.Handler.handleCallback(Handler.java:800)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.os.Handler.dispatchMessage(Handler.java:100)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.os.Looper.loop(Looper.java:194)
01-27 17:35:03.794: E/AndroidRuntime(7738): at android.app.ActivityThread.main(ActivityThread.java:5431)
01-27 17:35:03.794: E/AndroidRuntime(7738): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 17:35:03.794: E/AndroidRuntime(7738): at java.lang.reflect.Method.invoke(Method.java:525)
01-27 17:35:03.794: E/AndroidRuntime(7738): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
01-27 17:35:03.794: E/AndroidRuntime(7738): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
01-27 17:35:03.794: E/AndroidRuntime(7738): at dalvik.system.NativeStart.main(Native Method)
[更新] 这也显示为错误:
01-27 19:46:56.704: D/Greska(19822): Permission Denial: starting Intent { act=com.viber.voip.action.CALL dat=tel:xxxxxxxxx cmp=com.viber.voip/com.viber.service.OutgoingCallBroadcaster (has extras) } from ProcessRecord{416c41b8 19822:rs.limitline.maxitaxins/u0a10065} (pid=19822, uid=10065) not exported from uid 10147