Example usage for android.os PowerManager newWakeLock

List of usage examples for android.os PowerManager newWakeLock

Introduction

In this page you can find the example usage for android.os PowerManager newWakeLock.

Prototype

public WakeLock newWakeLock(int levelAndFlags, String tag) 

Source Link

Document

Creates a new wake lock with the specified level and flags.

Usage

From source file:com.daiv.android.twitter.utils.NotificationUtils.java

public static void newInteractions(User interactor, Context context, SharedPreferences sharedPrefs,
        String type) {/*from   w  w  w  . j a  v  a 2 s.  c om*/
    String title = "";
    String text = "";
    String smallText = "";
    Bitmap icon = null;

    AppSettings settings = AppSettings.getInstance(context);

    int newFollowers = sharedPrefs.getInt("new_followers", 0);
    int newRetweets = sharedPrefs.getInt("new_retweets", 0);
    int newFavorites = sharedPrefs.getInt("new_favorites", 0);
    int newQuotes = sharedPrefs.getInt("new_quotes", 0);

    // set title
    if (newFavorites + newRetweets + newFollowers > 1) {
        title = context.getResources().getString(R.string.new_interactions);
    } else {
        title = context.getResources().getString(R.string.new_interaction_upper);
    }

    // set text
    String currText = sharedPrefs.getString("old_interaction_text", "");
    if (!currText.equals("")) {
        currText += "<br>";
    }
    if (settings.displayScreenName) {
        text = currText + "<b>" + interactor.getScreenName() + "</b> " + type;
    } else {
        text = currText + "<b>" + interactor.getName() + "</b> " + type;
    }
    sharedPrefs.edit().putString("old_interaction_text", text).commit();

    // set icon
    int types = 0;
    if (newFavorites > 0) {
        types++;
    }
    if (newFollowers > 0) {
        types++;
    }
    if (newRetweets > 0) {
        types++;
    }
    if (newQuotes > 0) {
        types++;
    }

    if (types > 1) {
        icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_stat_icon);
    } else {
        if (newFavorites > 0) {
            icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_action_important_dark);
        } else if (newRetweets > 0) {
            icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_action_repeat_dark);
        } else {
            icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.drawer_user_dark);
        }
    }

    // set shorter text
    int total = newFavorites + newFollowers + newRetweets + newQuotes;
    if (total > 1) {
        smallText = total + " " + context.getResources().getString(R.string.new_interactions_lower);
    } else {
        smallText = text;
    }

    Intent markRead = new Intent(context, ReadInteractionsService.class);
    PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0);

    Intent deleteIntent = new Intent(context, NotificationDeleteReceiverOne.class);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setContentTitle(title)
            .setContentText(Html.fromHtml(
                    settings.addonTheme ? smallText.replaceAll("FF8800", settings.accentColor) : smallText))
            .setSmallIcon(R.drawable.ic_stat_icon).setLargeIcon(icon).setTicker(title)
            .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0))
            .setPriority(NotificationCompat.PRIORITY_HIGH).setAutoCancel(true);

    if (context.getResources().getBoolean(R.bool.expNotifications)) {
        mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(
                Html.fromHtml(settings.addonTheme ? text.replaceAll("FF8800", settings.accentColor) : text)));
    }

    if (settings.vibrate) {
        mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
    }

    if (settings.sound) {
        try {
            mBuilder.setSound(Uri.parse(settings.ringtone));
        } catch (Exception e) {
            mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
        }
    }

    if (settings.led)
        mBuilder.setLights(0xFFFFFF, 1000, 1000);

    if (settings.notifications) {

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

        notificationManager.notify(4, mBuilder.build());

        // if we want to wake the screen on a new message
        if (settings.wakeScreen) {
            PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
            final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                    | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
            wakeLock.acquire(5000);
        }

        // Pebble notification
        if (sharedPrefs.getBoolean("pebble_notification", false)) {
            sendAlertToPebble(context, title, text);
        }

        // Light Flow notification
        sendToLightFlow(context, title, text);
    }
}

From source file:com.ternup.caddisfly.activity.SurveyActivity.java

@Override
protected void onStart() {
    super.onStart();

    if (wakeLock == null || !wakeLock.isHeld()) {
        PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
        wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
        wakeLock.acquire();/*from  ww  w  . jav  a 2s  .c o m*/
    }
}

