Example usage for android.content Intent getLongExtra

List of usage examples for android.content Intent getLongExtra

Introduction

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

Prototype

public long getLongExtra(String name, long defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.songcode.materialnotes.ui.NoteEditActivity.java

private boolean initActivityState(Intent intent) {
    /**/*from w  w  w .ja v a  2 s.c  o m*/
     * If the user specified the {@link Intent#ACTION_VIEW} but not provided with id,
     * then jump to the NotesListActivity
     */
    mWorkingNote = null;
    if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) {
        long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0);
        mUserQuery = "";

        /**
         * Starting from the searched result
         */
        if (intent.hasExtra(SearchManager.EXTRA_DATA_KEY)) {
            noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
            mUserQuery = intent.getStringExtra(SearchManager.USER_QUERY);
        }

        if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) {
            Intent jump = new Intent(this, NotesListActivity.class);
            startActivity(jump);
            showToast(R.string.error_note_not_exist);
            finish();
            return false;
        } else {
            mWorkingNote = WorkingNote.load(this, noteId);
            if (mWorkingNote == null) {
                Log.e(TAG, "load note failed with note id" + noteId);
                finish();
                return false;
            }
        }
    } else if (TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {
        // New note
        long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0);
        int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        int widgetType = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_TYPE, Notes.TYPE_WIDGET_INVALIDE);
        int bgResId = intent.getIntExtra(Notes.INTENT_EXTRA_BACKGROUND_ID, ResourceParser.getDefaultBgId(this));

        // Parse call-record note
        String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        long callDate = intent.getLongExtra(Notes.INTENT_EXTRA_CALL_DATE, 0);
        if (callDate != 0 && phoneNumber != null) {
            if (TextUtils.isEmpty(phoneNumber)) {
                Log.w(TAG, "The call record number is null");
            }
            long noteId = 0;
            if ((noteId = DataUtils.getNoteIdByPhoneNumberAndCallDate(getContentResolver(), phoneNumber,
                    callDate)) > 0) {
                mWorkingNote = WorkingNote.load(this, noteId);
                if (mWorkingNote == null) {
                    Log.e(TAG, "load call note failed with note id" + noteId);
                    finish();
                    return false;
                }
            } else {
                mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId);
                mWorkingNote.convertToCallNote(phoneNumber, callDate);
            }
        } else {
            mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId);
        }
    } else {
        Log.e(TAG, "Intent not specified action, should not support");
        finish();
        return false;
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
            | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mWorkingNote.setOnSettingStatusChangedListener(this);
    return true;
}

From source file:org.smssecure.smssecure.ConversationActivity.java

private void initializeReceivers() {
    securityUpdateReceiver = new BroadcastReceiver() {
        @Override//w w w .ja  v  a2 s  .com
        public void onReceive(Context context, Intent intent) {
            long eventThreadId = intent.getLongExtra("thread_id", -1);

            if (eventThreadId == threadId || eventThreadId == -2) {
                initializeSecurity();
                updateRecipientPreferences();
                calculateCharactersRemaining();
            }
        }
    };

    registerReceiver(securityUpdateReceiver, new IntentFilter(SecurityEvent.SECURITY_UPDATE_EVENT),
            KeyCachingService.KEY_PERMISSION, null);
}

