Example usage for android.content Intent getBundleExtra

List of usage examples for android.content Intent getBundleExtra

Introduction

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

Prototype

public Bundle getBundleExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.weebly.opus1269.copyeverywhere.ui.devices.DevicesActivity.java

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

    setContentView(R.layout.activity_devices);

    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.deviceList);
    if (recyclerView != null) {
        mAdapter = new DevicesAdapter();
        recyclerView.setAdapter(mAdapter);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }/*from w w w.  j  a v  a2 s  .c o m*/

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    if (fab != null) {
        fab.hide();
    }

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    // handler for received Intents for the "devices" event
    mDevicesReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            notifyAdapter(intent);
        }

        private void notifyAdapter(Intent intent) {
            final Bundle bundle = intent.getBundleExtra(Devices.BUNDLE);
            final String action = bundle.getString(Devices.ACTION);
            final int pos = bundle.getInt(Devices.POS);
            if (action == null) {
                return;
            }

            AppUtils.log(TAG, "Devices change: " + action + " pos: " + pos);

            switch (action) {
            case Devices.ACTION_ADD:
                mAdapter.notifyItemInserted(pos);
                break;
            case Devices.ACTION_REMOVE:
                mAdapter.notifyItemRemoved(pos);
                break;
            case Devices.ACTION_CLEAR:
                mAdapter.notifyDataSetChanged();
                break;
            default:
                break;
            }
        }
    };
}

From source file:de.dreier.mytargets.features.training.standardround.EditStandardRoundFragment.java

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

    if (resultCode == Activity.RESULT_OK) {
        Bundle intentData = data.getBundleExtra(ItemSelectActivity.INTENT);
        final int index = intentData.getInt(SelectorBase.INDEX);
        final Parcelable parcelable = data.getParcelableExtra(ITEM);
        switch (requestCode) {
        case DistanceSelector.DISTANCE_REQUEST_CODE:
            standardRound.getRounds().get(index).distance = Parcels.unwrap(parcelable);
            adapter.notifyItemChanged(index);
            break;
        case TargetSelector.TARGET_REQUEST_CODE:
            standardRound.getRounds().get(index).setTargetTemplate(Parcels.unwrap(parcelable));
            adapter.notifyItemChanged(index);
            break;
        }/*from  ww  w. j  a  va  2  s . c  o m*/
    }
}

From source file:com.example.maxuan.photoutils.ViewPagerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_select_viewpager);
    mViewPager = (HackyViewPager) findViewById(R.id.view_pager);
    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    cancelBtn = (ImageView) findViewById(R.id.selectCancel);
    cancelBtn.setOnClickListener(this);
    selectCheckBox = (CheckBox) findViewById(R.id.checkbox);
    selectCheckBox.setOnClickListener(this);
    completeBtn = (Button) findViewById(R.id.completeBtn);
    completeBtn.setOnClickListener(this);
    photos = new ArrayList<>();
    posArray = new SparseIntArray(10);
    adapter = new PhotoPagerAdapter(this, photos);
    mViewPager.setAdapter(adapter);/*from   w w w  .j ava 2s. c  om*/
    mViewPager.addOnPageChangeListener(this);
    Intent intent = getIntent();
    if (intent != null) {
        Bundle bundle = intent.getBundleExtra("data");
        if (bundle == null)
            return;
        selectedPhotoArray = bundle.getSparseParcelableArray("selectedPhotos");
        completeBtn.setText(String.format(format, selectedPhotoArray.size()));
        List<Photo> list = bundle.getParcelableArrayList("photos");
        if (list != null)
            photos.addAll(list);
        for (int i = 0; i < photos.size(); ++i) {
            posArray.put(photos.get(i).id, i);
        }
        position = bundle.getInt("position", 0);
        maxCount = bundle.getInt("maxCount", 9);
        adapter.notifyDataSetChanged();
        mViewPager.setCurrentItem(position);
        selectCheckBox.setChecked(selectedPhotoArray.indexOfKey(photos.get(position).id) >= 0);
    }

    selectedPhotoAdapter = new SelectedPhotoAdapter(this);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    layoutManager.setReverseLayout(true);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(selectedPhotoAdapter);
    recyclerView.setVisibility(selectedPhotoArray.size() > 0 ? View.VISIBLE : View.GONE);
    if (savedInstanceState != null) {
        boolean isLocked = savedInstanceState.getBoolean(ISLOCKED_ARG, false);
        ((HackyViewPager) mViewPager).setLocked(isLocked);
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
        return;
    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

}

