private void newDialog() { try { AlertDialog.Builder whats_new = new AlertDialog.Builder(MainActivity.this); whats_new.setTitle(getResources().getString(R.string.what_new)); //noinspection deprecation whats_new.setMessage(Html.fromHtml(getResources().getString(R.string.about_new))); whats_new.setPositiveButton(getResources().getString(R.string.great), null); whats_new.setNegativeButton(getString(R.string.like_on), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = "https://m.facebook.com/sunshineappsst/"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); whats_new.show(); } catch (Exception ignored) { } }
public Notification getPersistentNotification() { PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context, 0, new Intent(INTENT_ACTION_LAUNCH_SHADE), 0); RemoteViews content = new RemoteViews(BuildConfig.APPLICATION_ID, R.layout.persistent_notification); String notificationTitle = this.context.getResources().getString(R.string.persistent_notification_title); String notificationContent = this.context.getResources().getString(R.string.persistent_notification_text); int priority = Integer.MIN_VALUE; int smallIconId = 17170445; long when = Long.MIN_VALUE; if (this.hasPendingMessages) { notificationContent = this.context.getResources().getString(R.string.persistent_notification_with_messages_text); if (VERSION.SDK_INT <= 19) { priority = 1; } if (!(this.lockScreenManager.isPhoneLocked() || this.lockScreenManager.isScreenOff())) { when = System.currentTimeMillis(); priority = 1; } smallIconId = R.drawable.ic_notification_small; } priority=Notification.PRIORITY_MIN; // builder.setPriority(Notification.PRIORITY_MIN); content.setTextViewText(R.id.notification_title_textview, notificationTitle); content.setTextViewText(R.id.notification_content_textview, notificationContent); return new Builder(this.context).setPriority(priority).setContentIntent(pendingIntent).setSmallIcon(smallIconId).setContent(content).setWhen(when).setOngoing(true).build(); }
@SuppressLint("ResourceType") public void showPermissionNotification() { PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context, 0, new Intent( INTENT_ACTION_OPEN_PERMISSIONS), 0); String title = this.context.getResources().getString(R.string.permissions_notification_title); ((android.app.NotificationManager) this.context.getSystemService(Context.NOTIFICATION_SERVICE)) .notify( 2, new Builder(this.context) .setSmallIcon(17301543) .setContentTitle(title) .setContentText( this.context.getResources().getString(R.string.permissions_notification_text)) .setContentIntent(pendingIntent).setOngoing(true).setPriority(1).build()); // PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context, 0, new Intent(INTENT_ACTION_OPEN_PERMISSIONS), 0); // String title = this.context.getResources().getString(R.string.permissions_notification_title); // ((NotificationManager) this.context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(2, new Builder(this.context).setSmallIcon(17301543).setContentTitle(title).setContentText(this.context.getResources().getString(R.string.permissions_notification_text)).setContentIntent(pendingIntent).setOngoing(true).setPriority(1).build()); }
static /* synthetic */ void a(DownloadService downloadService, int i, c cVar, int i2) { if (i2 != 0 && !cVar.e()) { Object obj; int i3 = 4; if (2 == i2) { obj = z[20]; } else if (3 == i2) { obj = z[18]; } else if (1 == i2) { String str = z[19]; i3 = 2; } else { return; } Object obj2 = cVar.s; Intent intent = new Intent(); if (b.a(i2)) { intent.setClass(downloadService.getApplicationContext(), DownloadService.class); cVar.z = -1; intent.putExtra(z[17], cVar); } PendingIntent service = PendingIntent.getService(downloadService, i, intent, 134217728); if (VERSION.SDK_INT >= 11) { new Builder(downloadService.getApplicationContext()).setContentTitle(obj2).setContentText(obj).setContentIntent(service).setWhen(System.currentTimeMillis()).setSmallIcon(17301634).getNotification().flags = i3; } else { Notification notification = new Notification(); notification.icon = 17301634; notification.when = System.currentTimeMillis(); notification.flags = i3; m.a(notification, downloadService.getApplicationContext(), obj2, obj, service); } if (downloadService.f != null) { downloadService.c.notify(i, downloadService.f); } } }
public void setNotification(AlarmTip alarmTip, Intent intent) { Helper.showLog(TAG, "发送Notification " + alarmTip.id + SocializeConstants.OP_DIVIDER_MINUS + alarmTip.code + SocializeConstants.OP_DIVIDER_MINUS + alarmTip.name + SocializeConstants.OP_DIVIDER_MINUS + alarmTip.message); PendingIntent pendingIntent = PendingIntent.getActivity(this.ctx, 0, intent, 268435456); NotificationManager nfcManager = (NotificationManager) this.ctx.getSystemService ("notification"); String title = this.ctx.getString(R.string.dl); Builder builder = new Builder(this.ctx); builder.setAutoCancel(false); builder.setTicker(title); builder.setContentTitle(title); builder.setContentText(alarmTip.message); builder.setSmallIcon(R.drawable.ja); builder.setContentIntent(pendingIntent); builder.setAutoCancel(true); nfcManager.notify(this.noticeType, builder.getNotification()); }
private Builder addActionResume(Builder builder) { Intent pauseIntent = new Intent(getApplicationContext(), this.getClass()); pauseIntent.setAction(ACTION_RESUME); PendingIntent pausePendingIntent = PendingIntent.getService(getApplicationContext(), 0, pauseIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationBuilderCompatHelper.addAction(builder, getNotificationResources().getResumeActionIcon(), getString(getNotificationResources().getResumeActionText()), pausePendingIntent); return builder; }
private Notification getNotification() { String message = "Listening for " + Arrays.toString(getResources().getStringArray(R.array.voiceaction_wakeupphrases)); String title = "Speech Activation"; PendingIntent pi = PendingIntent.getService(this, 0, makeServiceStopIntent(this), 0); Notification notification = null; if (VERSION.SDK_INT >= 11) { Builder builder = new Builder(this); builder.setSmallIcon(android.support.design.R.drawable.notification_template_icon_bg).setWhen(System .currentTimeMillis()).setTicker(message).setContentTitle(title).setContentText(message) .setContentIntent(pi); notification = builder.build(); } return notification; }
public static void addAction(Notification.Builder paramBuilder, NotificationCompatBase.Action paramAction) { Notification.Action.Builder localBuilder = new Notification.Action.Builder(paramAction.getIcon(), paramAction.getTitle(), paramAction.getActionIntent()); if (paramAction.getRemoteInputs() != null) { RemoteInput[] arrayOfRemoteInput = RemoteInputCompatApi20.fromCompat(paramAction.getRemoteInputs()); int i = arrayOfRemoteInput.length; for (int j = 0; j < i; j++) { localBuilder.addRemoteInput(arrayOfRemoteInput[j]); } } if (paramAction.getExtras() != null) { localBuilder.addExtras(paramAction.getExtras()); } paramBuilder.addAction(localBuilder.build()); }
public final Builder setStyle(NotificationCompat.Style paramStyle) { if (this.mStyle != paramStyle) { this.mStyle = paramStyle; if (this.mStyle != null) { NotificationCompat.Style localStyle = this.mStyle; if (localStyle.mBuilder != this) { localStyle.mBuilder = this; if (localStyle.mBuilder != null) { localStyle.mBuilder.setStyle(localStyle); } } } } return this; }
public final Notification build$ab8b522(NotificationCompat.Builder paramBuilder) { Notification localNotification = paramBuilder.mNotification; localNotification.setLatestEventInfo(paramBuilder.mContext, paramBuilder.mContentTitle, paramBuilder.mContentText, paramBuilder.mContentIntent); Context localContext = paramBuilder.mContext; CharSequence localCharSequence1 = paramBuilder.mContentTitle; CharSequence localCharSequence2 = paramBuilder.mContentText; PendingIntent localPendingIntent1 = paramBuilder.mContentIntent; PendingIntent localPendingIntent2 = paramBuilder.mFullScreenIntent; localNotification.setLatestEventInfo(localContext, localCharSequence1, localCharSequence2, localPendingIntent1); localNotification.fullScreenIntent = localPendingIntent2; if (paramBuilder.mPriority > 0) { localNotification.flags = (0x80 | localNotification.flags); } return localNotification; }
private static dkl a(Context paramContext, int paramInt1, int paramInt2, Cursor paramCursor, int paramInt3) { Resources localResources = paramContext.getResources(); String str1 = localResources.getQuantityString(efj.xG, paramInt2); String str2 = ((giz)mbb.a(paramContext, giz.class)).a(paramInt1).b("account_name"); int i = efj.xF; Object[] arrayOfObject = new Object[2]; arrayOfObject[0] = str2; arrayOfObject[1] = Integer.valueOf(paramInt2); String str3 = localResources.getQuantityString(i, paramInt2, arrayOfObject); Intent localIntent1 = b(paramContext, paramInt1, paramCursor); localIntent1.addFlags(335544320); localIntent1.putExtra("com.google.android.libraries.social.notifications.FROM_ANDROID_NOTIFICATION", true); Intent localIntent2 = dmr.a(paramContext, paramInt1, localIntent1); PendingIntent localPendingIntent1 = PendingIntent.getActivity(paramContext, dmr.a(), localIntent2, 0); PendingIntent localPendingIntent2 = a(paramContext, paramInt1, paramCursor, "AST"); Notification localNotification = new Notification.Builder(paramContext).setSmallIcon(a(paramInt3)).setContentTitle(str1).setContentText(str3).setTicker(str1).setWhen(System.currentTimeMillis()).setContentIntent(localPendingIntent1).setDeleteIntent(localPendingIntent2).getNotification(); if (Build.VERSION.SDK_INT >= 21) {} for (int j = 1;; j = 0) { if (j != 0) { localNotification.color = localResources.getColor(efj.jY); } return new dkl(localNotification, false); } }
public final void a() { hww localhww = new hww(this.a); localhww.b(); if (!localhww.a.getSharedPreferences("es-app-upgrade-preferences", 0).getBoolean(localhww.a(".app_upgrade.notification_sent"), false)) { localhww.a.getSharedPreferences("es-app-upgrade-preferences", 0).edit().putBoolean(localhww.a(".app_upgrade.notification_sent"), true).apply(); Context localContext = this.a; NotificationManager localNotificationManager = (NotificationManager)localContext.getSystemService("notification"); Intent localIntent = new Intent("android.intent.action.VIEW"); localIntent.addFlags(524288); localIntent.setData(Uri.parse("market://details?id=com.google.android.apps.plus")); localIntent.addFlags(335544320); PendingIntent localPendingIntent = PendingIntent.getActivity(localContext, dmr.a(), localIntent, 0); String str1 = localContext.getString(aau.vh); String str2 = localContext.getString(aau.vi); Notification localNotification = new Notification.Builder(localContext).setSmallIcon(efj.sc).setContentTitle(str1).setContentText(str2).setTicker(str2).setWhen(System.currentTimeMillis()).setContentIntent(localPendingIntent).setAutoCancel(true).setDefaults(4).getNotification(); localNotificationManager.notify(String.valueOf(localContext.getPackageName()).concat(":notifications:upgrade"), aaw.gz, localNotification); } }
public void onPrepared(MediaPlayer paramMediaPlayer) { if (paramMediaPlayer == this.c) { this.c.start(); int n = aau.tK; Object[] arrayOfObject1 = new Object[2]; arrayOfObject1[0] = a(i); arrayOfObject1[1] = a(j); h = getString(n, arrayOfObject1); c(); this.b.postDelayed(this.m, 1000L); int i1 = aau.tF; Object[] arrayOfObject2 = new Object[1]; arrayOfObject2[0] = e; String str1 = getString(i1, arrayOfObject2); String str2 = getString(aau.tH); int i2 = aau.tG; Object[] arrayOfObject3 = new Object[1]; arrayOfObject3[0] = e; String str3 = getString(i2, arrayOfObject3); PendingIntent localPendingIntent = PendingIntent.getActivity(this, 0, efj.b(this, f, g), 134217728); Notification localNotification = new Notification.Builder(this).setSmallIcon(efj.wX).setContentTitle(str2).setContentText(str3).setTicker(str1).setWhen(System.currentTimeMillis()).setContentIntent(localPendingIntent).setOngoing(true).getNotification(); this.l.notify(27312, localNotification); } }
private void addNotification(Alarm alarm) { NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); Notification notification; PendingIntent activity; Intent intent; Log.i(TAG, "AlarmNotification.addNotification(" + alarm.getId() + ", '" + alarm.getTitle() + "', '" + mDateTime.formatDetails(alarm) + "')"); intent = new Intent(this.getApplicationContext(), AlarmMe.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); activity = PendingIntent.getActivity(this, (int)alarm.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); notification = builder .setContentIntent(activity) .setSmallIcon(R.drawable.ic_notification) .setAutoCancel(true) .setContentTitle("Missed alarm: " + alarm.getTitle()) .setContentText(mDateTime.formatDetails(alarm)) .build(); notificationManager.notify((int)alarm.getId(), notification); }
private synchronized void startForeground() { if (!mForeground) { Context context = mService.getApplicationContext(); String title = context.getString(R.string.title_notification); Intent intent = new Intent(context, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, REQUEST_MAIN_ACTIVITY, intent, PendingIntent.FLAG_UPDATE_CURRENT); mNotification = new Notification.Builder(context) .setContentIntent(pendingIntent) .setSmallIcon(android.R.drawable.stat_notify_error) .setContentTitle(title) .build(); mService.startForeground(NOTIFICATION_ID, mNotification); mForeground = true; mService.onServiceInForeground(); } }
/** * Shows the notification */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") private void showNotification (Builder notification) { NotificationManager mgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); int id = 0; try { id = Integer.parseInt(options.getId()); } catch (Exception e) {} if (Build.VERSION.SDK_INT<16) { // build notification for HoneyComb to ICS mgr.notify(id, notification.getNotification()); } else if (Build.VERSION.SDK_INT>15) { // Notification for Jellybean and above mgr.notify(id, notification.build()); } }
@SuppressWarnings("deprecation") private void notify(PendingIntent pending, String tagId, String tickerText, String contentTitle, String contentText) { Builder builder = new Notification.Builder(this); builder.setSmallIcon(R.drawable.notification); builder.setTicker(tickerText); builder.setWhen(System.currentTimeMillis()); builder.setAutoCancel(true); builder.setContentTitle(contentTitle); builder.setContentText(contentText); builder.setContentIntent(pending); builder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(tagId, 0, builder.getNotification()); }
public static void init(Service a_service, Context a_context) { service = a_service; context = a_context; note_manager = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent pending_click = null; String intent_click = context.getString(R.string.intent_click); log("Notify: using broadcasts to deliver clicks."); Intent click = new Intent(intent_click); pending_click = PendingIntent.getBroadcast(context, 0, click, 0); builder = new Notification.Builder(context) .setOngoing(false) .setSmallIcon(R.drawable.intent_radio) .setPriority(Notification.PRIORITY_HIGH) .setContentIntent(pending_click) .setContentTitle(service.getString(R.string.app_name_long)) ; }
/** * This enables again the AdMob ads. * * @param activity * @param adLayout * @param excludedDevices */ public static void adMob_showAds(Activity activity, final AdView adLayout, final List<String> excludedDevices) { activity.runOnUiThread(new Runnable() { @Override public void run() { adLayout.setEnabled(true); adLayout.setVisibility(View.VISIBLE); AdRequest.Builder adBuilder = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR); for(String dev:excludedDevices){ adBuilder.addTestDevice(dev); } adLayout.loadAd(adBuilder.build()); } }); }
/** * Creates an exit popup dialog. * * @param context * @param title * @param message * @param yesLabel * @param cancelLabel * @param moveTaskToBack Set to TRUE to instead closing the activity move to * background. */ public static void dialog_showExitConfirmationDialog(final Context context, int title, int message, int yesLabel, int cancelLabel, final boolean moveTaskToBack){ new AlertDialog.Builder(context) .setIcon(android.R.drawable.ic_menu_info_details) .setTitle(context.getResources().getString(title)) .setMessage(context.getResources().getString(message)) .setPositiveButton(context.getResources().getString(yesLabel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if(moveTaskToBack){ ((Activity)context).moveTaskToBack (true); }else{ ((Activity)context).finish(); } } }) .setNegativeButton(context.getResources().getString(cancelLabel), null) .show(); }
/** * Creates an alert with an OK button. * * @param context * @param msgResourceId */ public static void dialog_showAlertOkDialog(Context context, int titleResourceId, int msgResourceId){ AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(context.getResources().getString(msgResourceId)) .setCancelable(false) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); if(titleResourceId!=0){ builder.setTitle(context.getResources().getString(titleResourceId)); } AlertDialog alert = builder.create(); alert.show(); }
/** * Creates an alert with an OK button. * * @param context * @param message */ public static void dialog_showAlertOkDialog(Context context, String tittle, String message){ AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message) .setCancelable(false) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); if(tittle!=null && tittle.length()>0){ builder.setTitle(tittle); } AlertDialog alert = builder.create(); alert.show(); }
/** * Creates a geofencing trigger request. This will make the location service * to launch geofencing events (enter/exit events) with the specified * geofence list. * <br> * See Geofences at <a href="http://developer.android.com/intl/es/training/location/geofencing.html">Google developer</a>. * <br><br> * Note:<br><br> * * Requires the permission {@link android.permission.ACCESS_FINE_LOCATION}. * * @param geofenceList The list of Geofences to watch. */ public static GeofencingRequest location_geofencesCreateTriggerRequest(List<Geofence> geofenceList) { GeofencingRequest.Builder builder = new GeofencingRequest.Builder(); //The GEOFENCE_TRANSITION_ENTER/GEOFENCE_TRANSITION_EXIT transition //triggers when a device enters/exits a geofence. // //Specifying INITIAL_TRIGGER_ENTER tells Location services that //GEOFENCE_TRANSITION_ENTER should be triggered if the the device is //already inside the geofence. // //In many cases, it may be preferable to use instead INITIAL_TRIGGER_DWELL, //which triggers events only when the user stops for a defined duration //within a geofence. builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER); builder.addGeofences(geofenceList); return builder.build(); }
/** * Use this method to get warned in the logcat when an * operation that should be done outside of the UI thread * is done in it. A sympton of this: * <br><br> * “Choreographer(abc): Skipped xx frames! The application may be doing too much work on its main thread.” * <br><br> * It also stablishes the VmPolicy detecting leaked SQL * object and leaked closable objects with the penalty of * logging them and killing the whole process on violation. * <br><br> * See: <a href="http://developer.android.com/intl/es/reference/android/os/StrictMode.html">StricMode</a> * <br><br> * <b>Note</b>: This method requires API level 11 or greater. * * @param all If set to TRUE, all detectable problems are watched. * If set to FALSE, only disk read/write and network * operations are watched. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void enableStrictMode(boolean all) { //ThreadPolicy tPolicy = new StrictMode.ThreadPolicy.Builder(); StrictMode.ThreadPolicy.Builder tPolicyBuilder = new StrictMode.ThreadPolicy.Builder(); if(all) { tPolicyBuilder.detectAll(); }else{ tPolicyBuilder.detectDiskReads() .detectDiskWrites() .detectNetwork() .penaltyLog(); } StrictMode.setThreadPolicy(tPolicyBuilder.build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyLog() .penaltyDeath() .build()); Log.i(TAG, "StrictMode enabled!"); }
/** * This method posts a notification to notification manager. * @param msg Message that is included in the ADM message. */ private void postNotification(final String msg){ final Context context = getApplicationContext(); final NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final Builder notificationBuilder = new Notification.Builder(context); final Intent notificationIntent = new Intent(context, KindleMobilePushApp.class); final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL); final Notification notification = notificationBuilder.setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Message(s) Received!") .setContentIntent(pendingIntent) .setAutoCancel(true) .getNotification(); /* Posting notification on notification bar. */ final int notificationId = context.getResources().getInteger(R.integer.sample_app_notification_id); mNotificationManager.notify(notificationId, notification); savedMessage = msg; numberOfMissedMessages++; }
@Override public void onSheetDismissed(@NonNull BottomSheet bottomSheet, @DismissEvent int dismissEvent) { Log.v(TAG, "onSheetDismissed " + dismissEvent); switch (dismissEvent) { case R.id.favorites: bookmarksDrawer.openDrawer(GravityCompat.END); break; case R.id.forward: webView.goForward(); case R.id.getpro: AlertDialog.Builder proalert = new AlertDialog.Builder(MainActivity.this, R.style.AppCompatAlertDialogStyle); proalert.setTitle(getResources().getString(R.string.preference_donate_category)); proalert.setMessage(Html.fromHtml(getResources().getString(R.string.pro_hint))); proalert.setPositiveButton(getResources().getString(R.string.go_pros), new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.get_key)))); Toast.makeText(getApplicationContext(), getResources().getString(R.string.thanks), Toast.LENGTH_SHORT).show(); } }); proalert.setNeutralButton(getResources().getString(R.string.go_pro_hint), null); proalert.show(); break; case R.id.jumpToTop: webView.loadUrl("javascript:scroll(0,0)"); break; } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { // configure the notification notificationBuilder = new Notification.Builder(this); contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notification_progress); contentView.setImageViewResource(R.id.image, R.drawable.ic_wifip2p); contentView.setTextViewText(R.id.title, "Waiting for connection to download"); contentView.setProgressBar(R.id.status_progress, 100, 0, false); notificationBuilder.setContent(contentView); notificationBuilder.setSmallIcon(R.drawable.ic_wifip2p); notificationBuilder.setOngoing(true); notificationBuilder.setTicker("WiFi Direct service started"); notificationBuilder.setOnlyAlertOnce(true); Intent i = new Intent(Intent.ACTION_MAIN); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); boolean client = false; if (intent != null && intent.hasExtra("client")) client = intent.getBooleanExtra("client", false); if (intent != null && intent.hasExtra("path")) path = intent.getStringExtra("path"); i.setComponent(new ComponentName("com.archos.wifidirect", client ? "com.archos.wifidirect.WiFiDirectSenderActivity" : "com.archos.wifidirect.WiFiDirectReceiverActivity")); PendingIntent pi = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); notificationBuilder.setContentIntent(pi); notificationManager = (NotificationManager) getApplicationContext().getSystemService( Context.NOTIFICATION_SERVICE); //To not be killed startForeground(NOTIFICATION_ID, notificationBuilder.getNotification()); return START_STICKY; }
@TargetApi(16) final Notification a(Builder builder) { builder.setDefaults(this.notificationDefaults); builder.setSmallIcon(this.statusBarDrawable); Notification build = builder.build(); build.flags = this.notificationFlags; return build; }
public static void b(Context context, String str, String str2, int i) { Notification notification; Intent intent = new Intent(context, PushReceiver.class); intent.setAction(z[69]); intent.putExtra(z[70], true); intent.putExtra(z[96], str2); intent.putExtra(z[11], i); PendingIntent broadcast = PendingIntent.getBroadcast(context, 0, intent, 134217728); NotificationManager notificationManager = (NotificationManager) context.getSystemService(z[68]); int i2 = -1; try { i2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 256).applicationInfo.icon; } catch (NameNotFoundException e) { } if (i2 < 0) { i2 = 17301586; } Object obj = z[95]; Object obj2 = z[94]; long currentTimeMillis = System.currentTimeMillis(); if (VERSION.SDK_INT >= 11) { notification = new Builder(context.getApplicationContext()).setContentTitle(obj).setContentText(obj2).setContentIntent(broadcast).setSmallIcon(i2).setTicker(str).setWhen(currentTimeMillis).getNotification(); notification.flags = 34; } else { Notification notification2 = new Notification(i2, str, currentTimeMillis); notification2.flags = 34; m.a(notification2, context, obj, obj2, broadcast); notification = notification2; } if (notification != null) { notificationManager.notify(str.hashCode(), notification); } }
public static void c(Context context, String str, String str2) { if (g(context)) { Notification notification; z.b(); Intent intent = new Intent(context, PushReceiver.class); intent.setAction(z[69]); intent.putExtra(z[70], true); intent.putExtra(z[71], str2); PendingIntent broadcast = PendingIntent.getBroadcast(context, 0, intent, 134217728); NotificationManager notificationManager = (NotificationManager) context.getSystemService(z[68]); int i = -1; try { i = context.getPackageManager().getPackageInfo(context.getPackageName(), 256).applicationInfo.icon; } catch (NameNotFoundException e) { } if (i < 0) { i = 17301586; } Object obj = z[67]; Object obj2 = z[66]; long currentTimeMillis = System.currentTimeMillis(); if (VERSION.SDK_INT >= 11) { notification = new Builder(context.getApplicationContext()).setContentTitle(obj).setContentText(obj2).setContentIntent(broadcast).setSmallIcon(i).setTicker(str).setWhen(currentTimeMillis).getNotification(); notification.flags = 34; } else { Notification notification2 = new Notification(i, str, currentTimeMillis); notification2.flags = 34; m.a(notification2, context, obj, obj2, broadcast); notification = notification2; } if (notification != null) { notificationManager.notify(str.hashCode(), notification); } } }
public static void setProgressBarStype(Builder builder, boolean isCircle) { try { sField = sClass.getField("mFlymeNotificationBuilder"); sObject = sField.get(builder); sSetProgressBarStype = sField.getType().getDeclaredMethod("setCircleProgressBar", new Class[]{Boolean.TYPE}); if (sObject != null) { Proxy.invoke(sSetProgressBarStype, sObject, Boolean.valueOf(isCircle)); } } catch (Exception ignore) { ignore.printStackTrace(); } }
private void setNotification(Context context, Intent intent) { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 268435456); NotificationManager nfcManager = (NotificationManager) context.getSystemService ("notification"); String title = context.getString(R.string.a6a); Builder builder = new Builder(context); builder.setAutoCancel(false); builder.setTicker(title); builder.setContentTitle(title); builder.setContentText(tipsStr[getTips()]); builder.setSmallIcon(R.drawable.ja); builder.setContentIntent(pendingIntent); builder.setAutoCancel(true); nfcManager.notify(noticeType, builder.getNotification()); }
static Notification add(Context context, Notification n, CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo, RemoteViews tickerView, int number, PendingIntent contentIntent, PendingIntent fullScreenIntent, Bitmap largeIcon) { boolean z; Builder lights = new Builder(context).setWhen(n.when).setSmallIcon(n.icon, n.iconLevel).setContent(n.contentView).setTicker(n.tickerText, tickerView).setSound(n.sound, n.audioStreamType).setVibrate(n.vibrate).setLights(n.ledARGB, n.ledOnMS, n.ledOffMS); if ((n.flags & 2) != 0) { z = true; } else { z = false; } lights = lights.setOngoing(z); if ((n.flags & 8) != 0) { z = true; } else { z = false; } lights = lights.setOnlyAlertOnce(z); if ((n.flags & 16) != 0) { z = true; } else { z = false; } lights = lights.setAutoCancel(z).setDefaults(n.defaults).setContentTitle(contentTitle).setContentText(contentText).setContentInfo(contentInfo).setContentIntent(contentIntent).setDeleteIntent(n.deleteIntent); if ((n.flags & 128) != 0) { z = true; } else { z = false; } return lights.setFullScreenIntent(fullScreenIntent, z).setLargeIcon(largeIcon).setNumber(number).getNotification(); }
private void doPause() { // The actual work pause(); // Update UI Builder builder = createBasicBuilder(); builder.setSmallIcon(getNotificationResources().getPauseNotificationSmallIcon()); addActionResume(builder); NotificationManager notifyMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notifyMgr.notify(getOngoingNotificationId(), NotificationBuilderCompatHelper.build(builder)); }
private void doResume() { // The actual work resume(); // Update UI Builder builder = createBasicBuilder(); addActionPause(builder); NotificationManager notifyMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notifyMgr.notify(getOngoingNotificationId(), NotificationBuilderCompatHelper.build(builder)); }
public static Builder addAction(Builder builder, int icon, CharSequence title, PendingIntent intent) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { //noinspection deprecation return builder.addAction(icon, title, intent); } else { return builder; } }
public static Notification build(Builder builder) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { return builder.build(); } else { //noinspection deprecation return builder.getNotification(); } }
protected Builder createBasicBuilder() { Builder builder = new Builder(this) .setSmallIcon(getNotificationResources().getNotificationSmallIcon()) .setContentTitle(getString(getNotificationResources().getContentTitle())) .setContentText(getString(getNotificationResources().getContentText())); /// for API level >= 21 if not using NotificationCompat .setCategory(Notification.CATEGORY_SERVICE); // Set a PendingIntent to stop the copy service Intent stopIntent = new Intent(getApplicationContext(), this.getClass()); stopIntent.setAction(ACTION_STOP_FOREGROUND); PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pendingIntent); return builder; }