Example usage for android.graphics BitmapFactory decodeResource

List of usage examples for android.graphics BitmapFactory decodeResource

Introduction

In this page you can find the example usage for android.graphics BitmapFactory decodeResource.

Prototype

public static Bitmap decodeResource(Resources res, int id) 

Source Link

Document

Synonym for #decodeResource(Resources,int,android.graphics.BitmapFactory.Options) with null Options.

Usage

From source file:com.perm.DoomPlay.PlayingService.java

private Notification createOldNotif() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);

    Intent intentActivity;/*from w  w  w . ja v  a  2 s. co m*/

    if (SettingActivity.getPreferences(SettingActivity.keyOnClickNotif)) {
        intentActivity = new Intent(FullPlaybackActivity.actionReturnFull);
        intentActivity.setClass(this, FullPlaybackActivity.class);
        intentActivity.putExtra(FileSystemActivity.keyMusic, audios);
    } else {
        intentActivity = FullPlaybackActivity.getReturnSmallIntent(this, audios);
    }
    intentActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    builder.setContentIntent(
            PendingIntent.getActivity(this, 0, intentActivity, PendingIntent.FLAG_UPDATE_CURRENT))
            .setOngoing(true)
            .setSmallIcon(isPlaying ? R.drawable.status_icon_pause : R.drawable.status_icon_play);

    Audio audio = audios.get(indexCurrentTrack);

    builder.setContentTitle(audio.getTitle());
    builder.setContentText(audio.getArtist());

    Bitmap cover = AlbumArtGetter.getBitmapFromStore(audio.getAid(), this);
    if (cover == null) {
        Bitmap tempBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.fallback_cover);
        builder.setLargeIcon(tempBitmap);
        tempBitmap.recycle();
    } else {
        builder.setLargeIcon(cover);
        cover.recycle();
    }

    return builder.build();
}

From source file:cl.iluminadoschile.pako.floatingdiv.CustomOverlayService.java

@Override
protected Notification foregroundNotification(int notificationId) {
    Notification notification;//from   w w w  . j  a  v  a  2 s . c om

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && activation_method.equals(Constants.SETTINGS.ACTIVATION_METHOD_MANUAL)) {
        Intent settingsIntent = new Intent(Intent.ACTION_MAIN);
        settingsIntent.setClassName(Constants.ACTION.prefix, Constants.ACTION.prefix + ".SettingsActivity");
        settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, settingsIntent, 0);

        Intent startFgIntent = new Intent(this, CustomOverlayService.class);
        startFgIntent.setAction(Constants.ACTION.STARTFOREGROUND_ACTION);
        PendingIntent pstartFgIntent = PendingIntent.getService(this, 0, startFgIntent, 0);

        Intent pauseFgIntent = new Intent(this, CustomOverlayService.class);
        pauseFgIntent.setAction(Constants.ACTION.PAUSEFOREGROUND_ACTION);
        PendingIntent ppauseFgIntent = PendingIntent.getService(this, 0, pauseFgIntent, 0);

        Intent stopFgIntent = new Intent(this, CustomOverlayService.class);
        stopFgIntent.setAction(Constants.ACTION.STOPFOREGROUND_ACTION);
        PendingIntent pstopFgIntent = PendingIntent.getService(this, 0, stopFgIntent, 0);

        Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);

        notification = new NotificationCompat.Builder(this)
                .setContentTitle(getString(R.string.title_notification))
                .setTicker(getString(R.string.title_notification))
                .setContentText(getString(R.string.message_notification)).setSmallIcon(R.drawable.ic_launcher)
                .setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false)).setContentIntent(pendingIntent)
                .setOngoing(true).addAction(android.R.drawable.ic_media_play, "Start", pstartFgIntent)
                .addAction(android.R.drawable.ic_media_pause, "Pause", ppauseFgIntent)
                .addAction(android.R.drawable.ic_delete, "Stop", pstopFgIntent).build();

    } else {
        notification = new Notification(R.drawable.ic_launcher, getString(R.string.title_notification),
                System.currentTimeMillis());

        notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT
                | Notification.FLAG_ONLY_ALERT_ONCE;

        notification.setLatestEventInfo(this, getString(R.string.title_notification),
                getString(R.string.message_notification_manual), notificationIntent());
    }
    return notification;
}

