Updating the Android SDK

Recently we improved significantly the Android SDK integration process. Although the new method of integration is much simpler, if you currently are using a version older than this and are wishing to update, there are a few changes that you will have to make.



Note: This only applies to you if you are using Android Studio or another Gradle build system

The Xtremepush AAR is now distributed from a Maven repository. 

The steps you implement to get inline with the new behaviour are:

  1. Delete the old XPush.aar from your libs folder
  2. In your apps build.gradle file add the Xtremepush Maven repository
    repositories {
        maven {
            url 'http://maven.xtremepush.com/artifactory/libs-release-local/'
  3.  Add the XtremePush library to the dependencies section as shown below:
    compile 'ie.imobile.extremepush:XtremePush_lib:5.0.0'



Note: This only applies to you if you are using Android Studio or another Gradle build system

The XPush SDK now comes with a self contained manifest which contains all the required classes and permissions. So in your own app manifest you need to remove all the Xtremepush entries. 


Application Integration

The XPush integration process was also simplified by moving away from requiring a PushConnector object in every Activity, and instead centralising the process in the Application class of the app. 

To update to this new behaviour, the steps you must implement are as follows:

  1. Remove the XPush lifecycle callbacks from each Activity.
  2. Remove the PushConnector creation from each Activity.
  3. In your Application.java file import the following
    import ie.imobile.extremepush.PushConnector;
  4. In the onCreate method of your Application.java class, add the following
    public class YOUR_APPLICATION extends Application {
        public void onCreate() {
            new PushConnector.Builder(XPUSH_APP_KEY, GOOGLE_PROJECT_NUMBER)

Static PushConnector Object

Now the Xtremepush function calls can be made through a single static instance of PushConnector called mPushConnector. Some examples of using this object are shown below.



Callback  Changes

The PushListener Interface for custom notification handling has been deprecated. It has been replaced by the MessageResponseListener Interface. The advantages of this new interface is that it allows for greater control over handling messages, and works with inbox messages, inapp messages, and notifications.

To use this new functionality your Application.java class should implement MessageResponseListener, and it should be referenced when instantiating. An example is shown below.

public class YOUR_APPLICATION extends Application implements MessageResponseListener {

    public void onCreate() {
        new PushConnector.Builder(XPUSH_APP_KEY, GOOGLE_PROJECT_NUMBER)

    public void messageResponseReceived(Message messagePayload, HashMap<String, String> responsePayload, WeakReference uiReference) {


More information and examples can be found here


Foreground Notification handling

On previous versions, when the app was in the foreground it could be handled immediately using the setImmediatePushProcessing flag in the PushConnector builder. This method has been deprecated. Now we have added a PushConnectorBuilder method called setShowForegroundNotification to set the default behaviour for showing or not showing a notification when the app is in the foreground. 



When a push message is delivered to the device, the messageResponseReceived callback will be triggered, and it can be handled on a per message basis. 

More information and examples can be found here.




Have more questions? Submit a request


Please sign in to leave a comment.