java.lang.SecurityException:open3:用户10060和当前进程都没有android.permission.USE_SIP

时间:2016-08-06 05:08:46

标签: android sip

我在Android开发者网站上引用SIP教程:https://developer.android.com/guide/topics/connectivity/sip.html

如本页所述,我从github找到了一个相关的演示应用程序作为SIPDemo。 (不是来自官方谷歌示例页面,不确定为什么它从那里丢失)

我在Android Studio中配置了项目,并在移动设备和Genymotion模拟器上运行它。

该应用程序具有设置页面,用户可以在其中输入Sip用户名,密码和域信息。在我向应用程序输入信息后,我看到了这个错误。

life.gwl.sipdemo E/AndroidRuntime: FATAL EXCEPTION: main
                                                                  Process: life.gwl.sipdemo, PID: 16877
                                                                  java.lang.RuntimeException: Unable to resume activity {life.gwl.sipdemo/life.gwl.sipdemo.WalkieTalkieActivity}: java.lang.SecurityException: open3: Neither user 10060 nor current process has android.permission.USE_SIP.
                                                                      at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
                                                                      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)
                                                                      at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                      at android.os.Looper.loop(Looper.java:148)
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                   Caused by: java.lang.SecurityException: open3: Neither user 10060 nor current process has android.permission.USE_SIP.
                                                                      at android.os.Parcel.readException(Parcel.java:1599)
                                                                      at android.os.Parcel.readException(Parcel.java:1552)
                                                                      at android.net.sip.ISipService$Stub$Proxy.open3(ISipService.java:241)
                                                                      at android.net.sip.SipManager.open(SipManager.java:234)
                                                                      at life.gwl.sipdemo.WalkieTalkieActivity.initializeLocalProfile(WalkieTalkieActivity.java:170)
                                                                      at life.gwl.sipdemo.WalkieTalkieActivity.initializeManager(WalkieTalkieActivity.java:136)
                                                                      at life.gwl.sipdemo.WalkieTalkieActivity.onStart(WalkieTalkieActivity.java:105)
                                                                      at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
                                                                      at android.app.Activity.performStart(Activity.java:6253)
                                                                      at android.app.Activity.performRestart(Activity.java:6299)
                                                                      at android.app.Activity.performResume(Activity.java:6304)
                                                                      at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092)
                                                                      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134) 
                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388) 
                                                                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                      at android.os.Looper.loop(Looper.java:148) 
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                      at java.lang.reflect.Method.invoke(Native Method) 
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

我在AndroidManifest.xml文件中添加了以下权限。

<!-- permission-->
    <uses-permission android:name="android.permission.USE_SIP" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

如果我使用与CSipSimple等应用程序相同的SIP凭据,则表明它正常运行。

1 个答案:

答案 0 :(得分:1)

您似乎已将targetSdkVersion设置为23,这意味着您必须在运行时处理权限请求。
More details

简单的解决方案是在应用清单中将targetSdkVersion设置为22。