From source file:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java

private Bitmap getFallback() {
    Bitmap bm = null;/*from w  w w  .  j  av a2s. c o  m*/
    View view = v.get();
    if (view != null) {
        String key = Integer.toString(fallback);
        bm = memGet(key);
        if (bm == null) {
            bm = BitmapFactory.decodeResource(view.getResources(), fallback);
            if (bm != null) {
                memPut(key, bm);
            }
        }
    }
    return bm;
}

From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.main_frag, container, false);
    setRetainInstance(true);/* w w w . ja v a  2s  .  c  o  m*/
    listView = (android.support.v7.widget.RecyclerView) rootView.findViewById(R.id.listView);
    mToolbarContainer = (AppBarLayout) getActivity().findViewById(R.id.lin);
    fastScroller = (FastScroller) rootView.findViewById(R.id.fastscroll);
    fastScroller.setPressedHandleColor(Color.parseColor(fabSkin));
    listView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (adapter != null && stopAnims) {
                stopAnimation();
                stopAnims = false;
            }
            return false;
        }
    });
    mToolbarContainer.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (adapter != null && stopAnims) {
                stopAnimation();
                stopAnims = false;
            }
            return false;
        }
    });

    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.activity_main_swipe_refresh_layout);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            loadlist((CURRENT_PATH), false, openMode);
        }
    });
    buttons = (LinearLayout) getActivity().findViewById(R.id.buttons);
    pathbar = (LinearLayout) getActivity().findViewById(R.id.pathbar);
    SHOW_THUMBS = sharedPref.getBoolean("showThumbs", true);
    res = getResources();
    pathname = (TextView) getActivity().findViewById(R.id.pathname);
    mFullPath = (TextView) getActivity().findViewById(R.id.fullpath);
    //String itemsstring = res.getString(R.string.items);// TODO: 23/5/2017 use or delete
    apk = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.ic_doc_apk_grid));
    mToolbarContainer.setBackgroundColor(MainActivity.currentTab == 1 ? skinTwoColor : skin_color);

    if (!sharedPref.getBoolean("intelliHideToolbar", true)) {
        AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) getActivity()
                .findViewById(R.id.action_bar).getLayoutParams();
        params.setScrollFlags(0);
        mToolbarContainer.setExpanded(true, true);
    }

    //   listView.setPadding(listView.getPaddingLeft(), paddingTop, listView.getPaddingRight(), listView.getPaddingBottom());
    return rootView;
}

From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java

private Bitmap getFallback() {

    Bitmap bm = null;/* ww w  .  j a va2  s. com*/

    View view = v.get();
    if (view != null) {

        String key = Integer.toString(fallback);
        bm = memGet(key);

        if (bm == null) {
            bm = BitmapFactory.decodeResource(view.getResources(), fallback);

            if (bm != null) {
                memPut(key, bm);
            }
        }
    }

    return bm;
}

From source file:com.cleanwiz.applock.ui.activity.LockMainActivity.java

void share() {
    Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
    String imgPath = FileService.createShareImage(bm, this);
    String title = getString(R.string.pwdsetting_share_detail);
    String text = getString(R.string.pwdsetting_share_text);

    shareMsg(title, title, text, imgPath);
}

From source file:com.roamprocess1.roaming4world.ui.messages.MessageAdapter.java

