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:com.ateam.alleneatonautorentals.ServiceSearchCar.java

@Override
public void onBackPressed() {
    Intent ii = new Intent(getApplicationContext(), MainMenu.class);
    Bundle b = new Bundle();
    b.putString("employeeType", "Service");
    ii.putExtras(b);

    startActivity(ii);//from w  ww .  j a  va  2s .c  o  m
    finish();
}

From source file:com.epitrack.guardioes.view.base.BaseActivity.java

@Override
public void navigateTo(final Class<? extends Activity> activityClass, final int flags, final Bundle bundle) {

    final Intent intent = new Intent(this, activityClass);

    intent.setFlags(flags);//from w w  w.j a  v a2  s. c  o m
    intent.putExtras(bundle);

    startActivity(intent);
}

From source file:com.epitrack.guardioes.view.base.BaseActivity.java

@Override
public void navigateForResult(final Class<? extends Activity> activityClass, final int requestCode,
        final int flags, final Bundle bundle) {

    final Intent intent = new Intent(this, activityClass);

    intent.setFlags(flags);/*w w w.  j  a va 2  s  .com*/
    intent.putExtras(bundle);

    startActivityForResult(intent, requestCode);
}

From source file:my.home.lehome.service.SendMsgIntentService.java

private void preparePengindCommand(Intent intent) {
    Messenger messenger;//  w w w  . j a  va  2  s .  c  o m
    if (intent.hasExtra("messenger"))
        messenger = (Messenger) intent.getExtras().get("messenger");
    else
        messenger = null;
    Message repMsg = Message.obtain();
    repMsg.what = MSG_BEGIN_SENDING;

    boolean isSysCmd = intent.getBooleanExtra("isSysCmd", false);
    if (isSysCmd) {
        Log.d(TAG, "sys cmd item");
        return;
    }

    ChatItem item = intent.getParcelableExtra("update");
    if (item == null) {
        item = new ChatItem();
        item.setContent(intent.getStringExtra("cmd"));
        item.setType(ChatItemConstants.TYPE_CLIENT);
        item.setState(Constants.CHATITEM_STATE_ERROR); // set ERROR
        item.setDate(new Date());
        DBStaticManager.addChatItem(getApplicationContext(), item);
    }
    item.setState(Constants.CHATITEM_STATE_PENDING);

    Log.d(TAG, "enqueue item: \n" + item);
    Bundle bundle = new Bundle();
    bundle.putBoolean("update", intent.hasExtra("update"));
    bundle.putParcelable("item", item);
    if (messenger != null) {
        repMsg.setData(bundle);
        try {
            messenger.send(repMsg);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    } else {
        Log.d(TAG, "messager is null, send broadcast instead:" + ACTION_SEND_MSG_BEGIN);
        Intent newIntent = new Intent(ACTION_SEND_MSG_BEGIN);
        newIntent.putExtras(bundle);
        sendBroadcast(newIntent);
    }

    intent.putExtra("pass_item", item);
}

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

@Override
public boolean onMenuItemClick(final MenuItem item) {
    if (mSelectedUser == null)
        return false;
    switch (item.getItemId()) {
    case MENU_DELETE: {
        mService.deleteUserListMember(getAccountId(), mUserListId, mSelectedUser.user_id);
        break;//from   w  w w.  j a v a  2 s .  c  o m
    }
    case MENU_VIEW_PROFILE: {
        openUserProfile(mSelectedUser.user_id, mSelectedUser.screen_name);
        break;
    }
    case MENU_EXTENSIONS: {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_USER, mSelectedUser);
        intent.putExtras(extras);
        startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions)));
        break;
    }
    }
    return false;
}

From source file:fi.mikuz.boarder.gui.internet.Login.java