From source file:com.ichi2.anki.StudyOptionsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    Timber.d("onActivityResult (requestCode = %d, resultCode = %d)", requestCode, resultCode);

    // rebuild action bar
    configureToolbar();/*from   w ww  .  j  a v  a  2s .c o  m*/

    // boot back to deck picker if there was an error
    if (resultCode == DeckPicker.RESULT_DB_ERROR || resultCode == DeckPicker.RESULT_MEDIA_EJECTED) {
        closeStudyOptions(resultCode);
        return;
    }

    // perform some special actions depending on which activity we're returning from
    if (requestCode == STATISTICS || requestCode == BROWSE_CARDS) {
        // select original deck if the statistics or card browser were opened,
        // which can change the selected deck
        if (intent.hasExtra("originalDeck")) {
            getCol().getDecks().select(intent.getLongExtra("originalDeck", 0L));
        }
    }
    if (requestCode == DECK_OPTIONS) {
        if (mLoadWithDeckOptions == true) {
            mLoadWithDeckOptions = false;
            try {
                JSONObject deck = getCol().getDecks().current();
                if (deck.getInt("dyn") != 0 && deck.has("empty")) {
                    deck.remove("empty");
                }
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
            mProgressDialog = StyledProgressDialog.show(getActivity(), "",
                    getResources().getString(R.string.rebuild_cram_deck), true);
            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_REBUILD_CRAM, getDeckTaskListener(true),
                    new DeckTask.TaskData(mFragmented));
        } else {
            DeckTask.waitToFinish();
            refreshInterface(true);
        }
    } else if (requestCode == AnkiActivity.REQUEST_REVIEW) {
        if (resultCode == Reviewer.RESULT_NO_MORE_CARDS) {
            // If no more cards getting returned while counts > 0 (due to learn ahead limit) then show a snackbar
            int[] counts = getCol().getSched().counts();
            if ((counts[0] + counts[1] + counts[2]) > 0 && mStudyOptionsView != null) {
                View rootLayout = mStudyOptionsView.findViewById(R.id.studyoptions_main);
                AnkiActivity activity = (AnkiActivity) getActivity();
                activity.showSnackbar(R.string.studyoptions_no_cards_due, false, 0, null, rootLayout);
            }
        }
    } else if (requestCode == STATISTICS && mCurrentContentView == CONTENT_CONGRATS) {
        mCurrentContentView = CONTENT_STUDY_OPTIONS;
        setFragmentContentView(mStudyOptionsView);
    }
}

From source file:org.awesomeapp.messenger.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {

        if (requestCode == REQUEST_CHANGE_SETTINGS) {
            finish();/* www.ja  va  2  s .co  m*/
            startActivity(new Intent(this, MainActivity.class));
        } else if (requestCode == REQUEST_ADD_CONTACT) {

            String username = data.getStringExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAME);
            long providerId = data.getLongExtra(ContactsPickerActivity.EXTRA_RESULT_PROVIDER, -1);
            long accountId = data.getLongExtra(ContactsPickerActivity.EXTRA_RESULT_ACCOUNT, -1);

            startChat(providerId, accountId, username, false, false);

        } else if (requestCode == REQUEST_CHOOSE_CONTACT) {
            String username = data.getStringExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAME);

            if (username != null) {
                long providerId = data.getLongExtra(ContactsPickerActivity.EXTRA_RESULT_PROVIDER, -1);
                long accountId = data.getLongExtra(ContactsPickerActivity.EXTRA_RESULT_ACCOUNT, -1);

                startChat(providerId, accountId, username, true, true);
            } else {

                ArrayList<String> users = data
                        .getStringArrayListExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAMES);
                if (users != null) {
                    //start group and do invite here
                    startGroupChat(users);
                }

            }
        } else if (requestCode == ConversationDetailActivity.REQUEST_TAKE_PICTURE) {
            if (mLastPhoto != null)
                importPhoto();

        } else if (requestCode == OnboardingManager.REQUEST_SCAN) {

            ArrayList<String> resultScans = data.getStringArrayListExtra("result");
            for (String resultScan : resultScans) {

                try {

                    String address = null;

                    if (resultScan.startsWith("xmpp:")) {
                        address = XmppUriHelper.parse(Uri.parse(resultScan)).get(XmppUriHelper.KEY_ADDRESS);
                        String fingerprint = XmppUriHelper.getOtrFingerprint(resultScan);
                        new AddContactAsyncTask(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(), mApp)
                                .execute(address, fingerprint);

                    } else {
                        //parse each string and if they are for a new user then add the user
                        String[] parts = OnboardingManager.decodeInviteLink(resultScan);
                        address = parts[0];
                        String fingerprint = null, nickname = null;
                        if (parts.length > 1)
                            fingerprint = parts[1];
                        if (parts.length > 2)
                            nickname = parts[2];
                        new AddContactAsyncTask(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(), mApp)
                                .execute(address, fingerprint, nickname);
                    }

                    if (address != null)
                        startChat(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(), address, false,
                                false);

                    //if they are for a group chat, then add the group
                } catch (Exception e) {
                    Log.w(ImApp.LOG_TAG, "error parsing QR invite link", e);
                }
            }
        }
    }
}