private void outgoingImage(String numb) {
    Log.setLogLevel(6);//from  w  w  w .j ava 2 s .  c o m
    Log.d("outgoingImage", "call");
    iv_recievedfile = (ImageView) v.findViewById(R.id.iv_recievedfile);

    if (isimagemsginit(subject)) {
        pb_uploading.setVisibility(ProgressBar.VISIBLE);
    } else {
        pb_uploading.setVisibility(ProgressBar.GONE);
    }

    if (isvideoMsg(subject)) {
        text_view.setVisibility(TextView.GONE);
        iv_recievedfile.setVisibility(ImageView.VISIBLE);
        Bitmap b = BitmapFactory.decodeResource(context.getResources(), R.drawable.google_video_icon);
        iv_recievedfile.setImageBitmap(b);
    } else if (isaudioMsg(subject)) {
        text_view.setVisibility(TextView.GONE);
        iv_recievedfile.setVisibility(ImageView.VISIBLE);
        Bitmap b = BitmapFactory.decodeResource(context.getResources(), R.drawable.google_audio_icon);
        iv_recievedfile.setImageBitmap(b);
    } else if (islocationMsg(subject)) {
        text_view.setVisibility(TextView.GONE);
        iv_recievedfile.setVisibility(ImageView.VISIBLE);
        Bitmap b = BitmapFactory.decodeResource(context.getResources(), R.drawable.google_map_icon);
        iv_recievedfile.setImageBitmap(b);
    } else if (iscontactMsg(subject)) {
        tv_msg_info.setText("1");
        text_view.setVisibility(TextView.GONE);
        iv_recievedfile.setVisibility(ImageView.VISIBLE);
        Bitmap b = BitmapFactory.decodeResource(context.getResources(), R.drawable.google_contact_icon);
        iv_recievedfile.setImageBitmap(b);
    } else if (isimageMsg(subject)) {
        text_view.setVisibility(TextView.GONE);
        iv_recievedfile.setVisibility(ImageView.VISIBLE);
        Log.d("subject outgoingImage", subject);

        if (subject.contains("@@")) {
            String[] fileuriarr = subject.split("@@");
            String fileuri = fileuriarr[1];
            String[] namm = fileuri.split("-");
            String path = Environment.getExternalStorageDirectory() + "/R4W/SharingImage/" + stripNumber(numb)
                    + "/send/" + namm[2];
            Log.d("fileuri1", fileuri);
            Log.d("path1", path);
            File user_imageFile = new File(path);
            if (user_imageFile.exists()) {
                Bitmap b = BitmapFactory.decodeFile(path);

                int[] size = messageActivity.getBitmapSize(b);
                b = Bitmap.createScaledBitmap(b, size[0], size[1], false);
                Log.d("imageFile.exists", "true");
                Log.d("bitmap", b.getWidth() + " @");
                iv_recievedfile.setImageBitmap(b);
                /*
                 iv_recievedfile.setImageURI(Uri.parse(imageFile.getAbsolutePath()));
                 Log.d("imageFile.getAbsolutePath()", imageFile.getAbsolutePath());
                 */
            }
        }

    } else {
        text_view.setVisibility(TextView.VISIBLE);
        iv_recievedfile.setVisibility(ImageView.GONE);
        pb_uploading.setVisibility(ProgressBar.GONE);
    }
}

From source file:com.irccloud.android.activity.MainActivity.java

