Example usage for android.content Intent getParcelableExtra

List of usage examples for android.content Intent getParcelableExtra

Introduction

In this page you can find the example usage for android.content Intent getParcelableExtra.

Prototype

public <T extends Parcelable> T getParcelableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.cmput301w17t07.moody.CreateMoodActivity.java

/**
 * Method handles user interface response to when a user adds an image to their mood
 * from either their camera or their gallery. <br>
 *
 * Knowledge and logic of onActivityResult referenced and taken from <br>
 * link: http://blog.csdn.net/AndroidStudioo/article/details/52077597 <br>
 * author: AndroidStudio 2016-07-31 11:15 <br>
 * taken by Xin Huang 2017-03-04 15:30 <br>
 * @param requestCode          integer indicating the kind of action taken by the user <br>
 * @param resultCode <br>/*from   w w  w .j  ava2s  .c  o m*/
 * @param data <br>
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (data == null) {
        finish(); //no data return
    }
    if (requestCode == 0) {
        //get pic from local photo
        try {
            bitmap = data.getParcelableExtra("data");
            if (bitmap == null) {//if pic is not so big use original one
                try {
                    InputStream inputStream = getContentResolver().openInputStream(data.getData());
                    bitmap = BitmapFactory.decodeStream(inputStream);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            }
        } catch (RuntimeException e) {
            Intent intent = new Intent(getApplicationContext(), CreateMoodActivity.class);
            startActivity(intent);
        }

    } else if (requestCode == 1) {
        try {
            bitmap = (Bitmap) data.getExtras().get("data");
        } catch (Exception e) {
            Intent intent = new Intent(getApplicationContext(), CreateMoodActivity.class);
            startActivity(intent);
        }
    } else if (resultCode == Activity.RESULT_CANCELED) {
        try {
            Intent intent = new Intent(getApplicationContext(), CreateMoodActivity.class);
            startActivity(intent);
        } catch (RuntimeException e) {
        }

    }
    mImageView.setImageBitmap(bitmap);

}

From source file:com.cuddlesoft.nori.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Request window manager features.
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    // Get shared preferences.
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    // Inflate views.
    setContentView(R.layout.activity_search);

    // Get search result grid fragment from fragment manager.
    searchResultGridFragment = (SearchResultGridFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragment_searchResultGrid);

    // If the activity was started from a Search intent, create the SearchClient object and submit search.
    Intent intent = getIntent();
    if (intent != null && intent.getAction().equals(Intent.ACTION_SEARCH)
            && searchResultGridFragment.getSearchResult() == null) {
        SearchClient.Settings searchClientSettings = intent
                .getParcelableExtra(BUNDLE_ID_SEARCH_CLIENT_SETTINGS);
        searchClient = searchClientSettings.createSearchClient();
        doSearch(intent.getStringExtra(BUNDLE_ID_SEARCH_QUERY));
    }/*w  w  w . ja v  a  2s .co m*/

    // Set up the dropdown API server picker.
    setUpActionBar();
}

From source file:com.concentricsky.android.khanacademy.data.KADataService.java

/**
 * Used for long-running operations including library updates and video downloads.
 * /*from  w  w w  .java  2 s .  co m*/
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("KADataService", "Received start id " + startId + ": " + intent);

    PendingIntent pendingIntent = null;
    if (intent.hasExtra(Intent.EXTRA_INTENT)) {
        // TODO : use this intent. It needs to be called with the results of requestLibraryUpdate (so far)
        pendingIntent = intent.getParcelableExtra(Intent.EXTRA_INTENT);
    }

    if (ACTION_LIBRARY_UPDATE.equals(intent.getAction())) {
        requestLibraryUpdate(startId, pendingIntent, intent.getBooleanExtra(EXTRA_FORCE, false));
        return START_REDELIVER_INTENT;
    }

    if (ACTION_UPDATE_DOWNLOAD_STATUS.equals(intent.getAction())) {
        Log.d(LOG_TAG, "update download status");
        updateDownloadStatus(intent, pendingIntent, startId);
        return START_REDELIVER_INTENT;
    }

    /*
    START_NOT_STICKY
    Do not recreate the service, unless there are pending intents to deliver. This is the 
    safest option to avoid running your service when not necessary and when your application 
    can simply restart any unfinished jobs.
    START_STICKY
    Recreate the service and call onStartCommand(), but do not redeliver the last intent. 
    Instead, the system calls onStartCommand() with a null intent, unless there were pending 
    intents to start the service, in which case, those intents are delivered. This is suitable 
    for media players (or similar services) that are not executing commands, but running 
    indefinitely and waiting for a job.
    START_REDELIVER_INTENT
    Recreate the service and call onStartCommand() with the last intent that was delivered 
    to the service. Any pending intents are delivered in turn. This is suitable for services 
    that are actively performing a job that should be immediately resumed, such as downloading a file.
     */

    // If we reach this point, the intent has some unknown action, so just ignore it and stop.
    this.stopSelfResult(startId);
    return START_NOT_STICKY;
}