From source file:org.totschnig.myexpenses.activity.MyExpenses.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (requestCode == EDIT_TRANSACTION_REQUEST && resultCode == RESULT_OK) {
        long nextReminder;
        sequenceCount = intent.getLongExtra(ContribInfoDialogFragment.KEY_SEQUENCE_COUNT, 0);
        if (Utils.IS_FLAVOURED) {
            nextReminder = PrefKey.NEXT_REMINDER_RATE.getLong(TRESHOLD_REMIND_RATE);
            if (nextReminder != -1 && sequenceCount >= nextReminder) {
                RemindRateDialogFragment f = new RemindRateDialogFragment();
                f.setCancelable(false);//  w  w  w. j  ava  2  s  .c  om
                f.show(getSupportFragmentManager(), "REMIND_RATE");
                return;
            }
        }
        if (!MyApplication.getInstance().getLicenceHandler().isContribEnabled()) {
            nextReminder = PrefKey.NEXT_REMINDER_CONTRIB.getLong(TRESHOLD_REMIND_CONTRIB);
            if (nextReminder != -1 && sequenceCount >= nextReminder) {
                CommonCommands.showContribInfoDialog(this, sequenceCount);
                return;
            }
        }
        adHandler.onEditTransactionResult();
    }
    if (requestCode == CREATE_ACCOUNT_REQUEST && resultCode == RESULT_OK) {
        mAccountId = intent.getLongExtra(KEY_ROWID, 0);
    }
}

From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java

private SafeBroadcastReceiver getBroadcastReceiver() {
    return new SafeBroadcastReceiver() {
        @Override//from  w  w  w  .  ja v a  2  s. c om
        public String[] onSafeReceive(Context context, Intent intent) {
            T.UI();
            if (intent.getAction().equals(FriendsPlugin.FRIEND_INFO_RECEIVED_INTENT)) {
                final String emailHash = intent.getStringExtra(EMAILHASH);
                if (emailHash != null && emailHash.equals(mExpectedEmailHash)) {
                    abortProcessing();

                    if (intent.getBooleanExtra(ProcessScanActivity.SUCCESS, true)) {
                        final Intent inviteFriendIntent = new Intent(ProcessScanActivity.this,
                                InviteFriendActivity.class);
                        // Copy extra from other intent
                        for (String extra : new String[] { AVATAR, DESCRIPTION, DESCRIPTION_BRANDING, EMAIL,
                                EMAILHASH, NAME, QUALIFIED_IDENTIFIER }) {
                            inviteFriendIntent.putExtra(extra, intent.getStringExtra(extra));
                        }
                        inviteFriendIntent.putExtra(TYPE,
                                intent.getLongExtra(TYPE, FriendsPlugin.FRIEND_TYPE_USER));
                        startActivity(inviteFriendIntent);
                        finish();
                        return new String[] { intent.getAction() };
                    } else {
                        showError(intent);
                    }

                } else {
                    // ignore
                }
            } else if (intent.getAction().equals(FriendsPlugin.SERVICE_ACTION_INFO_RECEIVED_INTENT)) {
                if (mExpectedEmailHash != null && mExpectedEmailHash.equals(intent.getStringExtra(EMAILHASH))
                        && mExpectedAction != null
                        && mExpectedAction.equals(intent.getStringExtra(POKE_ACTION))) {
                    abortProcessing();

                    if (intent.getBooleanExtra(SUCCESS, true)) {
                        final Intent serviceActionIntent = new Intent(ProcessScanActivity.this,
                                ServiceActionActivity.class);
                        // Copy extra from other intent
                        for (String extra : new String[] { AVATAR, DESCRIPTION, DESCRIPTION_BRANDING, EMAIL,
                                NAME, POKE_DESCRIPTION, QUALIFIED_IDENTIFIER, STATIC_FLOW, STATIC_FLOW_HASH }) {
                            serviceActionIntent.putExtra(extra, intent.getStringExtra(extra));
                        }
                        serviceActionIntent.putExtra(EMAILHASH, mExpectedEmailHash);
                        serviceActionIntent.putExtra(POKE_ACTION, mExpectedAction);
                        serviceActionIntent.setAction(FriendsPlugin.SERVICE_ACTION_INFO_RECEIVED_INTENT);
                        serviceActionIntent.putExtra(SUCCESS, true);
                        startActivity(serviceActionIntent);
                        finish();
                        // TODO: set success?

                        return new String[] { intent.getAction() };
                    } else {
                        showError(intent);
                    }
                } else {
                    // ignore
                }
            } else if (intent.getAction().equals(URL_REDIRECTION_DONE)) {
                final String emailHash = intent.getStringExtra(EMAILHASH);
                if (intent.hasExtra(POKE_ACTION)) {
                    final String pokeAction = intent.getStringExtra(POKE_ACTION);
                    getServiceActionInfo(emailHash, pokeAction);
                } else {
                    processEmailHash(emailHash);
                }
                return new String[] { intent.getAction() };
            }

            return null; // Intent was ignored
        }

    };
}