From source file:de.dreier.mytargets.features.bows.EditBowFragment.java

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

    if (resultCode == Activity.RESULT_OK
            && requestCode == SimpleDistanceSelector.SIMPLE_DISTANCE_REQUEST_CODE) {
        Bundle intentData = data.getBundleExtra(ItemSelectActivity.INTENT);
        final int index = intentData.getInt(SelectorBase.INDEX);
        final Parcelable parcelable = data.getParcelableExtra(ItemSelectActivity.ITEM);
        bow.getSightMarks().get(index).distance = Parcels.unwrap(parcelable);
        adapter.notifyItemChanged(index);
    }/*  w w w .j av  a2s  . c  om*/
}

From source file:io.github.waka.sevenhack.activities.MainActivity.java

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

    switch (requestCode) {
    case RequestCodes.SEARCH_PODCAST:
        if (resultCode == ResultCodes.ADDED) {
            Podcast podcast = BundleUtil.getPodcast(data.getBundleExtra(BUNDLE_NAME));
            onAddedPodcast(podcast);//from  ww  w  .java 2s  .c  o m
        }
        break;
    case RequestCodes.PODCAST:
        if (resultCode == ResultCodes.DELETED) {
            Podcast podcast = BundleUtil.getPodcast(data.getBundleExtra(BUNDLE_NAME));
            onDeletedPodcast(podcast);
        }
        break;
    case RequestCodes.LISENCE:
        // nothing to do
        break;
    default:
        break;
    }
}

From source file:de.brokenpipe.taskermqtt.MqttConnectionService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    final Bundle localeBundle = intent.getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);

    if (localeBundle == null) {
        return super.onStartCommand(intent, flags, startId);
    }/*from w w w  .  ja  va 2  s . c  o  m*/

    final String actionType = localeBundle.getString(BundleExtraKeys.ACTION_TYPE);

    if (actionType != null)
        switch (actionType) {
        case BundleExtraKeys.ACTION_TYPE_CONNECT:
            connect();
            break;

        case BundleExtraKeys.ACTION_TYPE_DISCONNECT:
            disconnect();
            break;

        case BundleExtraKeys.ACTION_TYPE_SUBSCRIBE:
            subscribe(localeBundle.getString(BundleExtraKeys.TOPIC));
            break;

        case BundleExtraKeys.ACTION_TYPE_UNSUBSCRIBE:
            unsubscribe(localeBundle.getString(BundleExtraKeys.TOPIC));
            break;

        case BundleExtraKeys.ACTION_TYPE_PUBLISH:
            publish(localeBundle.getString(BundleExtraKeys.TOPIC),
                    localeBundle.getString(BundleExtraKeys.PAYLOAD));
            break;
        }

    return super.onStartCommand(intent, flags, startId);
}

From source file:com.example.domiter.fileexplorer.fragment.SearchListFragment.java

private void handleIntent() {
    Intent intent = getActivity().getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // Get the query.
        mQuery = intent.getStringExtra(SearchManager.QUERY);
        getActivity().getActionBar().setTitle(mQuery);

        // Get the current path
        String path = intent.getBundleExtra(SearchManager.APP_DATA)
                .getString(IntentConstants.EXTRA_SEARCH_INIT_PATH);
        mRoot = new File(path);
        getActivity().getActionBar().setSubtitle(path);

        // Start the actual search
        getLoaderManager().initLoader(LOADER_ID, null, this);
        getActivity().setProgressBarIndeterminateVisibility(true);
    }//w w  w .  j  a va 2  s.  co m
    // We're here because of a clicked suggestion
    else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        browse(intent.getData());

        getActivity().finish();
    } else {
        // Intent contents error.
        getActivity().setTitle(R.string.query_error);
        setLoading(false);
    }
}

