I'm doing the Android integration, what Activity should I start with and how do I make methods available throughout my app?

You find many types of application structures on Android but probably the most common patterns we see is apps with a BaseActivity. If you have an activity like a  MenuActivity in your application that all others extend from then the integration can be done there and your PushConnector variable will be available throughout your app and you can just call the methods like hit event as documented in your other activities:

//Tagging FAQ screen opening code
mPushConnector.hitEvent(this, "screen.faq.opened", "");  
If this is not a runner then you can just create a new BaseActivity where the integration is done and then have MenuActivity and all other activities extend BaseActivity. BaseActivity would basically be a shell activity that houses the integration like below:

import ie.imobile.extremepush.*;

public class BaseActivity extends Activity {

    public PushConnector mPushConnector;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

/* INITIALISE THE XTREMEPUSH CONNECTOR HERE
Include whatever options you are between ,Builder and .createe
if you are using location services for example include
.setEnableLocations(true)
*/
mPushConnector = new PushConnector.Builder("XTREME_PUSH_APP_KEY", "GOOGLE_PROJECT_NUMBER")
.create(this);


}

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//xtremepush onActivityResult Callback
mPushConnector.onActivityResult(requestCode, resultCode, data);
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
//xtremepush onNewIntent Callback
mPushConnector.onNewIntent(intent);
}

@Override
protected void onStart() {
super.onStart();
//xtremepush onStart Callback
mPushConnector.onStart(this);
}

@Override
protected void onResume() {
super.onResume();
//xtremepush onResume Callback
mPushConnector.onResume(this);
}

@Override
protected void onPause() {
super.onPause();
//xtremepush onPause Callback
mPushConnector.onPause(this);
}

@Override
protected void onStop() {
super.onStop();
//xtremepush onStop Callback
mPushConnector.onStop(this);
}

@Override
protected void onDestroy() {
super.onDestroy();
//xtremepush onDestroy Callback
mPushConnector.onDestroy(this);
}

}
Have more questions? Submit a request

0 Comments

Article is closed for comments.