Example usage for android.content Intent putExtras

List of usage examples for android.content Intent putExtras

Introduction

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

Prototype

public @NonNull Intent putExtras(@NonNull Bundle extras) 

Source Link

Document

Add a set of extended data to the intent.

Usage

From source file:eu.dirtyharry.androidopsiadmin.Main.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == GET_QR && resultCode == RESULT_OK) {
        contents = data.getExtras().getString("la.droid.qr.result");
        if (checkQR(contents)) {
            try {
                pc = (JSONObject) new JSONTokener(contents).nextValue();
                hosttocheck = pc.getString("dns");
            } catch (JSONException e) {
                e.printStackTrace();//w  w w .ja  v a  2  s.  c  om
            }
            final ProgressDialog dialog = ProgressDialog.show(Main.this,
                    getString(R.string.gen_title_pleasewait),
                    String.format(getString(R.string.pd_checkifopsiclientexists), hosttocheck), true);
            final Handler handler = new Handler() {
                public void handleMessage(Message msg) {
                    if (hostexistsinopsi && doit.equals("true")) {
                        if (customtags) {
                            Intent i = new Intent(Main.this, ShowBarcodeData.class);
                            Bundle b = new Bundle();
                            b.putString("qrdata", contents);
                            i.putExtras(b);
                            startActivity(i);
                        } else {
                            Intent i = new Intent(Main.this, ShowOpsiClientOptions.class);
                            Bundle b = new Bundle();
                            b.putString("qrdata", contents);
                            i.putExtras(b);
                            startActivity(i);
                        }
                    } else if (!hostexistsinopsi) {
                        new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                                String.format(getString(R.string.general_noopsihost), hosttocheck), false);
                    } else {
                        Toast.makeText(Main.this,
                                String.format(getString(R.string.to_servernotrechable), serverip),
                                Toast.LENGTH_LONG).show();
                    }
                    dialog.dismiss();
                }
            };

            Thread checkUpdate = new Thread() {
                public void run() {
                    Looper.prepare();

                    if (eu.dirtyharry.androidopsiadmin.Networking.isServerUp(serverip, serverport,
                            serverusername, serverpasswd)) {
                        doit = "true";
                        if (eu.dirtyharry.androidopsiadmin.Networking.checkIfHostExistsInOpsi(hosttocheck,
                                serverip, serverport, serverusername, serverpasswd)) {
                            hostexistsinopsi = true;
                        } else {
                            hostexistsinopsi = false;
                        }
                    } else {
                        doit = "serverdown";
                    }
                    handler.sendEmptyMessage(0);

                }
            };
            checkUpdate.start();

        } else {
            new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                    getString(R.string.at_novalidqr), false);
        }
    } else if (requestCode == GET_OPSI_CLIENT_REQUEST && resultCode == Activity.RESULT_OK) {
        if (data.getStringExtra("message").equals("refresh")) {
            getOpsiClientsTask();
        }
        // } else if (requestCode == SHOW_OPSI_DEPOT_REQUEST
        // && resultCode == Activity.RESULT_OK) {
        // resultconfignames = data.getExtras().getStringArrayList(
        // "choosenones");
        // resultconfigvalues = data.getExtras().getStringArrayList(
        // "choosenonesvalues");
        // event_opsisenddepotconfigchanges();
    }
}

From source file:org.openhab.habdroid.ui.OpenHABRoomSettingActivity.java

@Override
public void onEditClickListener(int pos) {
    // TODO Auto-generated method stub
    OpenHABWidget w = openHABWidgetDataSource.getWidgets().get(pos);

    Intent i = new Intent(OpenHABRoomSettingActivity.this, ChangeItemActivity.class);
    Bundle data = new Bundle();
    if (!w.getType().equalsIgnoreCase("group")) {
        data.putSerializable(ChangeItemActivity.GROUP_KEY, groupList);
        data.putString(ChangeItemActivity.PARENT_KEY, currPID);
    }/*from  w w w  .j a  v a  2  s  .  c o m*/
    data.putSerializable(ChangeItemActivity.ITEM_KEY, w);
    data.putString(ChangeItemActivity.SITE_KEY, sitemapRootUrl);
    i.putExtras(data);
    startActivity(i);
}

From source file:fr.cph.chicago.core.activity.BusBoundActivity.java

