marcick Well-Known Member Licensed User Longtime User Aug 14, 2019 #1 I have recently removed from my app the dangerous "phone" permission and everything works fine on tenths of devices. I have suddenly this crash on a Android 5.0 device Code: Copy java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10190 nor current process has android.permission.READ_PHONE_STATE It is generated in this sub: Code: Copy Sub CheckConnection As Boolean Dim ph As Phone Dim myLAN As ServerSocket myLAN.Initialize(0, "") If ph.GetDataState <> "CONNECTED" And myLAN.GetMyIP = "127.0.0.1" Then --->> ERROR HERE Return False Else Return True End If End Sub TargetSdk is 28 and you see in the picture the permission listed in B4A Why this sub requires READ_PHONE_STATE and why it happens only on this particular device ? The user experience the crash only when 3G/4G data is enabled. If they are switched off and it works only with Wi-Fi the app runs ok. Attachments Cattura.JPG 73.5 KB · Views: 821
I have recently removed from my app the dangerous "phone" permission and everything works fine on tenths of devices. I have suddenly this crash on a Android 5.0 device Code: Copy java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10190 nor current process has android.permission.READ_PHONE_STATE It is generated in this sub: Code: Copy Sub CheckConnection As Boolean Dim ph As Phone Dim myLAN As ServerSocket myLAN.Initialize(0, "") If ph.GetDataState <> "CONNECTED" And myLAN.GetMyIP = "127.0.0.1" Then --->> ERROR HERE Return False Else Return True End If End Sub TargetSdk is 28 and you see in the picture the permission listed in B4A Why this sub requires READ_PHONE_STATE and why it happens only on this particular device ? The user experience the crash only when 3G/4G data is enabled. If they are switched off and it works only with Wi-Fi the app runs ok.
Erel B4X founder Staff member Licensed User Longtime User Aug 14, 2019 #2 Phone.GetDataState doesn't require any permissions (https://developer.android.com/reference/android/telephony/TelephonyManager.html#getDataState()). Do you have access to the full error message? Upvote 0
Phone.GetDataState doesn't require any permissions (https://developer.android.com/reference/android/telephony/TelephonyManager.html#getDataState()). Do you have access to the full error message?
marcick Well-Known Member Licensed User Longtime User Aug 14, 2019 #3 Yes, strange. This is all what I have Code: Copy ~e: at java.lang.reflect.Method.invoke(Native Method) ~e: at java.lang.reflect.Method.invoke(Method.java:372) ~e: at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196) ~e: at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180) ~e: at anywheresoftware.b4a.BA.raiseEvent(BA.java:176) ~e: at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80) ~e: at android.view.View.performClick(View.java:5197) ~e: at android.view.View$PerformClick.run(View.java:20926) ~e: at android.os.Handler.handleCallback(Handler.java:739) ~e: at android.os.Handler.dispatchMessage(Handler.java:95) ~e: at android.os.Looper.loop(Looper.java:145) ~e: at android.app.ActivityThread.main(ActivityThread.java:5951) ~e: at java.lang.reflect.Method.invoke(Native Method) ~e: at java.lang.reflect.Method.invoke(Method.java:372) ~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388) ~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183) java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10190 nor current process has android.permission.READ_PHONE_STATE. at android.os.Parcel.readException(Parcel.java:1540) at android.os.Parcel.readException(Parcel.java:1493) at com.android.internal.telephony.ITelephony$Stub$Proxy.getDataState(ITelephony.java:2791) at android.telephony.TelephonyManager.getDataState(TelephonyManager.java:2348) at anywheresoftware.b4a.phone.Phone.GetDataState(Phone.java:330) at it.elettronicablancato.bmap4e.mysub._vvvvvvvv5(mysub.java:257) at it.elettronicablancato.bmap4e.main._iconsettings_click(main.java:4285) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180) at anywheresoftware.b4a.BA.raiseEvent(BA.java:176) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80) at android.view.View.performClick(View.java:5197) at android.view.View$PerformClick.run(View.java:20926) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5951) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183) Upvote 0
Yes, strange. This is all what I have Code: Copy ~e: at java.lang.reflect.Method.invoke(Native Method) ~e: at java.lang.reflect.Method.invoke(Method.java:372) ~e: at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196) ~e: at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180) ~e: at anywheresoftware.b4a.BA.raiseEvent(BA.java:176) ~e: at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80) ~e: at android.view.View.performClick(View.java:5197) ~e: at android.view.View$PerformClick.run(View.java:20926) ~e: at android.os.Handler.handleCallback(Handler.java:739) ~e: at android.os.Handler.dispatchMessage(Handler.java:95) ~e: at android.os.Looper.loop(Looper.java:145) ~e: at android.app.ActivityThread.main(ActivityThread.java:5951) ~e: at java.lang.reflect.Method.invoke(Native Method) ~e: at java.lang.reflect.Method.invoke(Method.java:372) ~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388) ~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183) java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10190 nor current process has android.permission.READ_PHONE_STATE. at android.os.Parcel.readException(Parcel.java:1540) at android.os.Parcel.readException(Parcel.java:1493) at com.android.internal.telephony.ITelephony$Stub$Proxy.getDataState(ITelephony.java:2791) at android.telephony.TelephonyManager.getDataState(TelephonyManager.java:2348) at anywheresoftware.b4a.phone.Phone.GetDataState(Phone.java:330) at it.elettronicablancato.bmap4e.mysub._vvvvvvvv5(mysub.java:257) at it.elettronicablancato.bmap4e.main._iconsettings_click(main.java:4285) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180) at anywheresoftware.b4a.BA.raiseEvent(BA.java:176) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80) at android.view.View.performClick(View.java:5197) at android.view.View$PerformClick.run(View.java:20926) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5951) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Erel B4X founder Staff member Licensed User Longtime User Aug 14, 2019 #4 Looks like an OS bug. You can add Try / Catch to catch this error. If it is critical for you then request this permission after it fails (make sure to also add it to the manifest editor). Upvote 0
Looks like an OS bug. You can add Try / Catch to catch this error. If it is critical for you then request this permission after it fails (make sure to also add it to the manifest editor).
marcick Well-Known Member Licensed User Longtime User Aug 14, 2019 #5 I wanted so much to get rid of this permission .. when the user see that my app want to manage contacts and calls it is not happy. I was using it before to read IMEI, but now I use Advertising_ID to identify the device and I no longer need this permission. Ok, you gave me your answer, thank you. I'll see. Upvote 0
I wanted so much to get rid of this permission .. when the user see that my app want to manage contacts and calls it is not happy. I was using it before to read IMEI, but now I use Advertising_ID to identify the device and I no longer need this permission. Ok, you gave me your answer, thank you. I'll see.