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:edu.mit.mobile.android.locast.accounts.AuthenticatorActivity.java

/**
 * Called when response is received from the server for confirm credentials request. See
 * onAuthenticationResult(). Sets the AccountAuthenticatorResult which is sent back to the
 * caller.//  ww w.j  a  v  a 2 s  . c  om
 *
 * @param the
 *            confirmCredentials result.
 */
protected void finishConfirmCredentials(boolean result) {
    Log.i(TAG, "finishConfirmCredentials()");
    final Account account = new Account(mUsername, AuthenticationService.ACCOUNT_TYPE);
    mAccountManager.setPassword(account, mPassword);
    final Intent intent = new Intent();
    intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, result);
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK, intent);
    finish();
}

From source file:jen.jobs.application.UpdateJobSeeking.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == SELECT_JOB_SEEKING_STATUS) {
        // Make sure the request was successful
        if (resultCode == RESULT_OK) {
            Bundle filters = data.getExtras();
            JobSeekingStatus selectedValues = (JobSeekingStatus) filters.get("jobseekingstatus");
            if (selectedValues != null) {
                selectedJobSeekingStatusValues = selectedValues;
                selectedJobSeekingStatus.setText(selectedValues.name);
            }//  w  ww  .  j  a  v a2s.c  o  m
        }
    } else if (requestCode == SELECT_COUNTRY) {
        if (resultCode == RESULT_OK) {
            Bundle filters = data.getExtras();
            Country selectedValues = (Country) filters.get("country");

            if (selectedValues != null) {
                selectedCountryValues = selectedValues;
                selectedCountry.setText(selectedValues.name);

                if (selectedValues.id == 127) {
                    selectMalaysiaState.setVisibility(View.VISIBLE);
                    selectMalaysiaStateSibling.setVisibility(View.VISIBLE);
                } else {
                    selectMalaysiaState.setVisibility(View.GONE);
                    selectMalaysiaStateSibling.setVisibility(View.GONE);
                }
            }
        }
    } else if (requestCode == SELECT_STATE) {
        if (resultCode == RESULT_OK) {
            Bundle filters = data.getExtras();
            State c = (State) filters.get("state");
            selectedMalaysiaStateValues = c;
            if (c != null) {
                selectedMalaysiaState.setText(c.name);
            }
        }
    } else if (requestCode == SELECT_JOB_NOTICE) {
        if (resultCode == RESULT_OK) {
            Bundle filters = data.getExtras();
            selectedAvailability = filters.getString("availability");
            selectedAvailabilityUnit = filters.getString("availabilityUnit");
            String a = selectedAvailability + " " + selectedAvailabilityUnit;
            selectedJobNotice.setText(a);
        }
    }
}

From source file:com.rukman.emde.smsgroups.authenticator.GMSAuthenticatorActivity.java

/**
 * Called when response is received from the server for authentication
 * request. See onAuthenticationResult(). Sets the
 * AccountAuthenticatorResult which is sent back to the caller. We store the
 * authToken that's returned from the server as the 'password' for this
 * account - so we're never storing the user's actual password locally.
 *
 * @param result the confirmCredentials result.
 *///  ww w  .j av  a  2s.c om
private void finishLogin(String authToken) {

    Log.i(TAG, "finishLogin()");
    final Account account = new Account(mUsername, GMSApplication.ACCOUNT_TYPE);
    if (mIsUnknownAccountName) {
        mAccountManager.addAccountExplicitly(account, mPassword, null);
        // Set contacts sync for this account.
        ContentResolver.setIsSyncable(account, GMSProvider.AUTHORITY, 1);
        ContentResolver.setSyncAutomatically(account, GMSProvider.AUTHORITY, true);
    } else {
        mAccountManager.setPassword(account, mPassword);
    }
    final Intent intent = new Intent();
    intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, GMSApplication.ACCOUNT_TYPE);
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK, intent);
    finish();
}

From source file:luan.com.flippit.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    mContext = this;
    mPrefs = getSharedPreferences(mContext.getPackageName(), Context.MODE_PRIVATE);
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
    mBuilder = new NotificationCompat.Builder(this);
    activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);

    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

    String message = intent.getStringExtra("message");
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) {
        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
            //sendNotification("Send error: " + extras.toString());
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            //sendNotification("Deleted messages on server: " + extras.toString());
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            manageNotification(message);
        }/* w w w .  j ava  2  s. co m*/
    }
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.lge.friendsCamera.CameraFileListViewActivity.java

/**
 * Set up view based on media type (image or video)
 *///  w w w  .ja va 2s. co m
private void setupViews() {
    setContentView(R.layout.filelistview_layout);
    mListView = (ListView) findViewById(R.id.list_view);

    //Get media type from intent
    Intent intent = getIntent();
    mediaType = intent.getExtras().getString("type");

    if (mediaType.equals(IMAGE)) {
        getSupportActionBar().setTitle(R.string.camera_image_gallery);
    } else {
        getSupportActionBar().setTitle(R.string.camera_video_gallery);
    }
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    adapter = new CustomListAdapter(this, itemInfo, itemBitmap);
}