@Override
public final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    App.checkBusData(this);
    if (!this.isFinishing()) {
        setContentView(R.layout.activity_bus_bound);
        ButterKnife.bind(this);

        if (busRouteId == null || busRouteName == null || bound == null || boundTitle == null) {
            final Bundle extras = getIntent().getExtras();
            busRouteId = extras.getString(bundleBusRouteId);
            busRouteName = extras.getString(bundleBusRouteName);
            bound = extras.getString(bundleBusBound);
            boundTitle = extras.getString(bundleBusBoundTitle);
        }/*from w ww.  j av  a2 s  .  c  o  m*/
        busBoundAdapter = new BusBoundAdapter();
        setListAdapter(busBoundAdapter);
        getListView().setOnItemClickListener((adapterView, view, position, id) -> {
            final BusStop busStop = (BusStop) busBoundAdapter.getItem(position);
            final Intent intent = new Intent(getApplicationContext(), BusActivity.class);

            final Bundle extras = new Bundle();
            extras.putInt(bundleBusStopId, busStop.getId());
            extras.putString(bundleBusStopName, busStop.getName());
            extras.putString(bundleBusRouteId, busRouteId);
            extras.putString(bundleBusRouteName, busRouteName);
            extras.putString(bundleBusBound, bound);
            extras.putString(bundleBusBoundTitle, boundTitle);
            extras.putDouble(bundleBusLatitude, busStop.getPosition().getLatitude());
            extras.putDouble(bundleBusLongitude, busStop.getPosition().getLongitude());

            intent.putExtras(extras);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        });

        filter.addTextChangedListener(new TextWatcher() {
            private List<BusStop> busStopsFiltered;

            @Override
            public void beforeTextChanged(final CharSequence s, final int start, final int count,
                    final int after) {
                busStopsFiltered = new ArrayList<>();
            }

            @Override
            public void onTextChanged(final CharSequence s, final int start, final int before,
                    final int count) {
                if (busStops != null) {
                    Stream.of(busStops).filter(busStop -> StringUtils.containsIgnoreCase(busStop.getName(), s))
                            .forEach(busStopsFiltered::add);
                }
            }

            @Override
            public void afterTextChanged(final Editable s) {
                busBoundAdapter.update(busStopsFiltered);
                busBoundAdapter.notifyDataSetChanged();
            }
        });

        Util.setWindowsColor(this, toolbar, TrainLine.NA);
        toolbar.setTitle(busRouteId + " - " + boundTitle);

        toolbar.setNavigationIcon(arrowBackWhite);
        toolbar.setOnClickListener(v -> finish());

        ObservableUtil.createBusStopBoundObservable(getApplicationContext(), busRouteId, bound)
                .subscribe(onNext -> {
                    busStops = onNext;
                    busBoundAdapter.update(onNext);
                    busBoundAdapter.notifyDataSetChanged();
                }, onError -> {
                    Log.e(TAG, onError.getMessage(), onError);
                    Util.showOopsSomethingWentWrong(getListView());
                });

        Util.trackAction(this, R.string.analytics_category_req, R.string.analytics_action_get_bus,
                BUSES_STOP_URL, 0);

        // Preventing keyboard from moving background when showing up
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    }
}

From source file:cn.longchou.wholesale.activity.VehicleDetailActivity.java

private void showBudget() {
     Intent intent = new Intent(this, BudgetConfirmActivity.class);
     Bundle bundle = new Bundle();
     bundle.putSerializable("cars", cars);
     intent.putExtras(bundle);
     startActivity(intent);//  w w w. ja v  a  2s .co m

 }

From source file:com.binil.pushnotification.GcmIntentService.java

private Intent generateIntent(Bundle extras) {

    Intent intent = null;

    try {/*from w  w  w  . j ava 2 s.  co  m*/
        String relatedId = extras.getString("AgmoActionContent", "");
        switch (Integer.parseInt(extras.getString("AgmoActionType", "0"))) {
        //                case Constants.NotificationType.MESSAGE:
        //                case Constants.NotificationType.URL:
        //                case Constants.NotificationType.REQUEST_NEW:
        //                case Constants.NotificationType.REQUEST_ASSIGNED:
        //                case Constants.NotificationType.REQUEST_USER_CANCEL:
        //                case Constants.NotificationType.REQUEST_DOCTOR_CANCEL:
        //                case Constants.NotificationType.REQUEST_COMPLETE:
        default:
            intent = new Intent(this, MainActivity.class);
            intent.putExtra("forNotification", "yes");
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.putExtras(extras);
            break;
        }
    } catch (Exception ex) {
        intent = new Intent(this, MainActivity.class);
    }

    return intent;
}

