onPushMessageReceived() not called in Android app.
  • I used Geoloqi API in android app. I created trigger by sending lat,long,radius.To notify user i used C2DM Push Notification.I created a class implementing 
    LQBroadcastReceiver.Three methods are calling but onPushMessageReceived() method is not called.please help.i given all permissions in manifest file

    Main Activity class:
    public class GeoloqiExampleActivity extends Activity{
    String TAG = "Geoloqi Example";
    private LQService mService;
    private boolean mBound;
    GeoReceiver geoReceiver = new GeoReceiver();
        public void onCreate(Bundle savedInstanceState) {
            Intent intent = new Intent(this, LQService.class);
            intent.putExtra(LQService.EXTRA_SDK_ID, Constants.LQ_SDK_ID);
            intent.putExtra(LQService.EXTRA_SDK_SECRET, Constants.LQ_SDK_SECRET);
            intent.putExtra(LQService.EXTRA_C2DM_SENDER, Constants.LQ_C2DM_SENDER);
        public void onResume() {
            // Bind to the tracking service so we can call public methods on it
            Intent intent = new Intent(this, LQService.class);
            bindService(intent, mConnection, 0);
            // Wire up the sample location receiver
            final IntentFilter filter = new IntentFilter();
            registerReceiver(geoReceiver, filter);
        public void onPause() {
            // Unbind from LQService
            if (mBound) {
                mBound = false;
            // Unregister our location receiver
        public void sendRequest() {
        // Performing a Trigger POST request
            if (mService != null) {
            //Toast.makeText(this, "Service Avaialble", Toast.LENGTH_LONG).show();
                LQSession session = mService.getSession();
                // Build your request
                JSONObject trigger = new JSONObject();
                try {
                    trigger.put("text", "Popcornapps");
                    trigger.put("type", "message");
                    trigger.put("latitude", 17.42557068);
                    trigger.put("longitude",  78.42022822);
                    trigger.put("radius", 1000);
                    trigger.put("place_name", "Banjara Hills");
                } catch (JSONException e) {
                   Log.d(TAG, e.getMessage());
                // Send the request
                session.runPostRequest("trigger/create", trigger, new OnRunApiRequestListener() {
                    public void onSuccess(LQSession session, HttpResponse response) {
                        Toast.makeText(GeoloqiExampleActivity.this, "Success", Toast.LENGTH_LONG).show();
                        try {
    BufferedReader reader=new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
       StringBuilder s = new StringBuilder();
       String sResponse;
    while ((sResponse = reader.readLine()) != null) {
    s = s.append(sResponse);
    String result = s.toString().trim();
    Log.d("On success Result", result);
                        } catch (UnsupportedEncodingException e) {
    } catch (IllegalStateException e) {
    } catch (IOException e) {
                    public void onFailure(LQSession session, LQException e) {
                        Log.e(TAG, e.getMessage());
                        Toast.makeText(GeoloqiExampleActivity.this, "Fail", Toast.LENGTH_LONG).show();
                    public void onComplete(LQSession session, HttpResponse response, StatusLine status) {
                    Toast.makeText(GeoloqiExampleActivity.this, "Complete", Toast.LENGTH_LONG).show();
            } else{
              Toast.makeText(this, "service null", Toast.LENGTH_LONG).show();

    /** Defines callbacks for service binding, passed to bindService() */
        private ServiceConnection mConnection = new ServiceConnection() {
            public void onServiceConnected(ComponentName name, IBinder service) {
                try {
                    // We've bound to LocalService, cast the IBinder and get LocalService instance.
                    LQBinder binder = (LQBinder) service;
                    mService = binder.getService();
                    mBound = true;
                    sendRequest();//Sending API Request
                } catch (ClassCastException e) {

            public void onServiceDisconnected(ComponentName name) {
                mBound = false;

  • 13 Comments sorted by
  • Hey, there's a bug in the currently posted version of the Android SDK that causes onPushMessageReceived to not be called. I have a fix for it in the upstream version of the SDK. I should be pushing that out today or tomorrow with some additional changes. Hold tight!
  • Hey thanks for your patience! We've updated the SDK and the sample app! You can check out the changes here:



    Let us know if you have any questions.

  • Thanks Tristan,
                         I tried new SDk but its saying Unable resolve this variables 
    3.EXTRA_C2DM_SENDER in LQService class(Added to Build Path also).
    please check it...
  • We made some changes to how the service is initialized, hopefully to make it easier. Please read the new credentials section of the readme and let me know if you have any more questions:


    Essentially you need to copy the geoloqi.properties.sample file into /assets/geoloqi.properties and update it with your API key and secret. You can then remove the extras you were passing to the service.
  • Hi Triston, 
              I ve used latest Geoloqi APi still onPushMessageReceived() method is not called. To view my code please refer following URL:
    Even i ve configured Android push notifications in my account.
    I am creating trigger with current location is it required to enter into region manually or since i am already in the location its not calling?
  • If you're already in the region the trigger will most likely not fire. You'd have to exit the trigger region and re-enter. You can test push messaging directly by using the ID of the user authenticated on the device and the send/message API endpoint:


    Here is an example using curl from the command-line:


    The easiest way to get the current user_id is by calling this in your Android code:


  • Also, what sender account are you using? You should have specified one in your geoloqi.properties file. You need to make sure you've followed the Google sign-up process for C2DM:

  • I ve tested with http://developers.geoloqi.com/api/message/send then its working but i ve to test with trigger/create..
  • Great! The way we test triggers in the office is to set up a route of two or three triggers. Then we go for a walk or a bike ride.

    Let us know if you continue to have trouble getting the trigger to fire.
  • Ok,one request: current documentation is very brief even given example(in github) also.please provide detail documentation with examples so understanding, developing with geoloqi API will be easier...thanks ...
  • We're working hard to improve our documentation and definitely value your feedback! Can you list the pages of documentation you consulted before posting here? A list of URLs would be helpful.

    EDIT: I've updated our Android push messaging documentation. Hopefully it's easier to understand now! Let us know if you have any more feedback:

  • I found difficulty in  http://developers.geoloqi.com/android/getting-started entire document because only small snippets are there but where to place not given means code flow is missing.for example in page http://developers.geoloqi.com/android/making-api-requests how to make requests is given but when activity is launched session object is null since object is creating in onResume() method. even in sample project also(github) if you want u can check it...so please provide documentation with proper examples.....thanks..
  • Great feedback. We'll take that into account when we're revising those tutorials. Thanks!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion