use of android.app.NotificationManager in project XPrivacy by M66B.
the class PrivacyService method notifyException.
private void notifyException(Throwable ex) {
Util.bug(null, ex);
if (mNotified)
return;
Context context = getContext();
if (context == null)
return;
try {
Intent intent = new Intent("biz.bokhorst.xprivacy.action.EXCEPTION");
intent.putExtra("Message", ex.toString());
context.sendBroadcast(intent);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// Build notification
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
notificationBuilder.setSmallIcon(R.drawable.ic_launcher);
notificationBuilder.setContentTitle(context.getString(R.string.app_name));
notificationBuilder.setContentText(ex.toString());
notificationBuilder.setWhen(System.currentTimeMillis());
notificationBuilder.setAutoCancel(true);
Notification notification = notificationBuilder.build();
// Display notification
notificationManager.notify(Util.NOTIFY_CORRUPT, notification);
mNotified = true;
} catch (Throwable exex) {
Util.bug(null, exex);
}
}
use of android.app.NotificationManager in project XPrivacy by M66B.
the class BootReceiver method onReceive.
@Override
public void onReceive(final Context context, Intent bootIntent) {
// Start boot update
Intent changeIntent = new Intent();
changeIntent.setClass(context, UpdateService.class);
changeIntent.putExtra(UpdateService.cAction, UpdateService.cActionBoot);
context.startService(changeIntent);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// Check if Xposed enabled
if (Util.isXposedEnabled() && PrivacyService.checkClient())
try {
if (PrivacyService.getClient().databaseCorrupt()) {
// Build notification
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
notificationBuilder.setSmallIcon(R.drawable.ic_launcher);
notificationBuilder.setContentTitle(context.getString(R.string.app_name));
notificationBuilder.setContentText(context.getString(R.string.msg_corrupt));
notificationBuilder.setWhen(System.currentTimeMillis());
notificationBuilder.setAutoCancel(true);
Notification notification = notificationBuilder.build();
// Display notification
notificationManager.notify(Util.NOTIFY_CORRUPT, notification);
} else
context.sendBroadcast(new Intent("biz.bokhorst.xprivacy.action.ACTIVE"));
} catch (Throwable ex) {
Util.bug(null, ex);
}
else {
// Create Xposed installer intent
// @formatter:off
Intent xInstallerIntent = new Intent("de.robv.android.xposed.installer.OPEN_SECTION").setPackage("de.robv.android.xposed.installer").putExtra("section", "modules").putExtra("module", context.getPackageName()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// @formatter:on
PendingIntent pi = (xInstallerIntent == null ? null : PendingIntent.getActivity(context, 0, xInstallerIntent, PendingIntent.FLAG_UPDATE_CURRENT));
// Build notification
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
notificationBuilder.setSmallIcon(R.drawable.ic_launcher);
notificationBuilder.setContentTitle(context.getString(R.string.app_name));
notificationBuilder.setContentText(context.getString(R.string.app_notenabled));
notificationBuilder.setWhen(System.currentTimeMillis());
notificationBuilder.setAutoCancel(true);
if (pi != null)
notificationBuilder.setContentIntent(pi);
Notification notification = notificationBuilder.build();
// Display notification
notificationManager.notify(Util.NOTIFY_NOTXPOSED, notification);
}
}
use of android.app.NotificationManager in project Xposed-Tinted-Status-Bar by MohammadAG.
the class OnWindowFocusedHook method afterHookedMethod.
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mSettingsHelper.reload();
if (!mSettingsHelper.getBoolean(SettingsKeys.ENABLE_AWESOME_AB_COLOR_PICKER, false))
return;
Activity activity = (Activity) param.thisObject;
String packageName = activity.getPackageName();
String activityName = activity.getLocalClassName();
final TypedArray typedArray = activity.obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
int actionBarSize = (int) typedArray.getDimension(0, 0);
typedArray.recycle();
// Get the top of the window, so we can crop the status bar out.
Rect rect = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
int top = rect.top;
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
Bitmap bitmap1 = view.getDrawingCache();
if (bitmap1 == null)
return;
// Crop and compress the image so that we don't get a TransactionTooLargeException.
Bitmap bitmap = Bitmap.createBitmap(bitmap1, 0, top, bitmap1.getWidth(), actionBarSize);
ByteArrayOutputStream compressedBitmap = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, compressedBitmap);
ComponentName cn = new ComponentName("com.mohammadag.colouredstatusbar", "com.mohammadag.colouredstatusbar.activities.ScreenColorPickerActivity");
Intent colorPickerIntent = new Intent().setComponent(cn);
colorPickerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
colorPickerIntent.putExtra("bitmap", compressedBitmap.toByteArray());
colorPickerIntent.putExtra("pkg", packageName);
PendingIntent colorActivityPendingIntent = PendingIntent.getActivity(activity, 0, colorPickerIntent.putExtra("title", activityName), PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent colorAllPendingIntent = PendingIntent.getActivity(activity, 1, colorPickerIntent.putExtra("title", packageName), PendingIntent.FLAG_UPDATE_CURRENT);
NotificationManager nm = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new NotificationCompat.Builder(activity).setContentTitle(packageName).setContentText(activityName).setSmallIcon(android.R.drawable.sym_def_app_icon).setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap)).addAction(android.R.drawable.ic_menu_add, mResources.getString(R.string.notification_add_activity), colorActivityPendingIntent).addAction(android.R.drawable.ic_menu_add, mResources.getString(R.string.notification_add_app), colorAllPendingIntent).build();
nm.notify(1240, notification);
view.setDrawingCacheEnabled(false);
}
use of android.app.NotificationManager in project Signal-Android by WhisperSystems.
the class GcmRefreshJob method notifyGcmFailure.
private void notifyGcmFailure() {
Intent intent = new Intent(context, PlayServicesProblemActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 1122, intent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(R.drawable.icon_notification);
builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_action_warning_red));
builder.setContentTitle(context.getString(R.string.GcmRefreshJob_Permanent_Signal_communication_failure));
builder.setContentText(context.getString(R.string.GcmRefreshJob_Signal_was_unable_to_register_with_Google_Play_Services));
builder.setTicker(context.getString(R.string.GcmRefreshJob_Permanent_Signal_communication_failure));
builder.setVibrate(new long[] { 0, 1000 });
builder.setContentIntent(pendingIntent);
((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(12, builder.build());
}
use of android.app.NotificationManager in project Signal-Android by WhisperSystems.
the class RegistrationNotifier method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(R.drawable.icon_notification);
builder.setContentTitle(intent.getStringExtra(RegistrationService.NOTIFICATION_TITLE));
builder.setContentText(intent.getStringExtra(RegistrationService.NOTIFICATION_TEXT));
builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0));
builder.setWhen(System.currentTimeMillis());
builder.setDefaults(Notification.DEFAULT_VIBRATE);
builder.setAutoCancel(true);
Notification notification = builder.build();
((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(31337, notification);
}
Aggregations