Android Open Source - SmartNotify App Updated Broadcast Receiver






From Project

Back to project page SmartNotify.

License

The source code is released under:

Copyright (c) 2014, Sergey Parshin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project SmartNotify 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.github.quarck.smartnotify;
/* ww  w.ja v  a  2s .co  m*/
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class AppUpdatedBroadcastReceiver extends BroadcastReceiver
{
  @Override
  public void onReceive(final Context context, final Intent intent)
  {
    // after each update we are loosing permission to get notifications,
    // so service actually gets disabled, update settings to reflect this and 
    // then - ask user to re-enable permission for us    
    new Settings(context).setServiceEnabled(false);
    
    Intent mainActivityIntent = new Intent(context, MainActivity.class);
    PendingIntent pendingMainActivityIntent = PendingIntent.getActivity(context, 0, mainActivityIntent, 0);

    Notification notification = new Notification.Builder(context)
      .setContentTitle(context.getString(R.string.app_updated))
      .setContentText(context.getString(R.string.reenable_app))
      .setSmallIcon(R.drawable.ic_launcher)
      .setPriority(Notification.PRIORITY_HIGH)
      .setContentIntent(pendingMainActivityIntent)
      .setAutoCancel(true)
      .build();
  
    ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
      .notify(Consts.notificationIdUpdated, notification); // would update if already exists
  }
}




Java Source Code List

com.github.quarck.smartnotify.Alarm.java
com.github.quarck.smartnotify.AppUpdatedBroadcastReceiver.java
com.github.quarck.smartnotify.CallStateTracker.java
com.github.quarck.smartnotify.CommonAppsRegistry.java
com.github.quarck.smartnotify.Consts.java
com.github.quarck.smartnotify.EditApplicationsActivity.java
com.github.quarck.smartnotify.GlobalState.java
com.github.quarck.smartnotify.InitialPopulate.java
com.github.quarck.smartnotify.Lw.java
com.github.quarck.smartnotify.MainActivity.java
com.github.quarck.smartnotify.NotificationReceiverService.java
com.github.quarck.smartnotify.OngoingNotificationManager.java
com.github.quarck.smartnotify.PackageSettings.java
com.github.quarck.smartnotify.ServiceClient.java
com.github.quarck.smartnotify.SettingsActivity.java
com.github.quarck.smartnotify.Settings.java
com.github.quarck.smartnotify.SilentPeriodManager.java
com.github.quarck.smartnotify.ToggleMuteBroadcastReceiver.java
com.github.quarck.smartnotify.prefs.TimePickerPreference.java
com.github.quarck.smartnotify.prefs.VibrationPatternPreference.java