Example usage for android.content Intent getExtras

List of usage examples for android.content Intent getExtras

Introduction

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

Prototype

public @Nullable Bundle getExtras() 

Source Link

Document

Retrieves a map of extended data from the intent.

Usage

From source file:com.github.wakhub.monodict.activity.FlashcardActivity.java

@OnActivityResult(REQUEST_CODE_SELECT_DIRECTORY_TO_EXPORT)
void onActivityResultSelectDirectoryToExport(int resultCode, Intent data) {
    if (resultCode != RESULT_OK) {
        return;/*from  w  ww  . j a  v a2  s. c o  m*/
    }
    String path = data.getExtras().getString(DirectorySelectorActivity.RESULT_INTENT_PATH);

    String defaultPath = String.format("%s/%s-%s.json", path, getResources().getString(R.string.app_name),
            DateTimeUtils.getInstance().getCurrentDateTimeString());
    activityHelper.buildInputDialog(defaultPath, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            TextView textView = (TextView) ((Dialog) dialogInterface).findViewById(android.R.id.text1);
            String outputPath = textView.getText().toString();
            exportCardsTo(outputPath);
        }
    }).setTitle(R.string.action_export).show();
}

From source file:edu.mit.mobile.android.locast.data.MediaSync.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    final Uri data = intent.getData();
    final SyncQueueItem syncQueueItem = new SyncQueueItem(data, intent.getExtras());
    if (!mSyncQueue.contains(syncQueueItem) && !checkRecentlySyncd(data)) {
        if (DEBUG) {
            Log.d(TAG, "enqueueing " + syncQueueItem);
        }/*from  w  w  w . j a va2 s  .  com*/
        mSyncQueue.add(syncQueueItem);
    } else {
        if (DEBUG) {
            Log.d(TAG, syncQueueItem.toString() + " already in the queue. Skipping.");
        }
    }

    maybeStartTask();

    return START_REDELIVER_INTENT;
}

From source file:com.example.vedantn.algaeestimator.MainActivity.java

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

    //Processing image from camera
    if (requestCode == CAMERA_REQUEST_CODE && resultCode == RESULT_OK) {
        ImageView userImage = (ImageView) findViewById(R.id.userImage);
        Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
        userImage.setImageBitmap(thumbnail);
    }/*from   w w  w .  j a  va 2s. co m*/

}

From source file:com.android.mms.ui.ConversationList.java

@Override
protected void onStart() {
    super.onStart();
    if (notDeleting) {
        MessagingNotification.cancelNotification(getApplicationContext(),
                SmsRejectedReceiver.SMS_REJECTED_NOTIFICATION_ID);

        DraftCache.getInstance().addOnDraftChangedListener(this);

        Intent it = getIntent();
        Bundle bundle = it.getExtras();
        if (bundle != null) {
            fromFolder = bundle.getBoolean("fromFolder", false);
        }/*  w  w w.j  a v a 2  s .  c  o  m*/
        if (fromFolder) {
            mNeedToMarkAsSeen = false;
        } else {
            mNeedToMarkAsSeen = true;
        }

        int dropNum = Conversation.cleanExpiredWapPush(this);
        if (0 < dropNum) {
            Toast.makeText(this, getResources().getString(R.string.dl_expired_wap_push, dropNum),
                    Toast.LENGTH_LONG).show();
        }

        startAsyncQuery();

        // We used to refresh the DraftCache here, but
        // refreshing the DraftCache each time we go to the ConversationList seems overly
        // aggressive. We already update the DraftCache when leaving CMA in onStop() and
        // onNewIntent(), and when we delete threads or delete all in CMA or this activity.
        // I hope we don't have to do such a heavy operation each time we enter here.

        // we invalidate the contact cache here because we want to get updated presence
        // and any contact changes. We don't invalidate the cache by observing presence and contact
        // changes (since that's too untargeted), so as a tradeoff we do it here.
        // If we're in the middle of the app initialization where we're loading the conversation
        // threads, don't invalidate the cache because we're in the process of building it.
        // TODO: think of a better way to invalidate cache more surgically or based on actual
        // TODO: changes we care about
        if (!Conversation.loadingThreads()) {
            Contact.invalidateCache();
        }

        // Listen for broadcast intents that indicate the SMS is ready
        IntentFilter filter = new IntentFilter(TelephonyIntents.ACTION_IS_SIM_SMS_READY);
        //===== fixed CR<NEWMS00127040> by luning at 11-10-07 begin =====
        filter.addAction(TelephonyIntents.ACTION_IS_SIM_SMS_READY1);
        registerReceiver(mReceiver, filter);
    }
}