From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java

private Intent notificationIntent(final Bundle pushBundle, final String campaignId, final int requestId,
        final String intentAction, final Class<?> targetClass) {
    final Intent notificationIntent = new Intent(pinpointContext.getApplicationContext(), targetClass);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    notificationIntent.setAction(intentAction);
    notificationIntent.putExtras(pushBundle);
    notificationIntent.putExtra(INTENT_SNS_NOTIFICATION_FROM, AWS_EVENT_TYPE_OPENED);
    notificationIntent.putExtra(CAMPAIGN_ID_PUSH_KEY, campaignId);
    notificationIntent.putExtra(REQUEST_ID, requestId);
    notificationIntent.setPackage(pinpointContext.getApplicationContext().getPackageName());
    return notificationIntent;
}

From source file:com.dwdesign.tweetings.fragment.UserListDetailsFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_FOLLOW: {
        if (mAccountId != mUserId) {
            if (mUserList.isFollowing()) {
                mService.destroyUserListSubscription(mAccountId, mUserList.getId());
            } else {
                mService.createUserListSubscription(mAccountId, mUserList.getId());
            }//from w ww .  j a  va2 s  . c om
        }
        break;
    }
    case MENU_ADD: {
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        args.putString(INTENT_KEY_TEXT, "");
        args.putInt(INTENT_KEY_LIST_ID, mUserList.getId());
        mAddMemberDialogFragment.setArguments(args);
        mAddMemberDialogFragment.show(getFragmentManager(), "add_member");
        break;
    }
    case MENU_ADD_TAB: {
        CustomTabsAdapter mAdapter;
        mAdapter = new CustomTabsAdapter(getActivity());
        ContentResolver mResolver;
        mResolver = getContentResolver();
        final String tabName = mListName;
        final String tabType = AUTHORITY_LIST_TIMELINE;
        final String tabIcon = "list";
        final long account_id = mAccountId;
        final String tabScreenName = mUserScreenName;
        final String tabListName = mListName;
        final String tabArguments = "{\"account_id\":" + account_id + ",\"screen_name\":\"" + tabScreenName
                + "\",\"list_name\":" + JSONObject.quote(tabListName) + "}";
        final ContentValues values = new ContentValues();
        values.put(Tabs.ARGUMENTS, tabArguments);
        values.put(Tabs.NAME, tabName);
        values.put(Tabs.POSITION, mAdapter.getCount());
        values.put(Tabs.TYPE, tabType);
        values.put(Tabs.ICON, tabIcon);
        mResolver.insert(Tabs.CONTENT_URI, values);
        Toast.makeText(this.getActivity(), R.string.list_tab_added, Toast.LENGTH_SHORT).show();
        break;
    }
    case MENU_DELETE: {
        if (mUserId != mAccountId)
            return false;
        mService.destroyUserList(mAccountId, mUserListId);
        break;
    }
    case MENU_EXTENSIONS: {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_USER_LIST, new ParcelableUserList(mUserList, mAccountId));
        intent.putExtras(extras);
        startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions)));
        break;
    }
    }
    return true;
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_COMPOSE_NEW:
        createNewMessage();/*from  w  w w  . java  2  s . c  o m*/
        break;
    case MENU_SEARCH:
        onSearchRequested();
        break;
    case MENU_DELETE_ALL:
        // The invalid threadId of -1 means all threads here.
        //confirmDeleteThread(-1L, mQueryHandler);
        Intent intentDelete = new Intent(this, MultiSelectSmsDeleteActivity.class);
        startActivity(intentDelete);

        break;
    case MENU_PREFERENCES:
        Log.d(TAG, "[sms]onOptionsItemSelected mSmsReady[0]=" + mSmsReady[0] + " mSmsReady[1]=" + mSmsReady[1]);
        if (MessageUtils.isMSMS) {
            Intent intent = new Intent(this, MessagingPreferenceActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("mode", "conversation");
            intent.putExtras(bundle);
            startActivityIfNeeded(intent, -1);
        } else {
            if (isAnySmsReady()) {
                Intent intent = new Intent(this, MessagingPreferenceActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString("mode", "conversation");
                intent.putExtras(bundle);
                startActivityIfNeeded(intent, -1);
            } else {
                Toast.makeText(this, this.getResources().getString(R.string.sim_no_ready), Toast.LENGTH_LONG)
                        .show();
            }
        }
        break;

    case MENU_CBSMS:
        //Intent intent = new Intent(Intent.ACTION_VIEW);
        // XXX We need to specify the component here because if we don't
        // the activity manager will try to resolve the type by calling
        // the content provider, which causes it to be loaded in a process
        // other than the Dialer process, which causes a lot of stuff to
        // break.
        final Intent intent = new Intent(ConversationList.this, CellBroadcastSmsActivity.class);
        startActivity(intent);
        break;

    case MENU_MSG_FOLDER:
        unregisterReceiver(mReceiver);
        setLaunchMode(MMS_LAUNCH_MODE_PATH, "folder");
        Intent it = new Intent(this, MessageFolderActivity.class);
        startActivity(it);
        this.finish();
        break;
    default:
        return true;
    }
    return false;
}