From source file:it.ciopper90.gojack2.MessageListActivity.java

/**
 * Parse data pushed by {@link Intent}./*from   w w w. j a  va  2s.  co m*/
 * 
 * @param intent
 *            {@link Intent}
 */
private void parseIntent(final Intent intent) {
    Log.d(TAG, "parseIntent(" + intent + ")");
    if (intent == null) {
        return;
    }
    Log.d(TAG, "got action: " + intent.getAction());
    Log.d(TAG, "got uri: " + intent.getData());

    this.needContactUpdate = true;

    this.uri = intent.getData();
    if (this.uri != null) {
        if (!this.uri.toString().startsWith(URI)) {
            this.uri = Uri.parse(URI + this.uri.getLastPathSegment());
        }
    } else {
        final long tid = intent.getLongExtra("thread_id", -1L);
        this.uri = Uri.parse(URI + tid);
        if (tid < 0L) {
            try {
                // this.startActivity(ConversationListActivity.getComposeIntent(this,
                // null));
            } catch (ActivityNotFoundException e) {
                Log.e(TAG, "activity not found", e);
                Toast.makeText(this, R.string.error_conv_null, Toast.LENGTH_LONG).show();
            }
            this.finish();
            return;
        }
    }

    final int threadId = Integer.parseInt(this.uri.getLastPathSegment());
    final Conversation c = Conversation.getConversation(this, threadId, true);
    this.conv = c;

    if (c == null) {
        Toast.makeText(this, R.string.error_conv_null, Toast.LENGTH_LONG).show();
        this.finish();
        return;
    }

    final Contact contact = c.getContact();
    contact.update(this, false, true);

    Log.d(TAG, "address: " + contact.getNumber());
    Log.d(TAG, "name: " + contact.getName());
    Log.d(TAG, "displayName: " + contact.getDisplayName());

    final ListView lv = this.getListView();
    lv.setStackFromBottom(true);

    MessageAdapter adapter = new MessageAdapter(this, this.uri);
    this.setListAdapter(adapter);

    String displayName = contact.getDisplayName();
    this.setTitle(displayName);
    number = contact.getNumber();
    if (displayName.equals(number)) {
        this.getSupportActionBar().setSubtitle(null);
        number = contact.getDisplayName();
    } else {
        this.getSupportActionBar().setSubtitle(number);
    }
    // this.getSupportActionBar().setDisplayUseLogoEnabled(false);
    // this.getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    this.getSupportActionBar().setDisplayShowHomeEnabled(false);

    // this.spinner = WSInterface.setSpinner(this);
    if (MessageListActivity.alert == null) {
        MessageListActivity.alert = "";
    }
    // this.getSupportActionBar().setIcon(R.drawable.ic_menu_star);
    // this.getSupportActionBar().
    // this.ws = new WorkServizio(this.getApplicationContext());

    // service = this.ws.caricaServizio();
    // this.spinner = new Spinner(this);
    // ArrayList<String> lista = new ArrayList<String>();
    // for (int i = 0; i < service.size(); i++) {
    // lista.add(service.get(i).getName());
    // }
    // lista.add("a");
    // lista.add("b");
    // lista.add("c");

    // this.spinneradapter = new ArrayAdapter<String>(this,
    // R.layout.textview, lista);
    // this.spinner.setAdapter(this.spinneradapter);

    // String serv = WSInterface.ServizioNumero(number);
    // if (serv != null) {
    // int a = lista.indexOf(serv);
    // lista.indexOf(serv));
    // }
    // TODO attach to an adapter of some sort
    // this.getSupportActionBar().setCustomView(this.spinner);
    // this.getSupportActionBar().setDisplayShowCustomEnabled(true);
    // this.setContactIcon(contact);

    if (MessageListActivity.alert.equals("captcha")) {
        this.captcha();// Dialog.RestoreDialog(this, this.alert);
    } else {
        if (MessageListActivity.alert.equals("error")) {
            this.error(MessageListActivity.errore);
        } else {
            if (!MessageListActivity.alert.equals("")) {
                MessageListActivity.pd = Dialog.ProgDialog(this, MessageListActivity.alert);
                MessageListActivity.pd.show();
            }
        }
    }

    final String body = intent.getStringExtra(Intent.EXTRA_TEXT);
    if (!TextUtils.isEmpty(body)) {
        MessageListActivity.etText.setText(body);
    }

    this.setRead();
}