From source file:com.facebook.AccessTokenManagerTest.java

@Test
public void testChangingAccessTokenSendsBroadcast() {
    AccessTokenManager accessTokenManager = createAccessTokenManager();

    AccessToken accessToken = createAccessToken();

    accessTokenManager.setCurrentAccessToken(accessToken);

    final Intent intents[] = new Intent[1];
    final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
        @Override/*from w  ww.j  ava 2s  . c om*/
        public void onReceive(Context context, Intent intent) {
            intents[0] = intent;
        }
    };

    localBroadcastManager.registerReceiver(broadcastReceiver,
            new IntentFilter(AccessTokenManager.ACTION_CURRENT_ACCESS_TOKEN_CHANGED));

    AccessToken anotherAccessToken = createAccessToken("another string", "1000");

    accessTokenManager.setCurrentAccessToken(anotherAccessToken);

    localBroadcastManager.unregisterReceiver(broadcastReceiver);

    Intent intent = intents[0];

    assertNotNull(intent);

    AccessToken oldAccessToken = (AccessToken) intent
            .getParcelableExtra(AccessTokenManager.EXTRA_OLD_ACCESS_TOKEN);
    AccessToken newAccessToken = (AccessToken) intent
            .getParcelableExtra(AccessTokenManager.EXTRA_NEW_ACCESS_TOKEN);

    assertEquals(accessToken.getToken(), oldAccessToken.getToken());
    assertEquals(anotherAccessToken.getToken(), newAccessToken.getToken());
}