From source file:com.daiv.android.twitter.utils.NotificationUtils.java

public static void notifySecondMentions(Context context, int secondAccount) {
    MentionsDataSource data = MentionsDataSource.getInstance(context);
    int numberNew = data.getUnreadCount(secondAccount);

    int smallIcon = R.drawable.ic_stat_icon;
    Bitmap largeIcon;//  w  w w  .  ja va 2s. c  o m

    NotificationCompat.Builder mBuilder;

    String title = context.getResources().getString(R.string.app_name) + " - "
            + context.getResources().getString(R.string.sec_acc);
    String name = null;
    String message;
    String messageLong;

    String tweetText = null;
    NotificationCompat.Action replyAction = null;
    if (numberNew == 1) {
        name = data.getNewestName(secondAccount);

        SharedPreferences sharedPrefs = context.getSharedPreferences(
                "com.daiv.android.twitter_world_preferences",
                Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
        // if they are muted, and you don't want them to show muted mentions
        // then just quit
        if (sharedPrefs.getString("muted_users", "").contains(name)
                && !sharedPrefs.getBoolean("show_muted_mentions", false)) {
            return;
        }

        message = context.getResources().getString(R.string.mentioned_by) + " @" + name;
        tweetText = data.getNewestMessage(secondAccount);
        messageLong = "<b>@" + name + "</b>: " + tweetText;
        largeIcon = getImage(context, name);

        Intent reply = null;

        sharedPrefs.edit().putString("from_notification_second", "@" + name).commit();
        long id = data.getLastIds(secondAccount)[0];
        PendingIntent replyPending = PendingIntent.getActivity(context, 0, reply, 0);
        sharedPrefs.edit().putLong("from_notification_long_second", id).commit();
        sharedPrefs.edit()
                .putString("from_notification_text_second",
                        "@" + name + ": "
                                + TweetLinkUtils.removeColorHtml(tweetText, AppSettings.getInstance(context)))
                .commit();

        // Create the remote input
        RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel("@" + name + " ").build();

        // Create the notification action
        replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_action_reply_dark,
                context.getResources().getString(R.string.noti_reply), replyPending).addRemoteInput(remoteInput)
                        .build();

    } else { // more than one mention
        message = numberNew + " " + context.getResources().getString(R.string.new_mentions);
        messageLong = "<b>" + context.getResources().getString(R.string.mentions) + "</b>: " + numberNew + " "
                + context.getResources().getString(R.string.new_mentions);
        largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.drawer_user_dark);
    }

    Intent markRead = new Intent(context, MarkReadSecondAccService.class);
    PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0);

    AppSettings settings = AppSettings.getInstance(context);

    Intent deleteIntent = new Intent(context, NotificationDeleteReceiverTwo.class);

    mBuilder = new NotificationCompat.Builder(context).setContentTitle(title)
            .setContentText(TweetLinkUtils.removeColorHtml(message, settings)).setSmallIcon(smallIcon)
            .setLargeIcon(largeIcon).setAutoCancel(true)
            .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0))
            .setPriority(NotificationCompat.PRIORITY_HIGH);

    if (numberNew == 1) {
        mBuilder.addAction(replyAction);
        mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml(
                settings.addonTheme ? messageLong.replaceAll("FF8800", settings.accentColor) : messageLong)));
    } else {
        NotificationCompat.InboxStyle inbox = getMentionsInboxStyle(numberNew, secondAccount, context,
                TweetLinkUtils.removeColorHtml(message, settings));

        mBuilder.setStyle(inbox);
    }
    if (settings.vibrate) {
        mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
    }

    if (settings.sound) {
        try {
            mBuilder.setSound(Uri.parse(settings.ringtone));
        } catch (Exception e) {
            mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
        }
    }

    if (settings.led)
        mBuilder.setLights(0xFFFFFF, 1000, 1000);

    if (settings.notifications) {

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

        notificationManager.notify(9, mBuilder.build());

        // if we want to wake the screen on a new message
        if (settings.wakeScreen) {
            PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
            final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                    | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
            wakeLock.acquire(5000);
        }

        // Pebble notification
        if (context
                .getSharedPreferences("com.daiv.android.twitter_world_preferences",
                        Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE)
                .getBoolean("pebble_notification", false)) {
            sendAlertToPebble(context, title, messageLong);
        }

        // Light Flow notification
        sendToLightFlow(context, title, messageLong);
    }
}

