List of usage examples for android.app Notification toString
@Override
public String toString()
From source file:com.wifiafterconnect.WifiAuthenticator.java
protected void notifyWifiDisabled() { NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext()) .setSmallIcon(R.drawable.wifiac_small)//(android.R.drawable.presence_offline) .setContentTitle(getResourceString(R.string.notif_wifi_disabled_title)) .setContentText(authHost + " - " + getResourceString(R.string.notif_wifi_disabled_text)); Intent resultIntent = makeIntent(MainActivity.class); if (prefs.getReenableWifiQuiet()) resultIntent.setAction(getResourceString(R.string.action_reenable_wifi)); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(getContext()); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MainActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(resultPendingIntent); Notification n = builder.build(); debug("posting notification that wifi was disabled (" + n.toString() + ")"); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(0, n);/*from w ww .j av a 2 s .c o m*/ }
From source file:gowtham.com.desknote.MyListener.java
@Override public void onNotificationPosted(StatusBarNotification sbn) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); // If user has disabled notifications, then skip if (!pref.getBoolean("send_notifications", false)) return;// w w w . j av a 2s .c o m // Look for our device Set<String> emptySet = new HashSet<String>(); Collection<String> addresses = pref.getStringSet("desktop_address", emptySet); Log.i(MainActivity.TAG, "Connected devices " + connectedDevices); Collection<String> connectedAddresses = getConnectedAddresses(addresses, connectedDevices); Notification mNotification = sbn.getNotification(); // Can't do much if we get a null! if (mNotification == null) return; Bundle extras = mNotification.extras; String packageName = sbn.getPackageName(); String title = extras.getString(Notification.EXTRA_TITLE); String text = extras.getString(Notification.EXTRA_TEXT); String subText = extras.getString(Notification.EXTRA_SUB_TEXT); Integer smallIconID = extras.getInt(Notification.EXTRA_SMALL_ICON); String icon = "null"; if (pref.getBoolean("include_images", false)) { if (extras.getParcelable(Notification.EXTRA_LARGE_ICON) != null) { Bitmap b = Bitmap.class.cast(extras.getParcelable(Notification.EXTRA_LARGE_ICON)); icon = bitmap2Base64(b); } else { icon = getIcon(packageName, smallIconID); } } Map<String, String> extrasMap = new HashMap<String, String>(); for (String key : extras.keySet()) { extrasMap.put(key, String.valueOf(extras.get(key))); } Log.e(MainActivity.TAG, "Got a new notification " + title + " " + mNotification.hashCode()); Message msg = new Message(title, text, subText, icon, mNotification.toString(), extrasMap, packageName); NotificationTransmitter tx = new NotificationTransmitter(); Log.e(MainActivity.TAG, "Sending bluetooth message"); tx.transmit(connectedAddresses, msg); }