From source file:com.nbplus.vbroadlauncher.RadioActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Constants.OPEN_BETA_PHONE && LauncherSettings.getInstance(this).isSmartPhone()) {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }/*  ww  w . ja v a2s.c om*/

    mSettingsContentObserver = new SettingsContentObserver(this, new Handler());
    getApplicationContext().getContentResolver().registerContentObserver(
            android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserver);

    showProgressDialog();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(getResources().getColor(R.color.activity_radio_background));
    }

    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
    setContentView(R.layout.activity_radio);

    Intent i = getIntent();
    mShortcutData = i.getParcelableExtra(Constants.EXTRA_NAME_SHORTCUT_DATA);
    if (mShortcutData == null) {
        Log.e(TAG, "mShortcutData is not found..");
        finishActivity();
        return;
    }

    IntentFilter filter = new IntentFilter();
    filter.addAction(MusicService.ACTION_PLAYED);
    filter.addAction(MusicService.ACTION_PAUSED);
    filter.addAction(MusicService.ACTION_STOPPED);
    filter.addAction(MusicService.ACTION_COMPLETED);
    filter.addAction(MusicService.ACTION_ERROR);
    filter.addAction(MusicService.ACTION_PLAYING_STATUS);

    LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, filter);
    // send playing status
    Intent queryStatus = new Intent(this, MusicService.class);
    queryStatus.setAction(MusicService.ACTION_PLAYING_STATUS);
    startService(queryStatus);

    // ViewPager .
    // ??? ? ? ? .
    mViewPager = (NbplusViewPager) findViewById(R.id.viewPager);
    mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);

    // close button
    ImageButton closeButton = (ImageButton) findViewById(R.id.btn_close);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finishActivity();
        }
    });

    mActivityLayout = (RelativeLayout) findViewById(R.id.radio_activity_background);
    int wallpaperId = LauncherSettings.getInstance(this).getWallpaperId();
    mActivityLayout.setBackgroundResource(LauncherSettings.landWallpaperResource[wallpaperId]);

    // title.
    mRadioTitle = (TextView) findViewById(R.id.radio_activity_label);

    // media controller
    mPlayToggle = (ImageButton) findViewById(R.id.ic_media_control_play);
    mPlayToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mCurrentPlayingStatus == null) {
                return;
            }
            MusicService.State state = (MusicService.State) mCurrentPlayingStatus
                    .getSerializable(MusicService.EXTRA_PLAYING_STATUS);
            Intent i = new Intent(RadioActivity.this, MusicService.class);
            if (state == MusicService.State.Playing) {
                i.setAction(MusicService.ACTION_PAUSE);
            } else if (state == MusicService.State.Paused) {
                i.setAction(MusicService.ACTION_PLAY);
            }
            startService(i);
        }
    });
    mPlayStop = (ImageButton) findViewById(R.id.ic_media_control_stop);
    mPlayStop.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mCurrentPlayingStatus == null) {
                return;
            }
            MusicService.State state = (MusicService.State) mCurrentPlayingStatus
                    .getSerializable(MusicService.EXTRA_PLAYING_STATUS);
            if (state == MusicService.State.Playing || state == MusicService.State.Paused) {
                Intent i = new Intent(RadioActivity.this, MusicService.class);
                i.setAction(MusicService.ACTION_STOP);
                i.putExtra(MusicService.EXTRA_MUSIC_FORCE_STOP, false);
                startService(i);
            }
        }
    });

    mSoundToggle = (ImageButton) findViewById(R.id.ic_media_control_volume_btn);
    AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    int currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
    int maxVolume = audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    if (currentVolume <= 0) {
        mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_off);
    } else {
        mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_on);
    }
    mSoundToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

            if (audio.getStreamVolume(AudioManager.STREAM_MUSIC) <= 0) {
                if (mSoundTogglePreviousValue > 0) {
                    audio.setStreamVolume(AudioManager.STREAM_MUSIC, mSoundTogglePreviousValue,
                            AudioManager.FLAG_PLAY_SOUND);
                } else {
                    mSoundTogglePreviousValue = 1;
                    audio.setStreamVolume(AudioManager.STREAM_MUSIC, mSoundTogglePreviousValue,
                            AudioManager.FLAG_PLAY_SOUND);
                }
                mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_on);
                mSeekbar.setProgress(mSoundTogglePreviousValue);
                mSoundTogglePreviousValue = -1;
            } else {
                mSoundTogglePreviousValue = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
                audio.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_PLAY_SOUND);
                mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_off);
            }
        }
    });

    mSeekbar = (SeekBar) findViewById(R.id.ic_media_control_volume_seek);
    mSeekbar.setMax(maxVolume);
    mSeekbar.setProgress(currentVolume);
    mSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                mSoundTogglePreviousValue = -1;
                AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                audio.setStreamVolume(AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_PLAY_SOUND);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    getRadioChannelTask = new GetRadioChannelTask();
    if (getRadioChannelTask != null) {
        getRadioChannelTask.setBroadcastApiData(this, mHandler,
                mShortcutData.getDomain() + mShortcutData.getPath());
        mIsExecuteGetRadioChannelTask = true;
        getRadioChannelTask.execute();
    }
}