From source file:com.wifi.brainbreaker.mydemo.spydroid.ui.SpydroidActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mApplication = (SpydroidApplication) getApplication();

    setContentView(R.layout.spydroid);/* w ww  .j  a v  a2s.  c om*/

    if (findViewById(R.id.handset_pager) != null) {

        // Handset detected !
        mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
        mViewPager = (ViewPager) findViewById(R.id.handset_pager);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        mSurfaceView = (SurfaceView) findViewById(R.id.handset_camera_view);
        SessionBuilder.getInstance().setSurfaceView(mSurfaceView);
        SessionBuilder.getInstance().setPreviewOrientation(90);

    } else {

        // Tablet detected !
        device = TABLET;
        mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
        mViewPager = (ViewPager) findViewById(R.id.tablet_pager);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        SessionBuilder.getInstance().setPreviewOrientation(0);

    }

    mViewPager.setAdapter(mAdapter);

    // Remove the ads if this is the donate version of the app.
    //      if (mApplication.DONATE_VERSION) {
    //         ((LinearLayout)findViewById(R.id.adcontainer)).removeAllViews();
    //      }

    // Prevents the phone from going to sleep mode
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "net.majorkernelpanic.spydroid.wakelock");

    // Starts the service of the HTTP server
    this.startService(new Intent(this, CustomHttpServer.class));

    // Starts the service of the RTSP server
    this.startService(new Intent(this, CustomRtspServer.class));

}

From source file:net.majorkernelpanic.spydroid.ui.SpydroidActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mApplication = (SpydroidApplication) getApplication();

    setContentView(R.layout.spydroid);//from   w ww  .ja v a2s  .c  o  m

    if (findViewById(R.id.handset_pager) != null) {

        // Handset detected !
        mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
        mViewPager = (ViewPager) findViewById(R.id.handset_pager);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        mSurfaceView = (SurfaceView) findViewById(R.id.handset_camera_view);
        SessionBuilder.getInstance().setSurfaceView(mSurfaceView);
        SessionBuilder.getInstance().setPreviewOrientation(90);

    } else {

        // Tablet detected !
        device = TABLET;
        mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
        mViewPager = (ViewPager) findViewById(R.id.tablet_pager);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        SessionBuilder.getInstance().setPreviewOrientation(0);

    }

    mViewPager.setAdapter(mAdapter);

    // Remove the ads if this is the donate version of the app.
    if (mApplication.DONATE_VERSION) {
        ((LinearLayout) findViewById(R.id.adcontainer)).removeAllViews();
    }

    // Prevents the phone from going to sleep mode
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "net.majorkernelpanic.spydroid.wakelock");

    // Starts the service of the HTTP server
    this.startService(new Intent(this, CustomHttpServer.class));

    // Starts the service of the RTSP server
    this.startService(new Intent(this, CustomRtspServer.class));

}

From source file:net.majorkernelpanic.spydroid.SpydroidActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);//from   w ww .j av  a  2s. com

    camera = (SurfaceView) findViewById(R.id.smallcameraview);
    context = this.getApplicationContext();
    line1 = (TextView) findViewById(R.id.line1);
    line2 = (TextView) findViewById(R.id.line2);
    version = (TextView) findViewById(R.id.version);
    buttonSettings = (ImageView) findViewById(R.id.button_settings);
    buttonClient = (ImageView) findViewById(R.id.button_client);
    buttonAbout = (ImageView) findViewById(R.id.button_about);
    signWifi = (TextView) findViewById(R.id.advice);
    signStreaming = (TextView) findViewById(R.id.streaming);
    signInformation = (LinearLayout) findViewById(R.id.information);
    pulseAnimation = AnimationUtils.loadAnimation(this, R.anim.pulse);

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    H264Stream.setPreferences(settings);

    settings.registerOnSharedPreferenceChangeListener(this);

    camera.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder = camera.getHolder();

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "net.majorkernelpanic.spydroid.wakelock");

    // Print version number
    try {
        version.setText("v" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName);
    } catch (Exception e) {
        version.setText("v???");
    }

    Session.setSurfaceHolder(holder);
    Session.setHandler(handler);
    Session.setDefaultAudioEncoder(settings.getBoolean("stream_audio", false)
            ? Integer.parseInt(settings.getString("audio_encoder", "3"))
            : 0);
    Session.setDefaultVideoEncoder(settings.getBoolean("stream_video", true)
            ? Integer.parseInt(settings.getString("video_encoder", "2"))
            : 0);
    Session.setDefaultVideoQuality(new VideoQuality(settings.getInt("video_resX", 0),
            settings.getInt("video_resY", 0), Integer.parseInt(settings.getString("video_framerate", "0")),
            Integer.parseInt(settings.getString("video_bitrate", "0")) * 1000));

    rtspServer = new RtspServer(8086, handler);
    httpServer = new CustomHttpServer(8080, this.getApplicationContext(), handler);

    buttonSettings.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // Starts QualityListActivity where user can change the quality of the stream
            Intent intent = new Intent(context, OptionsActivity.class);
            startActivityForResult(intent, 0);
        }
    });
    buttonClient.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // Starts ClientActivity, the user can then capture the stream from another phone running Spydroid
            Intent intent = new Intent(context, ClientActivity.class);
            startActivityForResult(intent, 0);
        }
    });
    buttonAbout.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // Display some information
            Intent intent = new Intent(context, AboutActivity.class);
            startActivityForResult(intent, 0);
        }
    });

}