From source file:com.giltesa.taskcalendar.activity.Main.java

/**
 * Desde este procedimiento se tratan todos los Intents que se reciban de otras Activities:
 * El primer y segundo parametro sirven para saber quien lanzo la llamada y quien devolvio la respuesta.
 * Es decir, el padre (Main) puede tener varios "startActivityForResult()" para llamar a otra Activity.
 * Y la Activity hija puede tener varios "setResult()" para devolver los datos.
 * Es con esos dos parametros como se pueden controlar esos datos.
 * |//from w w w  .  ja  v  a 2  s .  c o m
 * Al final no se uso para nada, no hubo forma de actualizar la pantalla tras interactuar con sus items.
 * Asi que el activity que crea
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode != BACK)
        mViewPager.setCurrentItem(data.getBundleExtra("dataActivity").getInt("positionSlider"));

}

From source file:com.xbm.android.matisse.ui.MatisseActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK)
        return;//ww  w.j  a  v a2 s  .co m

    if (requestCode == REQUEST_CODE_PREVIEW) {
        Bundle resultBundle = data.getBundleExtra(BasePreviewActivity.EXTRA_RESULT_BUNDLE);
        ArrayList<Item> selected = resultBundle.getParcelableArrayList(SelectedItemCollection.STATE_SELECTION);
        int collectionType = resultBundle.getInt(SelectedItemCollection.STATE_COLLECTION_TYPE,
                SelectedItemCollection.COLLECTION_UNDEFINED);
        if (data.getBooleanExtra(BasePreviewActivity.EXTRA_RESULT_APPLY, false)) {
            Intent result = new Intent();
            ArrayList<Uri> selectedUris = new ArrayList<>();
            ArrayList<String> selectedPaths = new ArrayList<>();
            if (selected != null) {
                for (Item item : selected) {
                    selectedUris.add(item.getContentUri());
                    selectedPaths.add(PathUtils.getPath(this, item.getContentUri()));
                }
            }
            result.putParcelableArrayListExtra(EXTRA_RESULT_SELECTION, selectedUris);
            result.putStringArrayListExtra(EXTRA_RESULT_SELECTION_PATH, selectedPaths);
            setResult(RESULT_OK, result);
            finish();
        } else {
            mSelectedCollection.overwrite(selected, collectionType);
            Fragment mediaSelectionFragment = getSupportFragmentManager()
                    .findFragmentByTag(MediaSelectionFragment.class.getSimpleName());
            if (mediaSelectionFragment instanceof MediaSelectionFragment) {
                ((MediaSelectionFragment) mediaSelectionFragment).refreshMediaGrid();
            }
            updateBottomToolbar();
        }
    } else if (requestCode == REQUEST_CODE_CAPTURE) {
        // Just pass the data back to previous calling Activity.
        Uri contentUri = mMediaStoreCompat.getCurrentPhotoUri();
        String path = mMediaStoreCompat.getCurrentPhotoPath();
        ArrayList<Uri> selected = new ArrayList<>();
        selected.add(contentUri);
        ArrayList<String> selectedPath = new ArrayList<>();
        selectedPath.add(path);
        Intent result = new Intent();
        result.putParcelableArrayListExtra(EXTRA_RESULT_SELECTION, selected);
        result.putStringArrayListExtra(EXTRA_RESULT_SELECTION_PATH, selectedPath);
        setResult(RESULT_OK, result);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
            MatisseActivity.this.revokeUriPermission(contentUri,
                    Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
        finish();
    }
}

From source file:com.khoahuy.phototag.HomeActivity.java

@Override
protected void onResume() {
    super.onResume();
    try {//ww w .j a v  a  2 s .c  om
        loadContent();

        Intent callerIntent = getIntent();
        if (callerIntent != null && Intent.EXTRA_UID.equals(callerIntent.getAction())) {
            Bundle packageFromCaller = callerIntent.getBundleExtra("MyPackage");
            if (packageFromCaller != null) {
                nfcid = packageFromCaller.getString("nfcid");
                // processNfcID();
                setIntent(callerIntent);
                dispatchTakePictureIntent(ACTION_TAKE_PHOTO_B);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}