Android Open Source - fco-alerts-app Notification Forward Receiver






From Project

Back to project page fco-alerts-app.

License

The source code is released under:

MIT License

If you think the Android project fco-alerts-app 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 uk.co.eleusis.android.fcoalerts;
/*w w w.j av a 2s  .  c o m*/
import uk.co.eleusis.android.util.DebugUtils;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * Very simple receiver - when a user clicks on a notification with only a single
 * alert, we forward them straight to the corresponding URL.
 * 
 * However, if we do it right from the notification, we won't clear the alert from
 * the store, so we have to do that as well here first, before forwarding them on.
 * 
 * @author keithm
 *
 */
public class NotificationForwardReceiver extends BroadcastReceiver
{
    private static final String TAG = "NotificationDeleteReceiver";

    @Override
    public void onReceive(Context context, Intent intent)
    {
        // first off, just check that we got here
        Log.d(TAG, "received forward-notif intent: ");
        DebugUtils.printIntent(intent);

        // delete the notification:
        new NotificationStore(context).removeAllNotifications();
        
        // now forward.. 
        Intent forwardIntent;
        if (intent.getData() != null)
        {
            Log.d(TAG, "Got data URI, forwarding to URL..");
            forwardIntent = new Intent(Intent.ACTION_VIEW, intent.getData());
        }
        else
        {
            Log.d(TAG, "No data URI, back to MainActivity..");
            forwardIntent = new Intent(context, MainActivity.class);
        }
        
        forwardIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        forwardIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 

        context.startActivity(forwardIntent);
    }

}




Java Source Code List

uk.co.eleusis.android.fcoalerts.Constants.java
uk.co.eleusis.android.fcoalerts.CountryPrefs.java
uk.co.eleusis.android.fcoalerts.GCMRegistration.java
uk.co.eleusis.android.fcoalerts.GcmBroadcastReceiver.java
uk.co.eleusis.android.fcoalerts.GcmIntentService.java
uk.co.eleusis.android.fcoalerts.MainActivity.java
uk.co.eleusis.android.fcoalerts.NotificationDeleteReceiver.java
uk.co.eleusis.android.fcoalerts.NotificationForwardReceiver.java
uk.co.eleusis.android.fcoalerts.NotificationStore.java
uk.co.eleusis.android.fcoalerts.NotifiedAlert.java
uk.co.eleusis.android.fcoalerts.Notifier.java
uk.co.eleusis.android.fcoalerts.RegidChangeListener.java
uk.co.eleusis.android.fcoalerts.ServerComms.java
uk.co.eleusis.android.fcoalerts.SettingsDisplay.java