From source file:com.newtifry.android.UpdaterService.java

public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);

    // Null intent? Weird, but deal with it.
    if (intent == null) {
        return;/*from   ww w  . ja  va2  s.co m*/
    }

    // Fetch a wakelock if we don't already have one.
    // TODO: This is disabled until I can figure out the "under locked" exception.
    /*if( this.wakelock == null )
    {
       PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);
       this.wakelock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
       this.wakelock.acquire(60000); // Max 60 seconds.
    }*/

    // We need to make some kind of backend request.
    String type = intent.getExtras().getString("type");

    if (type.equals("registration")) {
        // We want to update our registration key with the server.
        // Get a list of accounts. We need to send it to any enabled ones on the backend.
        ArrayList<NewtifryAccount> accounts = NewtifryAccount.FACTORY.listAll(this);

        String newRegistration = intent.getExtras().getString("registration");

        // TODO: Notify the user if this fails.
        for (NewtifryAccount account : accounts) {
            if (account.getEnabled()) {
                HashMap<String, Object> metadata = new HashMap<String, Object>();
                metadata.put("account", account);
                metadata.put("operation", "register");
                metadata.put("registration", newRegistration);
                account.registerWithBackend(this, newRegistration, true, null, handler, metadata);
            }
        }
    } else if (type.equals("sourcechange")) {
        // Somewhere, a source has changed or been added. We should pull down a local one.
        Long serverSourceId = intent.getLongExtra("sourceId", 0);
        Long serverDeviceId = intent.getLongExtra("deviceId", 0);

        BackendRequest request = new BackendRequest("/sources/get");
        request.add("id", serverSourceId.toString());
        request.addMeta("operation", "updatedSource");
        request.addMeta("context", this);
        request.addMeta("source_id", serverSourceId);
        request.addMeta("account_id", serverDeviceId);

        // Where to come back when we're done.
        request.setHandler(handler);

        NewtifryAccount account = NewtifryAccount.FACTORY.getByServerId(this, serverDeviceId);

        // Start a thread to make the request.
        // But if there was no account to match that device, don't bother.
        if (account != null) {
            request.startInThread(this, null, account.getAccountName());
        }
    }
}

From source file:com.mikecorrigan.bohrium.pubsub.RegistrationClient.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.v(TAG, "onStartCommand: intent=" + intent + ", extras=" + Utils.bundleToString(intent.getExtras())
            + ", flags=" + flags + ", startId=" + startId);

    if (intent.getAction().equals(C2DM_INTENT_REGISTRATION)) {
        mHandler.sendMessage(mHandler.obtainMessage(EVENT_C2DM_REGISTRATION_RESPONSE, intent));
        GCMBroadcastReceiver.completeWakefulIntent(intent);
    } else if (intent.getAction().equals(C2DM_INTENT_RECEIVE)) {
        mHandler.sendMessage(mHandler.obtainMessage(EVENT_C2DM_MESSAGE, intent));
        GCMBroadcastReceiver.completeWakefulIntent(intent);
    } else if (intent.getAction().equals(C2DM_INTENT_RETRY)) {
        mHandler.sendMessage(mHandler.obtainMessage(EVENT_C2DM_RETRY_REGISTRATION, intent));
        GCMBroadcastReceiver.completeWakefulIntent(intent);
    } else if (intent.getAction().equals(Intent.ACTION_MAIN)) {
        if (mConfiguration == null) {
            mConfiguration = intent.getExtras();
        }//from   www  .  jav  a  2s .  c om

        mHandler.sendEmptyMessage(EVENT_INITIALIZE);
    } else if (intent.getAction().equals(Intent.ACTION_SHUTDOWN)) {
        mHandler.sendEmptyMessage(EVENT_UNINITIALIZE);
    }

    return RegistrationClient.START_STICKY;
}