From source file:com.klinker.android.twitter.utils.NotificationUtils.java

public static void sendTestNotification(Context context) {

    if (!TEST_NOTIFICATION) {
        return;/*from ww w  . j av  a2  s .  co  m*/
    }

    AppSettings settings = AppSettings.getInstance(context);

    SharedPreferences sharedPrefs = context.getSharedPreferences(
            "com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);

    Intent markRead = new Intent(context, MarkReadService.class);
    PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0);

    String shortText = "Test Talon";
    String longText = "Here is a test for Talon's notifications";

    Intent resultIntent = new Intent(context, RedirectToMentions.class);

    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);

    NotificationCompat.Builder mBuilder;

    Intent deleteIntent = new Intent(context, NotificationDeleteReceiverOne.class);

    mBuilder = new NotificationCompat.Builder(context).setContentTitle(shortText).setContentText(longText)
            .setSmallIcon(R.drawable.ic_stat_icon)
            .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher))
            .setContentIntent(resultPendingIntent).setAutoCancel(true).setTicker(shortText)
            .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0))
            .setPriority(NotificationCompat.PRIORITY_HIGH);

    // Pebble notification
    if (sharedPrefs.getBoolean("pebble_notification", false)) {
        sendAlertToPebble(context, shortText, shortText);
    }

    // Light Flow notification
    sendToLightFlow(context, shortText, shortText);

    if (settings.vibrate) {
        mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
    }

    if (settings.sound) {
        try {
            mBuilder.setSound(Uri.parse(settings.ringtone));
        } catch (Exception e) {
            e.printStackTrace();
            mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
        }
    }

    if (settings.led)
        mBuilder.setLights(0xFFFFFF, 1000, 1000);

    // Get an instance of the NotificationManager service
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

    Intent reply = new Intent(context, NotificationCompose.class);
    MentionsDataSource data = MentionsDataSource.getInstance(context);
    PendingIntent replyPending = PendingIntent.getActivity(context, 0, reply, 0);

    RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel("@" + "lukeklinker" + " ")
            .build();

    // Create the notification action
    NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(
            R.drawable.ic_action_reply_dark, context.getResources().getString(R.string.noti_reply),
            replyPending).addRemoteInput(remoteInput).build();

    NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder(
            R.drawable.ic_action_read_dark, context.getResources().getString(R.string.mark_read), readPending);

    mBuilder.addAction(replyAction);
    mBuilder.addAction(action.build());

    // Build the notification and issues it with notification manager.
    notificationManager.notify(1, mBuilder.build());

    // if we want to wake the screen on a new message
    if (settings.wakeScreen) {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
        wakeLock.acquire(5000);
    }
}

From source file:cc.softwarefactory.lokki.android.androidServices.LocationService.java