From source file:com.krayzk9s.imgurholo.activities.ImgurLinkActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    destroyed = false;//from   w  w w.j  a  v a  2 s .c  o  m
    if (getActionBar() != null)
        getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    Log.d("New Intent", intent.toString());
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
            Intent serviceIntent = new Intent(this, UploadService.class);
            if (intent.getExtras() == null)
                finish();
            serviceIntent.setData((Uri) intent.getExtras().get("android.intent.extra.STREAM"));
            startService(serviceIntent);
            finish();
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
        Log.d("sending", "sending multiple");
        Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
        ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        Intent serviceIntent = new Intent(this, UploadService.class);
        serviceIntent.putParcelableArrayListExtra("images", list);
        startService(serviceIntent);
        finish();
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null
            && intent.getData().toString().startsWith("http://imgur.com/a")) {
        String uri = intent.getData().toString();
        album = uri.split("/")[4];
        Log.d("album", album);
        Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM);
        fetcher.execute();
    } else if (Intent.ACTION_VIEW.equals(action)
            && intent.getData().toString().startsWith("http://imgur.com/gallery/")) {
        String uri = intent.getData().toString();
        final String album = uri.split("/")[4];
        if (album.length() == 5) {
            Log.d("album", album);
            Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM);
            fetcher.execute();
        } else if (album.length() == 7) {
            Log.d("image", album);
            Fetcher fetcher = new Fetcher(this, "/3/gallery/image/" + album, ApiCall.GET, null, apiCall, IMAGE);
            fetcher.execute();
        }
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://i.imgur")) {
        String uri = intent.getData().toString();
        final String image = uri.split("/")[3].split("\\.")[0];
        Log.d("image", image);
        Fetcher fetcher = new Fetcher(this, "/3/image/" + image, ApiCall.GET, null, apiCall, IMAGE);
        fetcher.execute();
    }
}

From source file:com.chaturs.notepad.NoteEditor.java

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

    //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    final Intent intent = getIntent();
    title = intent.getExtras().getString("note_title");
    // Do some setup based on the action being performed.

    final String action = intent.getAction();
    if (ACTION_EDIT.equals(action)) {
        // Requested to edit: set that state, and the data being edited.
        mState = STATE_EDIT;//from   w  w  w.j a va  2s  .c  om
        isSaved = false;
        mUri = intent.getData();
    } else {
        // Whoops, unknown action!  Bail.
        Log.e(TAG, "Unknown action, exiting");
        finish();
        return;
    }

    // Set the layout for this activity.  You can find it in res/layout/note_editor.xml
    setContentView(R.layout.note_editor);

    preferences = getSharedPreferences(DOC_PREFERENCE, Context.MODE_PRIVATE);
    IpValue = preferences.getString(KEY_IPVALUE, "");
    // The text view for our note, identified by its ID in the XML file.
    mText = (EditText) findViewById(R.id.note);

    // Get the note!
    mCursor = managedQuery(mUri, PROJECTION, null, null, null);

    // If an instance of this activity had previously stopped, we can
    // get the original text it started with.
    if (savedInstanceState != null) {
        mOriginalContent = savedInstanceState.getString(ORIGINAL_CONTENT);
    }

    DatabaseHandler databasehandler = DatabaseHandler.getInstance();
    studyGroupList = databasehandler.listStudyGroupsInfo();
    Iterator<StudyGroup> iterator = studyGroupList.iterator();
    while (iterator.hasNext()) {
        StudyGroup studyGroup = iterator.next();
        studyGroupNames.add(studyGroup.getName());
    }
}

From source file:com.example.hudpassthrough.BluetoothChat.java

private void connectDevice(Intent data, boolean secure) {
    // Get the device MAC address
    String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
    // Get the BLuetoothDevice object
    BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
    // Attempt to connect to the device
    mChatService.connect(device, secure);
}

From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java

/**
 * Called when response is received from the server for confirm credentials
 * request. See onAuthenticationResult(). Sets the
 * AccountAuthenticatorResult which is sent back to the caller.
 * //from ww  w .  j a va2s  . com
 * @param the confirmCredentials result.
 */
protected void finishConfirmCredentials(boolean result) {
    Log.i(tag, "finishConfirmCredentials()");
    final Account account = new Account(mUsername, Constants.ACCOUNT_TYPE);
    mAccountManager.setPassword(account, mPassword);
    mAccountManager.setUserData(account, Constants.PHONE_NUMBER_KEY, countryCode + mPhone);
    Db.deleteServerData(getApplicationContext());
    final Intent intent = new Intent();
    intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, result);
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK, intent);
    finish();
}

From source file:org.klnusbaum.udj.auth.AuthActivity.java

/**
 * Called when response is received from the server for authentication
 * request. See onAuthenticationResult(). Sets the
 * AccountAuthenticatorResult which is sent back to the caller. We store the
 * authToken that's returned from the server as the 'password' for this
 * account - so we're never storing the user's actual password locally.
 *
 * @param result the confirmCredentials result.
 *///from   w ww. j a  va2s. co m
private void finishLogin(ServerConnection.AuthResult authResult) {
    Log.i(TAG, "finishLogin()");
    final Account account = new Account(mUsername, Constants.ACCOUNT_TYPE);
    if (mRequestNewAccount) {
        mAccountManager.addAccountExplicitly(account, mPassword, null);
        ContentResolver.setIsSyncable(account, Constants.AUTHORITY, 0);
    } else {
        mAccountManager.setPassword(account, mPassword);
    }
    mAccountManager.setUserData(account, Constants.USER_ID_DATA, authResult.userId);
    mAccountManager.setUserData(account, Constants.LAST_PLAYER_ID_DATA, Constants.NO_PLAYER_ID);
    mAccountManager.setUserData(account, Constants.PLAYER_STATE_DATA,
            Integer.toString(Constants.NOT_IN_PLAYER));
    final Intent intent = new Intent();
    intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
    intent.putExtra(Constants.ACCOUNT_EXTRA, account);
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK, intent);
    finish();
}