From source file:com.lugia.timetable.ReminderService.java

@Override
protected void onHandleIntent(Intent intent) {
    String action = intent.getAction();

    Log.d("ReminderService", "Handle intent : " + action);

    Bundle extra = intent.getExtras();//from www .ja v a 2 s .  c o  m

    String subjectCode = extra.getString(EXTRA_SUBJECT_CODE);
    String header = extra.getString(EXTRA_HEADER);
    String content = extra.getString(EXTRA_CONTENT);

    String boardcastIntent = null;

    Intent notificationIntent = new Intent();
    Uri soundUri = null;

    int notificationId;
    boolean vibrate;

    if (action.equals(ACTION_SCHEDULE_REMINDER)) {
        notificationId = SCHEDULE_NOTIFICATION_ID;

        vibrate = SettingActivity.getBoolean(ReminderService.this, SettingActivity.KEY_SCHEDULE_NOTIFY_VIBRATE,
                false);

        String soundUriStr = SettingActivity.getString(ReminderService.this,
                SettingActivity.KEY_SCHEDULE_NOTIFY_SOUND, "");

        notificationIntent.setClass(ReminderService.this, SubjectDetailActivity.class)
                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                .putExtra(SubjectDetailActivity.EXTRA_SUBJECT_CODE, subjectCode);

        soundUri = !TextUtils.isEmpty(soundUriStr) ? Uri.parse(soundUriStr) : null;

        boardcastIntent = ReminderReceiver.ACTION_UPDATE_SCHEDULE_REMINDER;
    } else if (action.equals(ACTION_EVENT_REMINDER)) {
        long eventId = intent.getLongExtra(EXTRA_EVENT_ID, -1);

        notificationId = EVENT_NOTIFICATION_ID;

        vibrate = SettingActivity.getBoolean(ReminderService.this, SettingActivity.KEY_EVENT_NOTIFY_VIBRATE,
                false);

        String soundUriStr = SettingActivity.getString(ReminderService.this,
                SettingActivity.KEY_EVENT_NOTIFY_SOUND, "");

        notificationIntent.setClass(ReminderService.this, SubjectDetailActivity.class)
                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(SubjectDetailActivity.ACTION_VIEW_EVENT)
                .putExtra(SubjectDetailActivity.EXTRA_EVENT_ID, eventId)
                .putExtra(SubjectDetailActivity.EXTRA_SUBJECT_CODE, subjectCode);

        soundUri = !TextUtils.isEmpty(soundUriStr) ? Uri.parse(soundUriStr) : null;

        boardcastIntent = ReminderReceiver.ACTION_UPDATE_EVENT_REMINDER;
    } else {
        Log.e(TAG, "Unknow action!");

        return;
    }

    PendingIntent pendingIntent = PendingIntent.getActivity(ReminderService.this, 0, notificationIntent, 0);

    Notification notification = new NotificationCompat.Builder(ReminderService.this)
            .setSmallIcon(R.drawable.ic_notification_reminder).setTicker(header).setContentTitle(header)
            .setContentText(content).setContentIntent(pendingIntent).setAutoCancel(true)
            .setWhen(System.currentTimeMillis()).build();

    // always show the notification light
    notification.defaults |= Notification.DEFAULT_LIGHTS;
    notification.flags |= Notification.FLAG_SHOW_LIGHTS;

    // only vibrate when user enable it
    if (vibrate)
        notification.defaults |= Notification.DEFAULT_VIBRATE;

    // set the notification sound
    notification.sound = soundUri;

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

    manager.notify(notificationId, notification);

    // update the reminder, so it will notify user again on next schedule
    Intent broadcastIntent = new Intent(ReminderService.this, ReminderReceiver.class);
    broadcastIntent.setAction(boardcastIntent);

    sendBroadcast(broadcastIntent);
}

