Android Question Firebase - Service MeasurementBrokerService

gravel

Member
Licensed User
Longtime User
I'm using Firebase notifications and saw that the service MeasurementBrokerService was appearing as a running service with my App, adding a big chunk to it's apparent memory usage (on a 4.4.4 device and a 6.01 device).

See also this Stackoverflow post http://stackoverflow.com/questions/...rservice-and-how-to-stop-it/42162155#42162155

I've changed the manifest text to:
B4X:
'************ Firebase Base ************
CreateResourceFromFile("google-services", "google-services.json")
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
AddManifestText( <permission android:name="${applicationId}.permission.C2D_MESSAGE"
  android:protectionLevel="signature" />)
AddApplicationText(
<receiver
  android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
  android:enabled="false">
  <intent-filter>
  <action android:name="com.google.android.gms.measurement.UPLOAD"/>
  </intent-filter>
  </receiver>

  <service
  android:name="com.google.android.gms.measurement.AppMeasurementService"
  android:enabled="false"
  android:exported="false"/>
   <provider
  android:authorities="${applicationId}.firebaseinitprovider"
  android:name="com.google.firebase.provider.FirebaseInitProvider"
  android:exported="false"
  android:initOrder="100" />
    <receiver
  android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
  android:enabled="false">
  <intent-filter>
  <action android:name="com.google.android.gms.measurement.UPLOAD"/>
  </intent-filter>
  </receiver>

  <service
  android:name="com.google.android.gms.measurement.AppMeasurementService"
  android:enabled="false"
  android:exported="false"/>
   <receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
  android:exported="true"
  android:permission="com.google.android.c2dm.permission.SEND" >
  <intent-filter>
  <action android:name="com.google.android.c2dm.intent.RECEIVE" />
  <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
  <category android:name="${applicationId}" />
  </intent-filter>
  </receiver>
    <receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
  android:exported="false" />


  <service
  android:name="com.google.firebase.iid.FirebaseInstanceIdService"
  android:exported="true">
  <intent-filter android:priority="-500">
  <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
  </intent-filter>
  </service>
)
'************ Firebase Base (end) ************

and the analytics bit in the .json reads

B4X:
      "services": {
        "analytics_service": {
          "status": 2
        },

This seems to have stopped the service being attached to the app and everything seems to be working OK.

But does anyone forsee a problem from the changes that I've made?
 

gravel

Member
Licensed User
Longtime User
I spoke to soon, after the app has been running for a while the service has now reappeared.

Any suggestions how to stop this service?
 
Upvote 0

gravel

Member
Licensed User
Longtime User
Thanks, but that doesn't seem to stop it reappearing as soon as you interact with the App.

This https://developers.google.com/analytics/devguides/collection/android/v4/advanced refers to an App level opt-out.


Might this do the trick, how would I set the flag?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…