From source file:eu.dirtyharry.androidopsiadmin.Main.java

public void getOPSIDepotConfig(final String depot) {
    final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait),
            String.format(getString(R.string.pd_getdepotconfigfor), depot), true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();//from  www  . j a  v  a 2s.c  o  m
            if (GlobalVar.getInstance().getError().equals("null")) {
                Intent i = new Intent(Main.this, ShowOpsiHostParamsListView.class);
                Bundle b = new Bundle();
                b.putString("hostparams", opsiresult.toString());
                b.putString("pc", choosendepot);
                b.putString("opsitype", "OpsiConfigserver");
                i.putExtras(b);
                startActivityForResult(i, SHOW_OPSI_DEPOT_REQUEST);
            } else {
                new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                        GlobalVar.getInstance().getError(), false);
            }

        }
    };
    Thread checkUpdate = new Thread() {
        public void run() {
            Looper.prepare();
            JSONArray JSONparams = new JSONArray();
            JSONparams.put(depot);
            opsiresult = new JSONObject();
            opsiresult = eu.dirtyharry.androidopsiadmin.Networking.opsiGetJSONObject("rpc", serverip,
                    serverport, "getDepot_hash", JSONparams, serverusername, serverpasswd);
            handler.sendEmptyMessage(0);
        }
    };
    checkUpdate.start();
}

From source file:fr.cph.chicago.activity.BusBoundActivity.java

@Override
public final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ChicagoTracker.checkBusData(this);
    if (!this.isFinishing()) {
        setContentView(R.layout.activity_bus_bound);

        if (mBusRouteId == null && mBusRouteName == null && mBound == null) {
            mBusRouteId = getIntent().getExtras().getString("busRouteId");
            mBusRouteName = getIntent().getExtras().getString("busRouteName");
            mBound = getIntent().getExtras().getString("bound");
        }//from  w ww  .  j a v  a 2  s  .co  m
        mAdapter = new BusBoundAdapter(mBusRouteId);
        setListAdapter(mAdapter);
        getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
                BusStop busStop = (BusStop) mAdapter.getItem(position);
                Intent intent = new Intent(ChicagoTracker.getAppContext(), BusActivity.class);

                Bundle extras = new Bundle();
                extras.putInt("busStopId", busStop.getId());
                extras.putString("busStopName", busStop.getName());
                extras.putString("busRouteId", mBusRouteId);
                extras.putString("busRouteName", mBusRouteName);
                extras.putString("bound", mBound);
                extras.putDouble("latitude", busStop.getPosition().getLatitude());
                extras.putDouble("longitude", busStop.getPosition().getLongitude());

                intent.putExtras(extras);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
                overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
            }
        });

        EditText filter = (EditText) findViewById(R.id.bus_filter);
        filter.addTextChangedListener(new TextWatcher() {
            List<BusStop> busStopsFiltered;

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                busStopsFiltered = new ArrayList<BusStop>();
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                for (BusStop busStop : mBusStops) {
                    if (StringUtils.containsIgnoreCase(busStop.getName(), s)) {
                        this.busStopsFiltered.add(busStop);
                    }
                }
            }

            @Override
            public void afterTextChanged(Editable s) {
                mAdapter.update(busStopsFiltered);
                mAdapter.notifyDataSetChanged();
            }
        });

        getActionBar().setDisplayHomeAsUpEnabled(true);
        new BusBoundAsyncTask().execute();

        // Preventing keyboard from moving background when showing up
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    }
}