From source file:org.lol.reddit.activities.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences);

    if (solidblack)
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));

    final Intent intent = getIntent();

    mUrl = General.uriFromString(intent.getDataString());
    final RedditPost src_post = intent.getParcelableExtra("post");

    if (mUrl == null) {
        General.quickToast(this, "Invalid URL. Trying web browser.");
        revertToWeb();/*from   w  ww  .j a v  a 2 s.c  o m*/
        return;
    }

    Log.i("ImageViewActivity", "Loading URL " + mUrl.toString());

    final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);

    final LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(progressBar);

    CacheManager.getInstance(this)
            .makeRequest(new CacheRequest(mUrl, RedditAccountManager.getAnon(), null,
                    Constants.Priority.IMAGE_VIEW, 0, CacheRequest.DownloadType.IF_NECESSARY,
                    Constants.FileType.IMAGE, false, false, false, this) {

                private void setContentView(View v) {
                    layout.removeAllViews();
                    layout.addView(v);
                    v.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
                    v.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
                }

                @Override
                protected void onCallbackException(Throwable t) {
                    BugReportActivity.handleGlobalError(context.getApplicationContext(),
                            new RRError(null, null, t));
                }

                @Override
                protected void onDownloadNecessary() {
                    General.UI_THREAD_HANDLER.post(new Runnable() {
                        @Override
                        public void run() {
                            progressBar.setVisibility(View.VISIBLE);
                            progressBar.setIndeterminate(true);
                        }
                    });
                }

                @Override
                protected void onDownloadStarted() {
                }

                @Override
                protected void onFailure(final RequestFailureType type, Throwable t, StatusLine status,
                        final String readableMessage) {

                    final RRError error = General.getGeneralErrorForFailure(context, type, t, status,
                            url.toString());

                    General.UI_THREAD_HANDLER.post(new Runnable() {
                        public void run() {
                            // TODO handle properly
                            progressBar.setVisibility(View.GONE);
                            layout.addView(new ErrorView(ImageViewActivity.this, error));
                        }
                    });
                }

                @Override
                protected void onProgress(final long bytesRead, final long totalBytes) {
                    General.UI_THREAD_HANDLER.post(new Runnable() {
                        @Override
                        public void run() {
                            progressBar.setVisibility(View.VISIBLE);
                            progressBar.setIndeterminate(false);
                            progressBar.setProgress((int) ((100 * bytesRead) / totalBytes));
                        }
                    });
                }

                @Override
                protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp,
                        UUID session, boolean fromCache, final String mimetype) {

                    if (mimetype == null || !Constants.Mime.isImage(mimetype)) {
                        revertToWeb();
                        return;
                    }

                    final InputStream cacheFileInputStream;
                    try {
                        cacheFileInputStream = cacheFile.getInputStream();
                    } catch (IOException e) {
                        notifyFailure(RequestFailureType.PARSE, e, null,
                                "Could not read existing cached image.");
                        return;
                    }

                    if (cacheFileInputStream == null) {
                        notifyFailure(RequestFailureType.CACHE_MISS, null, null, "Could not find cached image");
                        return;
                    }

                    if (Constants.Mime.isImageGif(mimetype)) {

                        if (AndroidApi.isIceCreamSandwichOrLater()) {

                            General.UI_THREAD_HANDLER.post(new Runnable() {
                                public void run() {
                                    try {
                                        final GIFView gifView = new GIFView(ImageViewActivity.this,
                                                cacheFileInputStream);
                                        setContentView(gifView);
                                        gifView.setOnClickListener(new View.OnClickListener() {
                                            public void onClick(View v) {
                                                finish();
                                            }
                                        });

                                    } catch (OutOfMemoryError e) {
                                        General.quickToast(context, R.string.imageview_oom);
                                        revertToWeb();

                                    } catch (Throwable e) {
                                        General.quickToast(context, R.string.imageview_invalid_gif);
                                        revertToWeb();
                                    }
                                }
                            });

                        } else {

                            gifThread = new GifDecoderThread(cacheFileInputStream,
                                    new GifDecoderThread.OnGifLoadedListener() {

                                        public void onGifLoaded() {
                                            General.UI_THREAD_HANDLER.post(new Runnable() {
                                                public void run() {
                                                    imageView = new ImageView(context);
                                                    imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
                                                    setContentView(imageView);
                                                    gifThread.setView(imageView);

                                                    imageView.setOnClickListener(new View.OnClickListener() {
                                                        public void onClick(View v) {
                                                            finish();
                                                        }
                                                    });
                                                }
                                            });
                                        }

                                        public void onOutOfMemory() {
                                            General.quickToast(context, R.string.imageview_oom);
                                            revertToWeb();
                                        }

                                        public void onGifInvalid() {
                                            General.quickToast(context, R.string.imageview_invalid_gif);
                                            revertToWeb();
                                        }
                                    });

                            gifThread.start();

                        }

                    } else {

                        final long bytes = cacheFile.getSize();
                        final byte[] buf = new byte[(int) bytes];

                        try {
                            new DataInputStream(cacheFileInputStream).readFully(buf);
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }

                        final ImageTileSource imageTileSource;
                        try {
                            imageTileSource = new ImageTileSourceWholeBitmap(buf);

                        } catch (OutOfMemoryError e) {
                            General.quickToast(context, R.string.imageview_oom);
                            revertToWeb();
                            return;

                        } catch (Throwable t) {
                            Log.e("ImageViewActivity", "Exception when creating ImageTileSource", t);
                            General.quickToast(context, R.string.imageview_decode_failed);
                            revertToWeb();
                            return;
                        }

                        General.UI_THREAD_HANDLER.post(new Runnable() {
                            public void run() {

                                surfaceView = new RRGLSurfaceView(ImageViewActivity.this,
                                        new ImageViewDisplayListManager(imageTileSource,
                                                ImageViewActivity.this));
                                setContentView(surfaceView);

                                surfaceView.setOnClickListener(new View.OnClickListener() {
                                    public void onClick(View v) {
                                        finish();
                                    }
                                });

                                if (mIsPaused) {
                                    surfaceView.onPause();
                                } else {
                                    surfaceView.onResume();
                                }
                            }
                        });
                    }
                }
            });

    final RedditPreparedPost post = src_post == null ? null
            : new RedditPreparedPost(this, CacheManager.getInstance(this), 0, src_post, -1, false, false, false,
                    false, RedditAccountManager.getInstance(this).getDefaultAccount(), false);

    final FrameLayout outerFrame = new FrameLayout(this);
    outerFrame.addView(layout);

    if (post != null) {

        final SideToolbarOverlay toolbarOverlay = new SideToolbarOverlay(this);

        final BezelSwipeOverlay bezelOverlay = new BezelSwipeOverlay(this,
                new BezelSwipeOverlay.BezelSwipeListener() {

                    public boolean onSwipe(BezelSwipeOverlay.SwipeEdge edge) {

                        toolbarOverlay.setContents(
                                post.generateToolbar(ImageViewActivity.this, false, toolbarOverlay));
                        toolbarOverlay.show(edge == BezelSwipeOverlay.SwipeEdge.LEFT
                                ? SideToolbarOverlay.SideToolbarPosition.LEFT
                                : SideToolbarOverlay.SideToolbarPosition.RIGHT);
                        return true;
                    }

                    public boolean onTap() {

                        if (toolbarOverlay.isShown()) {
                            toolbarOverlay.hide();
                            return true;
                        }

                        return false;
                    }
                });

        outerFrame.addView(bezelOverlay);
        outerFrame.addView(toolbarOverlay);

        bezelOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
        bezelOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;

        toolbarOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
        toolbarOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;

    }

    setContentView(outerFrame);
}

