Hi everybody,
It's a bit weird: while the app is consuming all the time, the % of use is very low (see the images)
I can't figure it out where is my mistake
B4A v8.00, Android 8.1.0
There are only 3 services: Starter, habilitar_smsread and habilitar_push
The relevant code:
The Manifest:
It's a bit weird: while the app is consuming all the time, the % of use is very low (see the images)
I can't figure it out where is my mistake
B4A v8.00, Android 8.1.0
There are only 3 services: Starter, habilitar_smsread and habilitar_push
The relevant code:
B4X:
Starter
Service_Create
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
If IsPaused(habilitar_push) Then
StartService(habilitar_push)
End If
If IsPaused(habilitar_smsread) Then
StartService(habilitar_smsread)
End If
Service_Start
Sleep(0)
Service.StopAutomaticForeground
habilitar_smsread
Service_Create
GLO_NotificationSvc.Initialize
GLO_NotificationSvc.Icon = "icon"
GLO_NotificationSvc.Sound = False
GLO_NotificationSvc.SetInfo("Agendame.Turnos.Habilitar","activado!",Main)
Service.StartForeground(123456788,GLO_NotificationSvc)
Service_Start
If StartingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
Dim misSMSList As List
misSMSList = rtn_ParseSmsIntent(StartingIntent)
End If
Sleep(0)
Service.StopAutomaticForeground
habilitar_push
Service_Create
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
GLO_NotificationSvc.Initialize
GLO_NotificationSvc.Icon = "icon"
GLO_NotificationSvc.Sound = False
GLO_NotificationSvc.SetInfo("Agendame.Turnos.Habilitar","activado!",Main)
Service.StartForeground(123456788,GLO_NotificationSvc)
Service_Start
Select StartingIntent.Action
Case "com.google.android.c2dm.intent.REGISTRATION"
HandleRegistrationResult(StartingIntent)
Case "com.google.android.c2dm.intent.RECEIVE"
ProcesarPushRecibido(StartingIntent)
End Select
Sleep(0)
Service.StopAutomaticForeground
The Manifest:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddApplicationText(<activity android:name="de.amberhome.objects.preferenceactivity"/>)
AddPermission(android.permission.RECEIVE_SMS)
AddPermission(android.permission.SEND_SMS)
AddReceiverText(habilitar_smsread,
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)
AddPermission(android.permission.READ_CONTACTS)
AddPermission(android.permission.WRITE_CONTACTS)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
'C2DM Permissions
AddManifestText(<permission android:name="$PACKAGE$.permission.C2D_MESSAGE" android:protectionLevel="signature" />)
AddPermission($PACKAGE$.permission.C2D_MESSAGE)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
' Push Service Receiver Attribute
SetReceiverAttribute(habilitar_push, android:permission, "com.google.android.c2dm.permission.SEND")
' Service Receiver Text
AddReceiverText(habilitar_push,
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="$PACKAGE$" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="$PACKAGE$" />
</intent-filter>)
CreateResourceFromFile(Macro, Themes.DarkTheme)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddApplicationText(
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="$PACKAGE$.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
)
CreateResource(xml, provider_paths,
<external-files-path name="name" path="shared" />
)
AddPermission(android.permission.GET_ACCOUNTS)
AddPermission(android.permission.READ_PHONE_STATE)