We are trying to instantiate the Exact Target push service on Android, with the call ETPush.readyAimFire, in an Activity class instead of the Application one. We want to use as an Activity class instead of an Application one as we are thinking of possible integrations with clients that are using a framework that doesn't provide a way to extend the Application class.

We tried to implement it, and it works perfectly if you have the application running, but once you close it, the push notification is not shown. We can in the logs that we receive the message (GCM message com.testsalesforce 0:1424704288668625%f408837ef9fd7ecd), but we cannot see the logs for the broadcast receiver handling the notification.

Urban Airship has a class for this type of situation, you can see it's documentation here: http://docs.urbanairship.com/reference/libraries/android/latest/reference/com/urbanairship/Autopilot.html

We appreciate any information/help anyone can give us.


2 Answers 2


The SDK requires an Application Class as the context in readyAimFire().

We completed additional testing of this scenario, and have found that you cannot call readyAimFire() within an Activity class, even if you pass in activity.getApplicationClass(). You must call readyAimFire() from the Application class.

This is because the application class will be instantiated for background work (eg. receivers) and if you have readyAimFire() in the activity class, Android will be unable to instantiate the SDK to process the work required in these receivers.

  • Hi Peter, thanks for your quick response. We have run through our code again this morning and are sure we are only calling the method readyAimFire once, when the application starts. We have tried getting the Application context, and instantiating the service with it, and we encounter the same behaviour, we receive the notification if the application is opened, but the notification doesn't get handled if the application is closed. Do you have an example app we can look at that uses this approach? Is this an issue you have come across before? Any help would be greatly appreciated. Thanks Commented Feb 26, 2015 at 10:24
  • Yes, there is a sample app: SDK Explorer. I also recommend turning debug on. ETPush.setLogLevel(Log.DEBUG). If you are unable to determine the problem from these, then we would need to see your AndroidManifest.xml file and possible other files. Do you have a support agreement? If so, contacting them would provide additional help and support. Commented Feb 26, 2015 at 12:38
  • Hi Peter, replied in the answer below because of the character limit on the comment. Can you review and advise what we should try next. Many thanks Commented Feb 27, 2015 at 15:59
  • Isabella, sorry for late reply. However, before we go further, can you let me know what you mean that you're not receiving notifications when you "close the app"? If you close the app via Settings (ie. stop app), then all background processing stops for that app. This is a security feature of Android. Or did you mean when the app is in the background? Commented Mar 6, 2015 at 15:48
  • Hi Peter, our tests were run with the app (services) running in the background. We would expect to see the notification in this instance. Can you think of any reason why this may not be happening? We can see the notification when we use the application class but not when we use a activity class to instantiate it. Thanks Commented Mar 9, 2015 at 15:16

Thanks for your answer. But we have already looked at the sample app and in that case you instantiate the push in the application class and this does not apply to our case. As for the logs we already have the debug turned on so that is how we know your broadcast receiver is not handling the message.

As requested here is our manifest file. Please let us know if there is anything in this we need to address:

  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
  <uses-permission android:name="android.permission.WAKE_LOCK"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.VIBRATE"/>
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  <permission android:name="${packageName}.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
  <uses-permission android:name="${packageName}.permission.C2D_MESSAGE"/>
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
  <uses-permission android:name="android.permission.GET_ACCOUNTS"/>


      android:value="@integer/google_play_services_version" />

        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>

        <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
        <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
        <category android:name="${packageName}"/>

    <receiver android:name="com.exacttarget.etpushsdk.ETSendDataReceiver"/>

        <action android:name="${packageName}.MESSAGE_OPENED" />

    <service android:name="com.exacttarget.etpushsdk.ETSendDataIntentService"/>



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .