Example usage for android.content Context NOTIFICATION_SERVICE

List of usage examples for android.content Context NOTIFICATION_SERVICE

Introduction

In this page you can find the example usage for android.content Context NOTIFICATION_SERVICE.

Prototype

String NOTIFICATION_SERVICE

To view the source code for android.content Context NOTIFICATION_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.app.NotificationManager for informing the user of background events.

Usage

From source file:br.com.atarde.portal.MyFirebaseMessagingService.java

private void sendNotification(String messageBody) {
    Intent intent = new Intent(this, MainActivity.class);

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Bitmap rawBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setContentTitle("Portal A Tarde").setContentText(messageBody).setAutoCancel(true)
            .setSound(defaultSoundUri).setContentIntent(pendingIntent).setDefaults(Notification.DEFAULT_ALL)
            .setSmallIcon(R.mipmap.ic_launcher).setLargeIcon(rawBitmap);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:com.example.bryan.sunshine.app.gcm.MyGcmListenerService.java

/**
 *  Put the message into a notification and post it.
 *  This is just one simple example of what you might choose to do with a GCM message.
 *
 * @param message The alert message to be posted.
 *///from  w  w w .  ja v  a  2s  .co  m
private void sendNotification(String message) {
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);

    // Notifications using both a large and a small icon (which yours should!) need the large
    // icon as a bitmap. So we need to create that here from the resource ID, and pass the
    // object along in our notification builder. Generally, you want to use the app icon as the
    // small icon, so that users understand what app is triggering this notification.
    //Bitmap largeIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.art_storm);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            //.setSmallIcon(R.drawable.art_clear)
            //.setLargeIcon(largeIcon)
            .setContentTitle("Weather Alert!").setStyle(new NotificationCompat.BigTextStyle().bigText(message))
            .setContentText(message).setPriority(NotificationCompat.PRIORITY_HIGH);
    mBuilder.setContentIntent(contentIntent);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}

From source file:com.riksof.a320.c2dm.common.C2DMReceiver.java

@Override
protected void onMessage(Context contxt, Intent intent) {

    String unValidatedURL = intent.getStringExtra("payload");
    Log.w("C2DMReceiver", unValidatedURL);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    int icon = R.drawable.ic_launcher; // icon from resources

    CharSequence tickerText = "You got message !!!"; // ticker-text
    long when = System.currentTimeMillis(); // notification time
    Context context = getApplicationContext(); // application Context

    Intent notificationIntent = new Intent(this, PushEndpointDemo.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    CharSequence contentTitle = "Norification Received !";

    // the next two lines initialize the Notification, using the configurations above
    Notification notification = new Notification(icon, tickerText, when);
    notification.defaults |= Notification.DEFAULT_LIGHTS;
    notification.ledARGB = 0xff00ff00;//  w  w  w  . jav  a  2 s .co m
    notification.ledOnMS = 300;
    notification.ledOffMS = 1000;
    notification.flags |= Notification.FLAG_SHOW_LIGHTS;
    notification.setLatestEventInfo(context, contentTitle, unValidatedURL, contentIntent);
    notificationManager.notify(10001, notification);

    Cache.getInstance().remove(unValidatedURL);
    FileCache fc = new FileCache(context);
    fc.clear();

    Log.w("C2DMReceiver", "finish");
}

From source file:com.coderming.weatherwatch.gcm.MyGcmListenerService.java

/**
 *  Put the message into a notification and post it.
 *  This is just one simple example of what you might choose to do with a GCM message.
 *
 * @param message The alert message to be posted.
 *//*  ww  w.j a v a2s .co  m*/
private void sendNotification(String message) {
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);

    // Notifications using both a large and a small icon (which yours should!) need the large
    // icon as a bitmap. So we need to create that here from the resource ID, and pass the
    // object along in our notification builder. Generally, you want to use the app icon as the
    // small icon, so that users understand what app is triggering this notification.
    Bitmap largeIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.art_storm);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.art_clear).setLargeIcon(largeIcon).setContentTitle("Weather Alert!")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).setContentText(message)
            .setPriority(NotificationCompat.PRIORITY_HIGH);
    mBuilder.setContentIntent(contentIntent);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}

From source file:br.com.commons.pushnotification.views.service.GcmCustomListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from www.ja  v a  2s  .c  o  m
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, HomeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.common_google_signin_btn_icon_dark).setContentTitle("GCM Message")
            .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:com.keylesspalace.tusky.util.NotificationMaker.java

public static void make(final Context context, final int notifyId, Notification body) {
    final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    final SharedPreferences notificationPreferences = context.getSharedPreferences("Notifications",
            Context.MODE_PRIVATE);

    if (!filterNotification(preferences, body)) {
        return;//from  w  w w .  java2s .c  o  m
    }

    String rawCurrentNotifications = notificationPreferences.getString("current", "[]");
    JSONArray currentNotifications;

    try {
        currentNotifications = new JSONArray(rawCurrentNotifications);
    } catch (JSONException e) {
        currentNotifications = new JSONArray();
    }

    boolean alreadyContains = false;

    for (int i = 0; i < currentNotifications.length(); i++) {
        try {
            if (currentNotifications.getString(i).equals(body.account.getDisplayName())) {
                alreadyContains = true;
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    if (!alreadyContains) {
        currentNotifications.put(body.account.getDisplayName());
    }

    notificationPreferences.edit().putString("current", currentNotifications.toString()).commit();

    Intent resultIntent = new Intent(context, MainActivity.class);
    resultIntent.putExtra("tab_position", 1);
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    Intent deleteIntent = new Intent(context, NotificationClearBroadcastReceiver.class);
    PendingIntent deletePendingIntent = PendingIntent.getBroadcast(context, 0, deleteIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_notify).setContentIntent(resultPendingIntent)
            .setDeleteIntent(deletePendingIntent).setDefaults(0); // So it doesn't ring twice, notify only in Target callback

    if (currentNotifications.length() == 1) {
        builder.setContentTitle(titleForType(context, body))
                .setContentText(truncateWithEllipses(bodyForType(body), 40));

        Target mTarget = new Target() {
            @Override
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                builder.setLargeIcon(bitmap);

                setupPreferences(preferences, builder);

                ((NotificationManager) (context.getSystemService(Context.NOTIFICATION_SERVICE)))
                        .notify(notifyId, builder.build());
            }

            @Override
            public void onBitmapFailed(Drawable errorDrawable) {
            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {
            }
        };

        Picasso.with(context).load(body.account.avatar).placeholder(R.drawable.avatar_default)
                .transform(new RoundedTransformation(7, 0)).into(mTarget);
    } else {
        setupPreferences(preferences, builder);
        try {
            builder.setContentTitle(String.format(context.getString(R.string.notification_title_summary),
                    currentNotifications.length()))
                    .setContentText(truncateWithEllipses(joinNames(context, currentNotifications), 40));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        builder.setVisibility(android.app.Notification.VISIBILITY_PRIVATE);
        builder.setCategory(android.app.Notification.CATEGORY_SOCIAL);
    }

    ((NotificationManager) (context.getSystemService(Context.NOTIFICATION_SERVICE))).notify(notifyId,
            builder.build());
}

From source file:audio.lisn.service.MediaNotificationManager.java

public MediaNotificationManager(AudioPlayerService service) {
    mService = service;//from  ww  w.j  a v a 2  s . co  m
    Log.v("Media", "MediaNotificationManager start");

    // mController = new MediaController(mService.getApplicationContext());

    // updateSessionToken();

    mNotificationColor = mService.getResources().getColor(R.color.colorPrimary);

    //ResourceHelper.getThemeColor(mService,android.R.attr.colorPrimary, Color.DKGRAY);

    mNotificationManager = (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);

    String pkg = mService.getPackageName();
    mPauseIntent = PendingIntent.getBroadcast(mService, REQUEST_CODE, new Intent(ACTION_PAUSE).setPackage(pkg),
            PendingIntent.FLAG_CANCEL_CURRENT);
    mPlayIntent = PendingIntent.getBroadcast(mService, REQUEST_CODE, new Intent(ACTION_PLAY).setPackage(pkg),
            PendingIntent.FLAG_CANCEL_CURRENT);
    mPreviousIntent = PendingIntent.getBroadcast(mService, REQUEST_CODE,
            new Intent(ACTION_PREV).setPackage(pkg), PendingIntent.FLAG_CANCEL_CURRENT);
    mNextIntent = PendingIntent.getBroadcast(mService, REQUEST_CODE, new Intent(ACTION_NEXT).setPackage(pkg),
            PendingIntent.FLAG_CANCEL_CURRENT);
    mDeleteIntent = PendingIntent.getBroadcast(mService, REQUEST_CODE,
            new Intent(ACTION_DELETE).setPackage(pkg), PendingIntent.FLAG_CANCEL_CURRENT);

    // Cancel all notifications to handle the case where the Service was killed and
    // restarted by the system.
    mNotificationManager.cancelAll();
}

From source file:com.amaze.filemanager.services.ExtractService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle b = new Bundle();
    b.putInt("id", startId);
    epath = PreferenceManager.getDefaultSharedPreferences(this).getString("extractpath", "");
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    String file = intent.getStringExtra("zip");
    eentries = intent.getBooleanExtra("entries1", false);
    if (eentries) {
        entries = intent.getStringArrayListExtra("entries");
    }//from w  w  w.j av a  2s .  c o m
    b.putString("file", file);
    DataPackage intent1 = new DataPackage();
    intent1.setName(file);
    intent1.setTotal(0);
    intent1.setDone(0);
    intent1.setId(startId);
    intent1.setP1(0);
    intent1.setCompleted(false);
    hash1.put(startId, intent1);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.putExtra("openprocesses", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder = new NotificationCompat.Builder(cd);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.extracting))
            .setContentText(new File(file).getName()).setSmallIcon(R.drawable.ic_doc_compressed);
    hash.put(startId, true);
    new Doback().execute(b);
    return START_STICKY;
}

From source file:com.portfolio.course.esguti.goubiquitous.mobile.gcm.MyGcmListenerService.java

/**
 *  Put the message into a notification and post it.
 *  This is just one simple example of what you might choose to do with a GCM message.
 *
 * @param message The alert message to be posted.
 *//*from w ww  . j  a v a2s . c o m*/
private void sendNotification(String message) {
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);

    // Notifications using both a large and a small icon (which yours should!) need the large
    // icon as a bitmap. So we need to create that here from the resource ID, and pass the
    // object along in our notification builder. Generally, you want to use the com.portfolio.course.esguti.goubiquitous.mobile icon as the
    // small icon, so that users understand what com.portfolio.course.esguti.goubiquitous.mobile is triggering this notification.
    Bitmap largeIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.art_storm);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.art_clear).setLargeIcon(largeIcon).setContentTitle("Weather Alert!")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).setContentText(message)
            .setPriority(NotificationCompat.PRIORITY_HIGH);
    mBuilder.setContentIntent(contentIntent);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}

From source file:com.olearyp.gusto.Expsetup.java

/** Called when the activity is first created. */
@Override/* w w w .  j a  va  2 s.c  o  m*/
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    settings = getSharedPreferences("serverState", MODE_PRIVATE);
    addPreferencesFromResource(R.xml.preferences);
    final Map<String, String> config = getCurrentConfig();

    // Tack version number on to titlebar at top level
    try {
        this.setTitle(getTitle() + " v" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
    } catch (final NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    String ramhack_file;
    // ROM-specific settings
    if (config.get("GLB_EP_VERSION_EPDATA").contains("-TMO")) {
        findPreference("launcher").setEnabled(false);
        findPreference("phone").setEnabled(false);
        findPreference("contacts").setEnabled(false);
        findPreference("teeter").setEnabled(false);
        findPreference("quickoffice").setEnabled(false);
        ramhack_file = "10mb_kernel_patch_tmo262.zip";
    } else {
        ramhack_file = "10mb_kernel_patch_adp262.zip";
    }
    // QuickCommands menu
    {
        findPreference("reboot").setOnPreferenceClickListener(new RebootPreferenceListener(
                R.string.reboot_alert_title, R.string.reboot_msg, R.string.reboot));
        findPreference("reboot_recovery").setOnPreferenceClickListener(new RebootPreferenceListener(
                R.string.reboot_alert_title, R.string.reboot_recovery_msg, R.string.reboot_recovery));
        findPreference("reboot_bootloader").setOnPreferenceClickListener(new RebootPreferenceListener(
                R.string.reboot_alert_title, R.string.reboot_bootloader_msg, R.string.reboot_bootload));
        findPreference("reboot_poweroff").setOnPreferenceClickListener(new RebootPreferenceListener(
                R.string.shutdown_alert_title, R.string.shutdown_msg, R.string.shutdown));
        findPreference("rwsystem").setOnPreferenceClickListener(
                new ExpPreferenceListener(R.string.rwsystem, "setting /system read-write"));
        findPreference("rosystem").setOnPreferenceClickListener(
                new ExpPreferenceListener(R.string.rosystem, "setting /system read-only"));
    }
    // CPU options
    {
        findPreference("freq_sample").setOnPreferenceChangeListener(
                new ExpPreferenceListener("yes | set_ep_cyan_ond_mod", "setting frequency scaling"));
        ((CheckBoxPreference) findPreference("freq_sample"))
                .setChecked(isTrueish(config, "GLB_EP_ENABLE_CYAN_OND_MOD"));
        final List<String> freqs = Arrays.asList(getResources().getStringArray(R.array.cpu_freqs_str));
        final ListPreference minFreqPref = (ListPreference) findPreference("cpu_freq_min");
        final ListPreference maxFreqPref = (ListPreference) findPreference("cpu_freq_max");
        minFreqPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(final Preference preference, final Object newValue) {
                sendCommand("GLB_EP_MIN_CPU=" + newValue.toString() + " && " + "write_out_ep_config && "
                        + "echo \"$GLB_EP_MIN_CPU\" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq",
                        "setting minimum CPU frequency", "none");
                final String[] legalfreqs = freqs.subList(freqs.indexOf(newValue), freqs.size())
                        .toArray(new String[0]);
                maxFreqPref.setEntries(legalfreqs);
                maxFreqPref.setEntryValues(legalfreqs);
                return true;
            }
        });
        maxFreqPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(final Preference preference, final Object newValue) {
                sendCommand("GLB_EP_MAX_CPU=" + newValue.toString() + " && " + "write_out_ep_config && "
                        + "echo \"$GLB_EP_MAX_CPU\" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
                        "setting maximum CPU frequency", "none");
                final String[] legalfreqs = freqs.subList(0, freqs.indexOf(newValue) + 1)
                        .toArray(new String[0]);
                minFreqPref.setEntries(legalfreqs);
                minFreqPref.setEntryValues(legalfreqs);
                return true;
            }
        });
        final String[] maxfreqs = freqs.subList(freqs.indexOf(config.get("GLB_EP_MIN_CPU")), freqs.size())
                .toArray(new String[0]);
        maxFreqPref.setEntries(maxfreqs);
        maxFreqPref.setEntryValues(maxfreqs);
        final String[] minfreqs = freqs.subList(0, freqs.indexOf(config.get("GLB_EP_MAX_CPU")) + 1)
                .toArray(new String[0]);
        minFreqPref.setEntries(minfreqs);
        minFreqPref.setEntryValues(minfreqs);
        maxFreqPref.setValue(config.get("GLB_EP_MAX_CPU"));
        minFreqPref.setValue(config.get("GLB_EP_MIN_CPU"));
    }
    // Downloadables
    {
        DownloadPreference p;
        p = ((DownloadPreference) findPreference("ramhack_kernel"));
        p.setParams(ASPIN_URL + "RESOURCE/" + ramhack_file, "/sdcard/" + ramhack_file);
        p.setOnPreferenceClickListener(new RamhackPreferenceListener(testRamhack(config), p));
        p = ((DownloadPreference) findPreference("kernel_mods"));
        p.setParams(ASPIN_URL + "ROM/kmods_v211_vsapp.zip", "/sdcard/epvsapps/available/kmods_v211_vsapp.zip");
        p.setOnPreferenceClickListener(new VsappPreferenceListener(
                new File("/sdcard/epvsapps/available/kmods_v211_vsapp.zip").exists(), p));
        p = ((DownloadPreference) findPreference("teeter"));
        p.setParams(ASPIN_URL + "APPS/teeter_vsapp.zip", "/sdcard/epvsapps/available/teeter_vsapp.zip");
        p.setOnPreferenceClickListener(new VsappPreferenceListener(
                new File("/sdcard/epvsapps/available/teeter_vsapp.zip").exists(), p));
        p = ((DownloadPreference) findPreference("quickoffice"));
        p.setParams(ASPIN_URL + "APPS/quickoffice_vsapp.zip",
                "/sdcard/epvsapps/available/quickoffice_vsapp.zip");
        p.setOnPreferenceClickListener(new VsappPreferenceListener(
                new File("/sdcard/epvsapps/available/quickoffice_vsapp.zip").exists(), p));
        p = ((DownloadPreference) findPreference("ext_widgets"));
        p.setParams(ASPIN_URL + "APPS/widgetpack_v2_vsapp.zip",
                "/sdcard/epvsapps/available/widgetpack_v2_vsapp.zip");
        p.setOnPreferenceClickListener(new VsappPreferenceListener(
                new File("/sdcard/epvsapps/available/widgetpack_v2_vsapp.zip").exists(), p));
        p = ((DownloadPreference) findPreference("xdan_java"));
        p.setParams(ASPIN_URL + "APPS/jbed_vsapp.zip", "/sdcard/epvsapps/available/jbed_vsapp.zip");
        p.setOnPreferenceClickListener(
                new VsappPreferenceListener(new File("/sdcard/epvsapps/available/jbed_vsapp.zip").exists(), p));
        p = ((DownloadPreference) findPreference("iwnn_ime_jp"));
        p.setParams(ASPIN_URL + "APPS/iwnnime_vsapp.zip", "/sdcard/epvsapps/available/iwnnime_vsapp.zip");
        p.setOnPreferenceClickListener(new VsappPreferenceListener(
                new File("/sdcard/epvsapps/available/iwnnime_vsapp.zip").exists(), p));
    }
    // Theme profile settings
    {
        findPreference("launcher").setOnPreferenceChangeListener(
                new ExpThemeProfileChangeListener("Launcher.apk", "changing Launcher"));
        ((CheckBoxPreference) findPreference("launcher")).setChecked(isTrueish(config, "Launcher.apk"));
        findPreference("phone").setOnPreferenceChangeListener(
                new ExpThemeProfileChangeListener("Phone.apk", "changing Phone"));
        ((CheckBoxPreference) findPreference("phone")).setChecked(isTrueish(config, "Phone.apk"));
        findPreference("contacts").setOnPreferenceChangeListener(
                new ExpThemeProfileChangeListener("Contacts.apk", "changing Contacts"));
        ((CheckBoxPreference) findPreference("contacts")).setChecked(isTrueish(config, "Contacts.apk"));
        findPreference("browser").setOnPreferenceChangeListener(
                new ExpThemeProfileChangeListener("Browser.apk", "changing the Browser"));
        ((CheckBoxPreference) findPreference("browser")).setChecked(isTrueish(config, "Browser.apk"));
        findPreference("mms")
                .setOnPreferenceChangeListener(new ExpThemeProfileChangeListener("Mms.apk", "changing MMS"));
        ((CheckBoxPreference) findPreference("mms")).setChecked(isTrueish(config, "Mms.apk"));
    }
    // Advanced Options
    {
        // Swappiness
        findPreference("swappiness").setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(final Preference preference, final Object newValue) {
                sendCommand("yes '" + newValue.toString() + "' | set_ep_swappiness", "setting swappiness",
                        "none");
                return true;
            }
        });
        ((EditTextPreference) findPreference("swappiness")).setText(config.get("GLB_EP_SWAPPINESS"));
        ((EditTextPreference) findPreference("swappiness")).getEditText()
                .setKeyListener(new SwappinessKeyListener());
        // Compcache
        findPreference("compcache").setOnPreferenceChangeListener(
                new ExpPreferenceListener("yes | toggle_ep_compcache", "setting compcache", true));
        ((CheckBoxPreference) findPreference("compcache"))
                .setChecked(isTrueish(config, "GLB_EP_ENABLE_COMPCACHE"));
        // Linux swap
        findPreference("linux_swap").setOnPreferenceChangeListener(
                new ExpPreferenceListener("yes | toggle_ep_linuxswap", "setting Linux-swap"));
        ((CheckBoxPreference) findPreference("linux_swap"))
                .setChecked(isTrueish(config, "GLB_EP_ENABLE_LINUXSWAP"));
        // userinit.sh
        findPreference("userinit").setOnPreferenceChangeListener(
                new ExpPreferenceListener("yes | toggle_ep_userinit", "setting userinit"));
        ((CheckBoxPreference) findPreference("userinit")).setChecked(isTrueish(config, "GLB_EP_RUN_USERINIT"));
        // Remove odex on boot
        findPreference("odex").setOnPreferenceChangeListener(
                new ExpPreferenceListener("yes | toggle_ep_odex_boot_removal", "setting ODEX removal"));
        ((CheckBoxPreference) findPreference("odex")).setChecked(isTrueish(config, "GLB_EP_ODEX_BOOT_REMOVAL"));
        // Odex now
        findPreference("reodex").setOnPreferenceClickListener(
                new ExpPreferenceListener("yes | odex_ep_data_apps", "re-ODEXing apps"));
        // Set pid priorities
        findPreference("pid_prioritize").setOnPreferenceChangeListener(
                new ExpPreferenceListener("yes | toggle_ep_pid_prioritizer", "setting PID prioritizer"));
        ((CheckBoxPreference) findPreference("pid_prioritize"))
                .setChecked(isTrueish(config, "GLB_EP_PID_PRIORITIZE"));
    }
    // Generate and send ep_log
    findPreference("ep_log").setOnPreferenceClickListener(new EpLogListener());
}