Android Open Source - terapush-android-sdk Message Reciever






From Project

Back to project page terapush-android-sdk.

License

The source code is released under:

Your use is subject to the Terms & Conditions at https://app.terapush.com/docs/End-User-License-Agreement.html

If you think the Android project terapush-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.terapush.samples;
//from   w  ww  .  ja  v  a  2s  .c  om
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class MessageReciever extends BroadcastReceiver 
{
  @Override
  public void onReceive(Context context, Intent intent) {
    
    /**
     * We want to open our MainActivity when the notification is clicked, So we are
     * creating a new intent
     */
    Intent i = new Intent(context, MainActivity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    i.setPackage(null);

    /**
     * Is there a landing page value for this notification? if so send it to our 
     * activity
     */
    if(intent.getExtras().getString("LandingPage") != null)
    {
      i.putExtra("LandingPage", intent.getExtras().getString("LandingPage"));
    }
    
    /**
     * Just like the LandingPage parameter, we can receive other custom parameters
     * and send them to our activity
     *
     * if(intent.getExtras().getString("AnyParameter") != null)
     * {
     *    i.putExtra("AnyParameter", intent.getExtras().getString("AnyParameter"));
     * }
     */
    
    context.startActivity(i);
  }
}




Java Source Code List

com.terapush.samples.MainActivity.java
com.terapush.samples.MessageReciever.java