@SuppressLint("NewApi")
@SuppressWarnings({ "deprecation", "unchecked" })
@Override/*ww  w  .  ja  v a 2  s  .c  o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    suggestionsTimer = new Timer("suggestions-timer");
    countdownTimer = new Timer("messsage-countdown-timer");

    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    registerReceiver(screenReceiver, filter);

    if (Build.VERSION.SDK_INT >= 21) {
        Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
        if (cloud != null) {
            setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name),
                    cloud, 0xFFF2F7FC));
            cloud.recycle();
        }
    }
    setContentView(R.layout.activity_message);
    try {
        setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    } catch (Throwable t) {
    }

    suggestionsAdapter = new SuggestionsAdapter();
    progressBar = (ProgressBar) findViewById(R.id.progress);
    errorMsg = (TextView) findViewById(R.id.errorMsg);
    buffersListView = findViewById(R.id.BuffersList);
    messageContainer = (LinearLayout) findViewById(R.id.messageContainer);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);

    redColor = getResources().getColor(R.color.highlight_red);
    blueColor = getResources().getColor(R.color.dark_blue);

    messageTxt = (ActionEditText) findViewById(R.id.messageTxt);
    messageTxt.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (sendBtn.isEnabled()
                    && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED
                    && event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER
                    && messageTxt.getText() != null && messageTxt.getText().length() > 0) {
                sendBtn.setEnabled(false);
                new SendTask().execute((Void) null);
            } else if (keyCode == KeyEvent.KEYCODE_TAB) {
                if (event.getAction() == KeyEvent.ACTION_DOWN)
                    nextSuggestion();
                return true;
            }
            return false;
        }
    });
    messageTxt.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (drawerLayout != null && v == messageTxt && hasFocus) {
                drawerLayout.closeDrawers();
                update_suggestions(false);
            } else if (!hasFocus) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        suggestionsContainer.setVisibility(View.INVISIBLE);
                    }
                });
            }
        }
    });
    messageTxt.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (drawerLayout != null) {
                drawerLayout.closeDrawers();
            }
        }
    });
    messageTxt.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            if (sendBtn.isEnabled()
                    && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED
                    && actionId == EditorInfo.IME_ACTION_SEND && messageTxt.getText() != null
                    && messageTxt.getText().length() > 0) {
                sendBtn.setEnabled(false);
                new SendTask().execute((Void) null);
            }
            return true;
        }
    });
    textWatcher = new TextWatcher() {
        public void afterTextChanged(Editable s) {
            Object[] spans = s.getSpans(0, s.length(), Object.class);
            for (Object o : spans) {
                if (((s.getSpanFlags(o) & Spanned.SPAN_COMPOSING) != Spanned.SPAN_COMPOSING)
                        && (o.getClass() == StyleSpan.class || o.getClass() == ForegroundColorSpan.class
                                || o.getClass() == BackgroundColorSpan.class
                                || o.getClass() == UnderlineSpan.class || o.getClass() == URLSpan.class)) {
                    s.removeSpan(o);
                }
            }
            if (s.length() > 0
                    && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) {
                sendBtn.setEnabled(true);
                if (Build.VERSION.SDK_INT >= 11)
                    sendBtn.setAlpha(1);
            } else {
                sendBtn.setEnabled(false);
                if (Build.VERSION.SDK_INT >= 11)
                    sendBtn.setAlpha(0.5f);
            }
            String text = s.toString();
            if (text.endsWith("\t")) { //Workaround for Swype
                text = text.substring(0, text.length() - 1);
                messageTxt.setText(text);
                nextSuggestion();
            } else if (suggestionsContainer != null && suggestionsContainer.getVisibility() == View.VISIBLE) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        update_suggestions(false);
                    }
                });
            } else {
                if (suggestionsTimer != null) {
                    if (suggestionsTimerTask != null)
                        suggestionsTimerTask.cancel();
                    suggestionsTimerTask = new TimerTask() {
                        @Override
                        public void run() {
                            Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
                            update_suggestions(false);
                        }
                    };
                    suggestionsTimer.schedule(suggestionsTimerTask, 250);
                }
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    };
    messageTxt.addTextChangedListener(textWatcher);
    sendBtn = findViewById(R.id.sendBtn);
    sendBtn.setFocusable(false);
    sendBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED)
                new SendTask().execute((Void) null);
        }
    });

    photoBtn = findViewById(R.id.photoBtn);
    if (photoBtn != null) {
        photoBtn.setFocusable(false);
        photoBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                insertPhoto();
            }
        });
    }
    userListView = findViewById(R.id.usersListFragment);

    View v = getLayoutInflater().inflate(R.layout.actionbar_messageview, null);
    v.findViewById(R.id.actionTitleArea).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            show_topic_popup();
        }
    });

    if (drawerLayout != null) {
        if (findViewById(R.id.usersListFragment2) == null) {
            upDrawable = new DrawerArrowDrawable(this);
            greyColor = upDrawable.getColor();
            ((Toolbar) findViewById(R.id.toolbar)).setNavigationIcon(upDrawable);
            ((Toolbar) findViewById(R.id.toolbar)).setNavigationContentDescription("Show navigation drawer");
            drawerLayout.setDrawerListener(mDrawerListener);
            if (refreshUpIndicatorTask != null)
                refreshUpIndicatorTask.cancel(true);
            refreshUpIndicatorTask = new RefreshUpIndicatorTask();
            refreshUpIndicatorTask.execute((Void) null);
        }
    }
    messageTxt.setDrawerLayout(drawerLayout);

    title = (TextView) v.findViewById(R.id.title);
    subtitle = (TextView) v.findViewById(R.id.subtitle);
    key = (ImageView) v.findViewById(R.id.key);
    getSupportActionBar().setCustomView(v);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    if (savedInstanceState != null && savedInstanceState.containsKey("cid")) {
        server = ServersDataSource.getInstance().getServer(savedInstanceState.getInt("cid"));
        buffer = BuffersDataSource.getInstance().getBuffer(savedInstanceState.getInt("bid"));
        backStack = (ArrayList<Integer>) savedInstanceState.getSerializable("backStack");
    }

    if (savedInstanceState != null && savedInstanceState.containsKey("imagecaptureuri"))
        imageCaptureURI = Uri.parse(savedInstanceState.getString("imagecaptureuri"));
    else
        imageCaptureURI = null;

    ConfigInstance config = (ConfigInstance) getLastCustomNonConfigurationInstance();
    if (config != null) {
        imgurTask = config.imgurUploadTask;
        fileUploadTask = config.fileUploadTask;
    }

    drawerLayout.setScrimColor(0);
    drawerLayout.closeDrawers();

    getSupportActionBar().setElevation(0);
}

From source file:net.olejon.spotcommander.WebViewActivity.java

@Override
public void onPause() {
    super.onPause();

    mActivityIsPaused = true;/*from   ww w  . j  a  v a 2s  .  c o m*/

    if (mWakeLock.isHeld())
        mWakeLock.release();

    if (!mHasLongPressedBack) {
        final String nowplaying_artist = mTools.getSharedPreferencesString("NOWPLAYING_ARTIST");
        final String nowplaying_title = mTools.getSharedPreferencesString("NOWPLAYING_TITLE");

        if (!nowplaying_artist.equals(getString(R.string.notification_no_music_is_playing_artist))) {
            if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
                Wearable.NodeApi.getConnectedNodes(mGoogleApiClient)
                        .setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() {
                            @Override
                            public void onResult(
                                    @NonNull NodeApi.GetConnectedNodesResult getConnectedNodesResult) {
                                mNotificationBuilder.setWhen(0)
                                        .setSmallIcon(R.drawable.ic_play_arrow_white_24dp)
                                        .setLargeIcon(BitmapFactory.decodeResource(getResources(),
                                                R.mipmap.ic_launcher))
                                        .setContentTitle(getString(R.string.project_name))
                                        .setContentIntent(mLaunchActivityPendingIntent)
                                        .setTicker(nowplaying_artist + " - " + nowplaying_title)
                                        .extend(new NotificationCompat.WearableExtender().setHintHideIcon(true)
                                                .setBackground(BitmapFactory.decodeResource(getResources(),
                                                        R.drawable.notification_background))
                                                .addAction(new NotificationCompat.Action.Builder(
                                                        R.drawable.notification_icon,
                                                        getString(R.string.notification_action_play_pause),
                                                        mPlayPausePendingIntent).build())
                                                .addAction(new NotificationCompat.Action.Builder(
                                                        R.drawable.ic_skip_next_white_24dp,
                                                        getString(R.string.notification_action_next),
                                                        mNextPendingIntent).build())
                                                .addAction(new NotificationCompat.Action.Builder(
                                                        R.drawable.ic_volume_down_white_24dp,
                                                        getString(R.string.notification_action_volume_down),
                                                        mVolumeDownPendingIntent).build())
                                                .addAction(new NotificationCompat.Action.Builder(
                                                        R.drawable.ic_volume_up_white_24dp,
                                                        getString(R.string.notification_action_volume_up),
                                                        mVolumeUpPendingIntent).build())
                                                .setContentIcon(R.drawable.notification_icon)
                                                .setContentAction(0));

                                if (getConnectedNodesResult.getNodes().size() > 0) {
                                    mNotificationBuilder
                                            .setContentText(getString(R.string.notification_wear_text))
                                            .addAction(R.drawable.ic_skip_previous_white_24dp,
                                                    getString(R.string.notification_action_previous),
                                                    mPreviousPendingIntent)
                                            .addAction(R.drawable.ic_play_arrow_white_24dp,
                                                    getString(R.string.notification_action_play_pause),
                                                    mPlayPausePendingIntent)
                                            .addAction(R.drawable.ic_skip_next_white_24dp,
                                                    getString(R.string.notification_action_next),
                                                    mNextPendingIntent);

                                    mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());
                                } else if (mPersistentNotificationIsSupported
                                        && mTools.getSharedPreferencesBoolean("PERSISTENT_NOTIFICATION")) {
                                    mNotificationBuilder.setOngoing(true)
                                            .setContentText(getString(R.string.notification_mobile_text))
                                            .addAction(R.drawable.ic_close_white_24dp,
                                                    getString(R.string.notification_action_hide),
                                                    mHidePendingIntent)
                                            .addAction(R.drawable.ic_play_arrow_white_24dp,
                                                    getString(R.string.notification_action_play_pause),
                                                    mPlayPausePendingIntent)
                                            .addAction(R.drawable.ic_skip_next_white_24dp,
                                                    getString(R.string.notification_action_next),
                                                    mNextPendingIntent);

                                    mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());
                                }
                            }
                        });
            } else if (mPersistentNotificationIsSupported
                    && mTools.getSharedPreferencesBoolean("PERSISTENT_NOTIFICATION")) {
                mNotificationBuilder.setWhen(0).setOngoing(true)
                        .setSmallIcon(R.drawable.ic_play_arrow_white_24dp)
                        .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
                        .setContentTitle(getString(R.string.project_name))
                        .setContentText(getString(R.string.notification_mobile_text))
                        .setContentIntent(mLaunchActivityPendingIntent)
                        .setTicker(nowplaying_artist + " - " + nowplaying_title)
                        .addAction(R.drawable.ic_close_white_24dp, getString(R.string.notification_action_hide),
                                mHidePendingIntent)
                        .addAction(R.drawable.ic_play_arrow_white_24dp,
                                getString(R.string.notification_action_play_pause), mPlayPausePendingIntent)
                        .addAction(R.drawable.ic_skip_next_white_24dp,
                                getString(R.string.notification_action_next), mNextPendingIntent);

                mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());
            }
        }
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        //noinspection deprecation
        CookieSyncManager.getInstance().sync();
    }

    mWebView.pauseTimers();
}

From source file:com.amansoni.tripbook.activity.FacebookActivity.java

private void postPhoto() {
    Bitmap image = BitmapFactory.decodeResource(this.getResources(), R.drawable.empty_photo);
    if (canPresentShareDialogWithPhotos) {
        FacebookDialog shareDialog = createShareDialogBuilderForPhoto(image).build();
        uiHelper.trackPendingDialogCall(shareDialog.present());
    } else if (hasPublishPermission()) {
        Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), image,
                new Request.Callback() {
                    @Override//from  w  ww.j a  v  a 2s. c o  m
                    public void onCompleted(Response response) {
                        showPublishResult(getString(R.string.photo_post), response.getGraphObject(),
                                response.getError());
                    }
                });
        request.executeAsync();
    } else {
        pendingAction = PendingAction.POST_PHOTO;
    }
}