@Override
public void onCreate() {

    Log.d(TAG, "onCreate");
    super.onCreate();

    if (PreferenceUtils.getString(this, PreferenceUtils.KEY_AUTH_TOKEN).isEmpty()) {
        Log.d(TAG, "User disabled reporting in App. Service not started.");
        stopSelf();//from   w  ww . ja  v a  2 s .co  m
    } else if (Utils.checkGooglePlayServices(this)) {
        Log.d(TAG, "Starting Service..");
        setLocationClient();
        setNotificationAndForeground();
        PowerManager mgr = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
        wakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "GPS Child Location Wake Lock");
        wakeLock.acquire();
        serviceRunning = true;
    } else {
        Log.e(TAG, "Google Play Services Are NOT installed.");
        stopSelf();
    }
}

From source file:com.cityfreqs.littlesirecho.MainActivity.java

private void runScheduler() {
    PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    wakeLock.acquire();/*from   w w w  .  j av a 2s  . co m*/

    scheduler = Executors.newSingleThreadScheduledExecutor();
    scheduler.scheduleAtFixedRate(new Runnable() {
        public void run() {
            logger("executor echo.");
            echoNotification();
        }
    }, userSelectedWaitTime, userSelectedWaitTime, TimeUnit.MILLISECONDS);
}

From source file:com.klinker.android.twitter.utils.NotificationUtils.java

public static void notifySecondDMs(Context context, int secondAccount) {
    DMDataSource data = DMDataSource.getInstance(context);

    SharedPreferences sharedPrefs = context.getSharedPreferences(
            "com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);

    int numberNew = sharedPrefs.getInt("dm_unread_" + secondAccount, 0);

    int smallIcon = R.drawable.ic_stat_icon;
    Bitmap largeIcon;//ww  w .  j a  va2 s. com

    Intent resultIntent = new Intent(context, SwitchAccountsRedirect.class);

    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);

    NotificationCompat.Builder mBuilder;

    String title = context.getResources().getString(R.string.app_name) + " - "
            + context.getResources().getString(R.string.sec_acc);
    String name;
    String message;
    String messageLong;

    NotificationCompat.InboxStyle inbox = null;
    if (numberNew == 1) {
        name = data.getNewestName(secondAccount);

        // if they are muted, and you don't want them to show muted mentions
        // then just quit
        if (sharedPrefs.getString("muted_users", "").contains(name)
                && !sharedPrefs.getBoolean("show_muted_mentions", false)) {
            return;
        }

        message = context.getResources().getString(R.string.mentioned_by) + " @" + name;
        messageLong = "<b>@" + name + "</b>: " + data.getNewestMessage(secondAccount);
        largeIcon = getImage(context, name);
    } else { // more than one dm
        message = numberNew + " " + context.getResources().getString(R.string.new_mentions);
        messageLong = "<b>" + context.getResources().getString(R.string.mentions) + "</b>: " + numberNew + " "
                + context.getResources().getString(R.string.new_mentions);
        largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.drawer_user_dark);

        inbox = getDMInboxStyle(numberNew, secondAccount, context, message);
    }

    Intent markRead = new Intent(context, MarkReadSecondAccService.class);
    PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0);

    AppSettings settings = AppSettings.getInstance(context);

    Intent deleteIntent = new Intent(context, NotificationDeleteReceiverTwo.class);

    mBuilder = new NotificationCompat.Builder(context).setContentTitle(title)
            .setContentText(TweetLinkUtils.removeColorHtml(message, settings)).setSmallIcon(smallIcon)
            .setLargeIcon(largeIcon).setContentIntent(resultPendingIntent)
            .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0)).setAutoCancel(true)
            .setPriority(NotificationCompat.PRIORITY_HIGH);

    if (inbox == null) {
        mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml(
                settings.addonTheme ? messageLong.replaceAll("FF8800", settings.accentColor) : messageLong)));
    } else {
        mBuilder.setStyle(inbox);
    }

    if (settings.vibrate) {
        mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
    }

    if (settings.sound) {
        try {
            mBuilder.setSound(Uri.parse(settings.ringtone));
        } catch (Exception e) {
            mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
        }
    }

    if (settings.led)
        mBuilder.setLights(0xFFFFFF, 1000, 1000);

    if (settings.notifications) {

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

        notificationManager.notify(9, mBuilder.build());

        // if we want to wake the screen on a new message
        if (settings.wakeScreen) {
            PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
            final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                    | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
            wakeLock.acquire(5000);
        }

        // Pebble notification
        if (sharedPrefs.getBoolean("pebble_notification", false)) {
            sendAlertToPebble(context, title, messageLong);
        }

        // Light Flow notification
        sendToLightFlow(context, title, messageLong);
    }
}