From source file:com.orangelabs.rcs.ri.messaging.chat.single.SingleChatView.java

@Override
public boolean processIntent(Intent intent) {
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "processIntent ".concat(intent.getAction()));
    }/*from www  .ja  v a  2 s.  c om*/
    ContactId newContact = intent.getParcelableExtra(EXTRA_CONTACT);
    if (newContact == null) {
        if (LogUtils.isActive) {
            Log.w(LOGTAG, "Cannot process intent: contact is null");
        }
        return false;
    }
    try {
        if (!newContact.equals(mContact) || mChat == null) {
            /* Either it is the first conversation loading or switch to another conversation */
            loadConversation(newContact);
        }
        /*
         * Open chat to accept session if the parameter IM SESSION START is 0. Client
         * application is not aware of the one to one chat session state nor of the IM session
         * start mode so we call the method systematically.
         */
        mChat.openChat();

        /* Set activity title with display name */
        String displayName = RcsContactUtil.getInstance(this).getDisplayName(mContact);
        setTitle(getString(R.string.title_chat, displayName));
        /* Mark as read messages if required */
        Map<String, Integer> msgIdUnreads = getUnreadMessageIds(mContact);
        for (Entry<String, Integer> entryMsgIdUnread : msgIdUnreads.entrySet()) {
            if (ChatLog.Message.HISTORYLOG_MEMBER_ID == entryMsgIdUnread.getValue()) {
                mChatService.markMessageAsRead(entryMsgIdUnread.getKey());
            } else {
                mFileTransferService.markFileTransferAsRead(entryMsgIdUnread.getKey());
            }
        }
        if (OneToOneChatIntent.ACTION_MESSAGE_DELIVERY_EXPIRED.equals(intent.getAction())) {
            processUndeliveredMessages(displayName);
        }
        if (FileTransferIntent.ACTION_FILE_TRANSFER_DELIVERY_EXPIRED.equals(intent.getAction())) {
            processUndeliveredFileTransfers(displayName);
        }
        return true;

    } catch (RcsServiceException e) {
        showExceptionThenExit(e);
        return false;
    }
}

From source file:fr.eyal.lib.data.service.DataLibService.java

