Hi there...
after updating some things at my project and manifest file to target new sdk 28... PhoneEvents can't show the Incoming Phone Number... at log...
when i have target sdk: 26 works good...
heres my code:
at create of main require the following:
at manifest:
may be something with permissions...
after updating some things at my project and manifest file to target new sdk 28... PhoneEvents can't show the Incoming Phone Number... at log...
when i have target sdk: 26 works good...
heres my code:
B4X:
#Region Service Attributes
#StartAtBoot: True
#StartCommandReturnValue: android.app.Service.START_STICKY
#End Region
Sub Process_Globals
Dim PE As PhoneEvents
End Sub
Sub Service_Create
Service.AutomaticForegroundMode=Service.AUTOMATIC_FOREGROUND_NEVER
Service.StartForeground(1, CreateNotification("..."))
End Sub
sub Service_Start (StartingIntent As Intent)
PE.InitializeWithPhoneState("PE",PhoneId)
end sub
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
If State = "RINGING" Then
ph=IncomingNumber.trim
Log(ph)
end if
end sub
at create of main require the following:
B4X:
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
wait for Activity_PermissionResult(permission As String, result As Boolean)
Log(result)
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
wait for Activity_PermissionResult(permission As String, result As Boolean)
Log(result)
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
wait for Activity_PermissionResult(permission As String, result As Boolean)
Log(result)
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_READ_CONTACTS)
wait for Activity_PermissionResult(permission As String, result As Boolean)
Log(result)
Dim rp As RuntimePermissions
rp.CheckAndRequest("android.permission.ANSWER_PHONE_CALLS")
wait for Activity_PermissionResult(permission As String, result As Boolean)
Log(result)
at manifest:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddPermission("android.permission.CALL_PHONE")
AddPermission("android.permission.READ_PHONE_STATE")
AddPermission("android.permission.FOREGROUND_SERVICE")
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)
AddPermission("android.permission.READ_CONTACTS")
AddPermission("android.permission.ANSWER_PHONE_CALLS")
AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>)
'End of default text.
may be something with permissions...