@Override
public void onConnectionSuccessful(ConnectionSuccessfulResponse connectionSuccessfulResponse)
        throws JSONException {
    ConnectionUtils.connectionSuccessful(Login.this, connectionSuccessfulResponse);
    mWaitDialog.dismiss();/*from w w  w . j av a 2  s  .  c  o m*/

    if (ConnectionUtils.checkConnectionId(connectionSuccessfulResponse, InternetMenu.mLogoutURL)) {
        Toast.makeText(Login.this,
                connectionSuccessfulResponse.getJSONObject().getString(ConnectionUtils.returnMessage),
                Toast.LENGTH_LONG).show();
        logout();
    } else if (ConnectionUtils.checkConnectionId(connectionSuccessfulResponse, InternetMenu.mLoginURL)) {
        String password = connectionSuccessfulResponse.getJSONObject().getString(InternetMenu.PASSWORD_KEY);
        String sessionToken = connectionSuccessfulResponse.getJSONObject()
                .getString(InternetMenu.SESSION_TOKEN_KEY);
        String userId = connectionSuccessfulResponse.getJSONObject().getString(InternetMenu.USER_ID_KEY);
        String accountMessage = connectionSuccessfulResponse.getJSONObject()
                .getString(InternetMenu.ACCOUNT_MESSAGE_KEY);

        if (mRememberSession) {
            mDbHelper.createLogin(InternetMenu.USER_ID_KEY, userId);
            mDbHelper.createLogin(InternetMenu.SESSION_TOKEN_KEY, sessionToken);
        }

        if (mPasswordOperation == PASSWORD_OPERATION_SAVE) {
            mDbHelper.putLogin(InternetMenu.PASSWORD_KEY, password);
        }

        mReturnSession = new HashMap<String, String>();
        mReturnSession.put(InternetMenu.USER_ID_KEY, userId);
        mReturnSession.put(InternetMenu.SESSION_TOKEN_KEY, sessionToken);

        Bundle bundle = new Bundle();
        bundle.putSerializable(InternetMenu.LOGIN_KEY, mReturnSession);
        bundle.putString(InternetMenu.ACCOUNT_MESSAGE_KEY, accountMessage);

        Intent intent = new Intent();
        intent.putExtras(bundle);

        setResult(RESULT_OK, intent);
        finish();
    } else if (ConnectionUtils.checkConnectionId(connectionSuccessfulResponse,
            InternetMenu.mRecoverPasswordURL)) {
        Toast.makeText(Login.this,
                connectionSuccessfulResponse.getJSONObject().getString(ConnectionUtils.returnMessage),
                Toast.LENGTH_LONG).show();
    }
}

From source file:com.app.jdy.adapter.ImagePagerAdapter.java

@Override
public View getView(int position, View view, ViewGroup container) {
    ViewHolder holder;/*from   w  w w  . ja va 2  s . c om*/
    if (view == null) {
        holder = new ViewHolder();
        view = holder.imageView = new ImageView(context);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }
    ImagePosition = position;
    holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    holder.imageView.setImageBitmap(imageIdList.get(getPosition(position)));
    holder.imageView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Log.i("debug==========position", String.valueOf(getPosition(ImagePosition)));
            if (getPosition(ImagePosition) == 1) {
                Intent intent = new Intent(context, PictureActivity.class);
                Bundle bundle = new Bundle();
                intent.putExtra("title", "");
                intent.putExtra("url", URLs.HONGBAO_INTRODUCE);
                intent.putExtras(bundle);
                context.startActivity(intent);
            } else if (getPosition(ImagePosition) == 0) {
                Intent intent = new Intent(context, PictureActivity.class);
                intent.putExtra("title", "???");
                Bundle bundle = new Bundle();
                intent.putExtra("url", URLs.SHANGXIAN_INTRODUCE);
                context.startActivity(intent);
            }
        }
    });
    return view;
}

From source file:br.com.frs.foodrestrictions.MessageLanguageSelector.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    Bundle args = new Bundle();
    Intent intent = new Intent(getContext(), MessagesTab.class);

    switch (position) {
    case 0: //English
        args.putString(MessageLanguageSelector.ARG_LANGUAGE, "en");
        break;// www . j  a  va2  s . c  o  m
    case 1: //Portuguese
        args.putString(MessageLanguageSelector.ARG_LANGUAGE, "pt");
        break;
    }

    intent.putExtras(args);
    startActivity(intent);
}