@SuppressWarnings("unchecked")
@Override//from   w  w  w .  ja  va  2s. c om
protected void onHandleIntent(final Intent intent) {
    final int processorType = intent.getIntExtra(INTENT_EXTRA_PROCESSOR_TYPE, -1);

    Out.d(TAG, "onHandleIntent");

    //      String userAgent = intent.getStringExtra(INTENT_EXTRA_USER_AGENT);

    final DataLibRequest request = new DataLibRequest();
    DataLibWebConfig.applyToRequest(request, DataLibWebConfig.getInstance()); //we apply a default configuration for the request

    //we get the action data
    request.url = intent.getStringExtra(INTENT_EXTRA_URL);
    request.params = intent.getParcelableExtra(INTENT_EXTRA_PARAMS);
    request.parseType = intent.getIntExtra(INTENT_EXTRA_PARSE_TYPE, DataLibRequest.PARSE_TYPE_SAX_XML);

    //we eventually add the complex options
    Object complexOptions = intent.getSerializableExtra(INTENT_EXTRA_COMPLEX_OPTIONS);
    if (complexOptions instanceof ComplexOptions)
        request.complexOptions = (ComplexOptions) complexOptions;

    request.context = getApplicationContext();
    //we get the options to apply
    int option = intent.getIntExtra(INTENT_EXTRA_REQUEST_OPTION, DataLibRequest.OPTION_NO_OPTION);
    DataLibWebConfig.applyToRequest(request, option, true);

    //we add the intent
    request.intent = intent;

    try {

        if (processorType == COOKIES_FLUSH)
            this.flushCookies();

        else {
            //we launch the processor on a daughter class
            launchProcessor(processorType, request);
        }

    } catch (final Exception e) {
        Out.e(TAG, "Erreur", e);
        final BusinessResponse response = new BusinessResponse();
        response.status = BusinessResponse.STATUS_ERROR;
        response.statusMessage = Log.getStackTraceString(e);
        sendResult(request, response, response.status);
    }

}

From source file:com.cmput301w17t07.moody.EditMoodActivity.java

/**
 * Method handles user interface response to when a user adds an image to their mood
 * from either their camera or their gallery.
 *
 * Knowledge and logic of onActivityResult referenced and taken from <br>
 * link: http://blog.csdn.net/AndroidStudioo/article/details/52077597 <br>
 * author: AndroidStudio 2016-07-31 11:15 <br>
 * taken by Xin Huang 2017-03-04 15:30 <br>
 *
 * @param requestCode integer indicating the kind of action taken by the user
 * @param resultCode//  w w  w. j a  v  a  2 s. co m
 * @param data
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    //        ImageView image = (ImageView) findViewById(R.id.editImageView);

    if (data == null) {
        return; //no data return
    }
    if (requestCode == 0) {
        //get pic from local photo
        bitmapImage = data.getParcelableExtra("data");
        if (bitmapImage == null) {//if pic is not so big use original one
            try {
                InputStream inputStream = getContentResolver().openInputStream(data.getData());
                bitmapImage = BitmapFactory.decodeStream(inputStream);
            } catch (FileNotFoundException e) {
                Intent intent = new Intent(getApplicationContext(), ProfileActivity.class);
                startActivity(intent);
            }
        }
    } else if (requestCode == 1) {
        // saveToSDCard(bitmap);
        try {
            bitmapImage = (Bitmap) data.getExtras().get("data");
        } catch (Exception e) {
            Intent intent = new Intent(getApplicationContext(), ProfileActivity.class);
            startActivity(intent);
            finish();
        }
    } else if (resultCode == Activity.RESULT_CANCELED) {
        try {
            Intent intent = new Intent(getApplicationContext(), ProfileActivity.class);
            startActivity(intent);
            finish();
        } catch (Exception e) {
        }
    }
    image.setImageBitmap(bitmapImage);
    editBitmapImage = bitmapImage;

    if (editBitmapImage == null) {
        final ImageButton deletePicture = (ImageButton) findViewById(R.id.deletePicture);
        deletePicture.setVisibility(View.INVISIBLE);
        deletePicture.setEnabled(false);
    } else {
        final ImageButton deletePicture = (ImageButton) findViewById(R.id.deletePicture);
        deletePicture.setVisibility(View.VISIBLE);
        deletePicture.setEnabled(true);
    }
}

From source file:com.fanfou.app.opensource.service.DownloadService.java

@Override
protected void onHandleIntent(final Intent intent) {
    this.nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    final int type = intent.getIntExtra(Constants.EXTRA_TYPE, DownloadService.TYPE_CHECK);
    if (AppContext.DEBUG) {
        Log.d(DownloadService.TAG, "onHandleIntent type=" + type);
    }//from w  w w . j  ava2 s  . c  om
    if (type == DownloadService.TYPE_CHECK) {
        check();
    } else if (type == DownloadService.TYPE_DOWNLOAD) {
        final AppVersionInfo info = intent.getParcelableExtra(Constants.EXTRA_URL);
        log("onHandleIntent TYPE_DOWNLOAD info=" + info);
        if ((info != null) && !TextUtils.isEmpty(info.downloadUrl)) {
            download(info);
        }
    }
}