From source file:com.krayzk9s.imgurholo.ui.ImagesFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d("requestcode", requestCode + "");
    if (data.getExtras() == null)
        return;//from  w ww . j av  a2 s . c  o  m
    Object bundle = data.getExtras().get("data");
    Log.d("HELO", bundle.getClass().toString());
    switch (requestCode) {
    case 1:
        super.onActivityResult(requestCode, resultCode, data);
        ArrayList<String> imageIds = data.getStringArrayListExtra("data");
        if (imageIds != null)
            Log.d("Ids!", imageIds.toString());
        AddImagesToAlbumAsync imageAsync = new AddImagesToAlbumAsync(imageIds,
                ((ImgurHoloActivity) getActivity()).getApiCall(), albumId);
        imageAsync.execute();
        break;
    }
}

From source file:com.soomla.billing.IabHelper.java

int getResponseCodeFromIntent(Intent i) {
    Object o = i.getExtras().get(RESPONSE_CODE);
    if (o == null) {
        StoreUtils.LogError(TAG, "Intent with no response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {/*from  w w w  .  jav  a 2  s .co m*/
        StoreUtils.LogError(TAG, "Unexpected type for intent response code.");
        StoreUtils.LogError(TAG, o.getClass().getName());
        throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
    }
}

From source file:com.timemachine.controller.ControllerActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String input = intent.getStringExtra(SearchManager.QUERY);
        String suggestion = (String) intent.getExtras().get("intent_extra_data_key");
        String query;//w w w  . ja v a2  s .  c o  m
        // Use the query to search your data somehow
        if (suggestion == null)
            query = input;
        else
            query = suggestion;
        Geocoder geocoder = new Geocoder(ControllerActivity.this);
        try {
            List<Address> address = geocoder.getFromLocationName(query, 1);
            if (address != null && !address.isEmpty()) {
                Address location = address.get(0);
                System.out.println(location.getLatitude() + ", " + location.getLongitude());
                mMap.animateCamera(
                        CameraUpdateFactory.newLatLngZoom(
                                new LatLng(location.getLatitude(), location.getLongitude()), maxZoom),
                        animateCameraDuration, null);
            } else
                System.out.println("No address found.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:eu.thecoder4.gpl.pleftdroid.EventDetailActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK && data != null) {
        Bundle extras = data.getExtras();
        int SC;//from   ww w  .  j  a va2s . co  m

        switch (requestCode) {
        case ACT_COMMENT:
            String comment = extras.getString(AR_COMMENT);
            int datepos = extras.getInt(AR_DTID);
            getAvailForPerson(curpid, adates.get(datepos).getId());
            updateAvailCommentForPerson(curpid, adates.get(datepos).getId(), comment);
            voteadateadapter.notifyDataSetChanged();
            break;
        case ACT_ADDINVITEE:
            String participant = extras.getString(AR_EMAIL);
            SC = PleftBroker.inviteAnotherParticipant(aid, participant, apserver, auser, avcode);
            if (SC >= HttpStatus.SC_BAD_REQUEST) { //400
                Toast.makeText(this, R.string.toast_problemrequest, Toast.LENGTH_LONG).show();
            } else {
                startActivity(getIntent());
                finish();
            }
            break;
        case ACT_NEWDATE:
            int[] thedate = extras.getIntArray(AR_DATE);
            int[] thetime = extras.getIntArray(AR_TIME);
            PDate td = new PDate(thedate, thetime);
            String newdate = td.getPleftDate();
            //TODO Check if this date and time is the same of one of the current dates!!!
            SC = PleftBroker.proposeNewDate(aid, newdate, apserver, auser, avcode);
            if (SC >= HttpStatus.SC_BAD_REQUEST) { //400
                Toast.makeText(this, R.string.toast_problemrequest, Toast.LENGTH_LONG).show();
            } else {
                startActivity(getIntent());
                finish();
            }
            break;
        }
    }
}