From source file:org.awesomeapp.messenger.MainActivity.java

private void handleIntent() {

    Intent intent = getIntent();

    if (intent != null) {
        Uri data = intent.getData();//from  www  . j  a  v  a 2  s .  co  m
        String type = intent.getType();
        if (data != null && Imps.Chats.CONTENT_ITEM_TYPE.equals(type)) {

            long chatId = ContentUris.parseId(data);

            Intent intentChat = new Intent(this, ConversationDetailActivity.class);
            intentChat.putExtra("id", chatId);
            startActivity(intentChat);
        } else if (Imps.Contacts.CONTENT_ITEM_TYPE.equals(type)) {
            long providerId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID,
                    mApp.getDefaultProviderId());
            long accountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID,
                    mApp.getDefaultAccountId());
            String username = intent.getStringExtra(ImServiceConstants.EXTRA_INTENT_FROM_ADDRESS);
            startChat(providerId, accountId, username, true, true);
        } else if (intent.hasExtra("username")) {
            //launch a new chat based on the intent value
            startChat(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(),
                    intent.getStringExtra("username"), true, true);
        }

        setIntent(null);
    }
}

From source file:com.jesusla.google.BillingService.java

/**
 * The {@link BillingReceiver} sends messages to this service using intents.
 * Each intent has an action and some extra arguments specific to that action.
 * @param intent the intent containing one of the supported actions
 * @param startId an identifier for the invocation instance of this service
 *///from   w w w.  j  a v a 2  s .  c  om
public void handleCommand(Intent intent, int startId) {
    String action = intent.getAction();
    if (Consts.DEBUG) {
        Log.i(TAG, "handleCommand() action: " + action);
    }
    if (Consts.ACTION_CONFIRM_NOTIFICATION.equals(action)) {
        String[] notifyIds = intent.getStringArrayExtra(Consts.NOTIFICATION_ID);
        confirmNotifications(startId, notifyIds);
    } else if (Consts.ACTION_GET_PURCHASE_INFORMATION.equals(action)) {
        String notifyId = intent.getStringExtra(Consts.NOTIFICATION_ID);
        getPurchaseInformation(startId, new String[] { notifyId });
    } else if (Consts.ACTION_PURCHASE_STATE_CHANGED.equals(action)) {
        String signedData = intent.getStringExtra(Consts.INAPP_SIGNED_DATA);
        String signature = intent.getStringExtra(Consts.INAPP_SIGNATURE);
        purchaseStateChanged(startId, signedData, signature);
    } else if (Consts.ACTION_RESPONSE_CODE.equals(action)) {
        long requestId = intent.getLongExtra(Consts.INAPP_REQUEST_ID, -1);
        int responseCodeIndex = intent.getIntExtra(Consts.INAPP_RESPONSE_CODE,
                ResponseCode.RESULT_ERROR.ordinal());
        ResponseCode responseCode = ResponseCode.valueOf(responseCodeIndex);
        checkResponseCode(requestId, responseCode);
    }
}