From source file:carsharing.starter.automotive.iot.ibm.com.mobilestarterapp.Reservations.Reservations.java

public void setContent(final ArrayList<ReservationsData> reservationsArray) {
    final FragmentActivity activity = getActivity();
    if (activity == null) {
        return;//from  w  w  w . ja  v a 2 s  .  co  m
    }
    final ListView listView = (ListView) view.findViewById(R.id.listView);

    final ReservationsDataAdapter adapter = new ReservationsDataAdapter(activity.getApplicationContext(),
            reservationsArray);
    listView.setAdapter(adapter);

    final ArrayList<ReservationsData> finalReservationsArray = reservationsArray;
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View view, int position, long arg) {
            final Intent completeReservation = new Intent(view.getContext(), CompleteReservation.class);

            final Bundle bundle = new Bundle();
            bundle.putSerializable("reservationData", finalReservationsArray.get(position));
            completeReservation.putExtras(bundle);

            startActivity(completeReservation);
        }
    });

    final ActionBar supportActionBar = ((AppCompatActivity) activity).getSupportActionBar();
    switch (reservations.size()) {
    case 0:
        supportActionBar.setTitle("You have no reservations.");
    case 1:
        supportActionBar.setTitle("You have one reservation.");
    default:
        supportActionBar.setTitle("You have " + reservations.size() + " reservations.");
    }
}

From source file:mad.codeforcommunity.CalendarView.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.calendar);/*from   ww w  .j  av a  2  s  . com*/
    month = Calendar.getInstance();
    //  onNewIntent(getIntent());

    items = new ArrayList<String>();
    adapter = new CalendarAdapter(this, month);

    GridView gridview = (GridView) findViewById(R.id.gridview);
    gridview.setAdapter(adapter);

    handler = new Handler();
    handler.post(calendarUpdater);

    TextView title = (TextView) findViewById(R.id.title);
    title.setText(android.text.format.DateFormat.format("MMMM yyyy", month));

    TextView previous = (TextView) findViewById(R.id.previous);
    previous.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            if (month.get(Calendar.MONTH) == month.getActualMinimum(Calendar.MONTH)) {
                month.set((month.get(Calendar.YEAR) - 1), month.getActualMaximum(Calendar.MONTH), 1);
            } else {
                month.set(Calendar.MONTH, month.get(Calendar.MONTH) - 1);
            }
            refreshCalendar();
        }
    });

    TextView next = (TextView) findViewById(R.id.next);
    next.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            if (month.get(Calendar.MONTH) == month.getActualMaximum(Calendar.MONTH)) {
                month.set((month.get(Calendar.YEAR) + 1), month.getActualMinimum(Calendar.MONTH), 1);
            } else {
                month.set(Calendar.MONTH, month.get(Calendar.MONTH) + 1);
            }
            refreshCalendar();

        }
    });

    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            TextView date = (TextView) v.findViewById(R.id.date);
            ImageView image = (ImageView) v.findViewById(R.id.date_icon);
            if (date instanceof TextView && !date.getText().equals("")) {
                if (image.getVisibility() == View.VISIBLE) {
                    /*OLD CODE
                     * Intent intent = new Intent();
                    String day = date.getText().toString();
                    if(day.length()==1) {
                       day = "0"+day;
                    }
                    // return chosen date as string format 
                    intent.putExtra("date", android.text.format.DateFormat.format("yyyy-MM", month)+"-"+day);
                    setResult(RESULT_OK, intent);
                    finish();
                    */

                    Bundle extras = new Bundle();
                    String day = date.getText().toString();
                    if (day.length() == 1) {
                        day = "0" + day;
                    }
                    // return chosen date as string format 
                    extras.putString("date",
                            android.text.format.DateFormat.format("yyyy-MM", month) + "-" + day);

                    Intent intent = new Intent(CalendarView.this, EventView.class);
                    intent.putExtras(extras);

                    startActivity(intent);
                }

            }

        }
    });
}