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:anipr.stampitgo.android.Locator.java

public boolean getCurrentLocation() {
    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    MainActivity.currentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    if (mLastLocation != null) {
        status = true;/*from w ww.j  a va 2 s.  c o  m*/
        Intent i = new Intent();
        i.setAction("com.stampitgo.location_update");
        lat = mLastLocation.getLatitude();
        lng = mLastLocation.getLongitude();
        Bundle extras = new Bundle();
        extras.putDouble("lat", lat);
        extras.putDouble("lng", lng);
        i.putExtras(extras);

        LocalBroadcastManager.getInstance(AppController.getInstance().getApplicationContext()).sendBroadcast(i);

    } else {
        status = false;
    }
    return status;
}

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

private void getTrips() {
    final String url = API.tripBehavior + "?all=true";
    try {/*from ww w. ja  v  a  2  s  . c o  m*/
        final API.doRequest task = new API.doRequest(new API.doRequest.TaskListener() {
            @Override
            public void postExecute(JSONArray result) throws JSONException {
                result.remove(result.length() - 1);

                final ListView listView = (ListView) view.findViewById(R.id.listView);
                final ArrayList<TripData> tripsArray = new ArrayList<TripData>();
                for (int i = 0; i < result.length(); i++) {
                    final JSONObject data = result.getJSONObject(i);
                    if (data.has("start_time")) {
                        TripData tempTripData = new TripData(data);
                        tripsArray.add(tempTripData);
                    }
                }

                Collections.sort(tripsArray, new Comparator<TripData>() {
                    @Override
                    public int compare(TripData b1, TripData b2) {
                        final long delta = b2.start_time - b1.start_time;
                        if (delta > 0) {
                            return 1;
                        } else if (delta < 0) {
                            return -1;
                        } else {
                            return 0;
                        }
                    }
                });

                final FragmentActivity activity = getActivity();
                if (activity == null) {
                    return;
                }
                final TripsDataAdapter adapter = new TripsDataAdapter(activity.getApplicationContext(),
                        tripsArray);
                listView.setAdapter(adapter);

                final ArrayList<TripData> finalTripArray = tripsArray;
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapter, View view, int position, long arg) {
                        final Intent tripDetails = new Intent(view.getContext(), TripDetails.class);

                        final Bundle bundle = new Bundle();
                        bundle.putSerializable("tripData", finalTripArray.get(position));
                        tripDetails.putExtras(bundle);

                        startActivity(tripDetails);
                    }
                });

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

                Log.i("Trip Data", result.toString());
            }
        });

        task.execute(url, "GET").get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}

From source file:com.example.parking.ParkingInformationFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mLicensePlateNumber = getActivity().getIntent().getStringExtra("licensePlateNumber");
    mDBAdapter = new DBAdapter(getActivity());
    mParkNameTV = (TextView) mView.findViewById(R.id.tv_parking_name_parking_detail);
    mParkNameTV.setText(R.string.park_name_fixed);
    mParkNumberTV = (TextView) mView.findViewById(R.id.tv_parking_number_parking_detail);
    mParkNumberTV.setText("?: " + this.getString(R.string.park_number_fixed));
    mLocationNumberTV = (TextView) mView.findViewById(R.id.tv_location_number_parking_detail);
    mLicenseNumberTV = (TextView) mView.findViewById(R.id.tv_license_plate_number_parking_detail);
    mCarTypeTV = (TextView) mView.findViewById(R.id.tv_car_type_parking_detail);
    mParkTypeTV = (TextView) mView.findViewById(R.id.tv_parking_type_parking_detail);
    mStartTimeTV = (TextView) mView.findViewById(R.id.tv_start_time_parking_detail);
    mLeaveTimeTV = (TextView) mView.findViewById(R.id.tv_leave_time_parking_detail);
    mConfirmLeavingBT = (Button) mView.findViewById(R.id.bt_confirm_leaving);
    mConfirmLeavingBT.setOnClickListener(new OnClickListener() {
        @Override/*from   w ww.  j a  va  2 s  .com*/
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), LeavingActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("licensePlate", mLicensePlateNumber);
            intent.putExtras(bundle);
            startActivity(intent);
        }
    });
    mCancelLeavingBT = (Button) mView.findViewById(R.id.bt_cancel_leaving);
    mCancelLeavingBT.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), ParkingSpaceActivity.class);
            startActivity(intent);
        }
    });
    new TimeThread().start();
    //new SQLThread().start();
    setParkingInformation();
}

From source file:com.conduit.plastic.common.BaseActivity.java

protected void openActivity(Class<? extends BaseActivity> toActivity, Bundle parameter) {
    Intent intent = new Intent(this, toActivity);
    if (parameter != null) {
        intent.putExtras(parameter);
    }//from w w  w. j  a va 2  s  . c om
    startActivity(intent);

}

From source file:com.conduit.plastic.common.BaseActivity.java

public void startActivity(Class<?> cls, Bundle bundle) {
    Intent intent = new Intent(getApplicationContext(), cls);
    if (null != bundle)
        intent.putExtras(bundle);
    startActivity(intent);/*from  w  ww.j a  va 2  s  .c o m*/

}

From source file:eu.trentorise.smartcampus.widget.shortcuts.StackWidgetService.java

@Override
public RemoteViews getViewAt(int position) {
    // position will always range from 0 to getCount() - 1.

    // We construct a remote views item based on our widget item xml
    // file, and set the
    // text based on the position.
    RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
    ShapeDrawable sd1 = new ShapeDrawable(new RectShape());
    sd1.getPaint().setColor(0xFFFFFFFF);
    sd1.getPaint().setStyle(Style.STROKE);
    sd1.getPaint().setStrokeWidth(1);//from www .ja v a 2s. c  om
    Canvas c = new Canvas();
    sd1.draw(c);
    Bitmap b = Bitmap.createBitmap(120, 120, Bitmap.Config.ARGB_8888);
    c.drawBitmap(b, 0, 0, sd1.getPaint());
    // Next, we set a fill-intent which will be used to fill-in the
    // pending intent template
    // which is set on the collection view in StackWidgetProvider.

    if (ALLPREFERENCES != null && ALLPREFERENCES[position] != null) { //ALLPREFERENCES  dimensionato come le preferenze selezionate

        BookmarkDescriptor myDescriptor = ALLPREFERENCES[position];

        // set the widgetbutton
        if (WidgetHelper.PARAM_TYPE.equals(myDescriptor.params.get(0).name)) { //controllare con gli input da config activity?
            String type = myDescriptor.params.get(0).value;
            if (WidgetHelper.TYPE_DT.equals(type)) {
                // dt -> put icons and hide text
                rv.setViewVisibility(R.id.text_widget_item, View.GONE);
                rv.setImageViewResource(R.id.image_widget_item,
                        Integer.parseInt(myDescriptor.params.get(2).value));

                rv.setInt(R.id.image_widget_item, "setBackgroundResource", R.drawable.rounded_border_dt);

            } else if (WidgetHelper.TYPE_JP.equals(type)) {
                // jp -> put text and hide icon

                rv.setViewVisibility(R.id.image_widget_item, View.GONE);
                // rv.setImageViewBitmap(R.id.text_widget_item,
                // getBackground(Color.parseColor("#6EB046")));
                if (!("0".equals(myDescriptor.params.get(2).value))) {
                    //bus
                    rv.setTextViewTextSize(R.id.text_widget_item, TypedValue.COMPLEX_UNIT_DIP, 80);

                    rv.setTextViewText(R.id.text_widget_item, RoutesHelper.getShortNameByRouteIdAndAgencyID(
                            myDescriptor.params.get(4).value, myDescriptor.params.get(3).value)); //4,3
                    rv.setTextColor(R.id.text_widget_item, Integer.parseInt(myDescriptor.params.get(2).value));//rv.setInt(R.id.text_widget_item, "setBackgroundColor",
                    //Integer.parseInt(myDescriptor.params.get(2).value));
                    rv.setInt(R.id.text_widget_item, "setBackgroundResource", R.drawable.rounded_border_jp);

                } else {
                    //train
                    rv.setTextViewTextSize(R.id.text_widget_item, TypedValue.COMPLEX_UNIT_DIP, 12);
                    //controllo contesto getRouteDescriptor i vari parametri
                    rv.setTextViewText(R.id.text_widget_item,
                            mContext.getString(
                                    RoutesHelper.getRouteDescriptorByRouteId(myDescriptor.params.get(3).value,
                                            myDescriptor.params.get(4).value).getNameResource()));
                    rv.setTextColor(R.id.text_widget_item, Color.BLACK);//Int(R.id.text_widget_item, "setBackgroundColor",Color.BLACK);
                    rv.setInt(R.id.text_widget_item, "setBackgroundResource", R.drawable.rounded_border_jp);

                }

            } else if (WidgetHelper.TYPE_JP_PARKINGS.equals(type)) {
                // jp parcheggio -> put text and hide icon
                rv.setViewVisibility(R.id.text_widget_item, View.GONE);
                rv.setImageViewResource(R.id.image_widget_item,
                        Integer.parseInt(myDescriptor.params.get(2).value));
                rv.setInt(R.id.image_widget_item, "setBackgroundResource", R.drawable.rounded_border_jp);

            }
            BookmarkDescriptor bookmark = myDescriptor;
            Bundle extras = new Bundle();
            extras.putString(StackWidgetProvider.EXTRA_INTENT, bookmark.getIntent());
            if (bookmark.getParams() != null) {
                for (Param param : bookmark.getParams()) {
                    extras.putString(param.name, param.value);

                }

            }
            Intent fillInIntent = new Intent(bookmark.getIntent());
            fillInIntent.putExtras(extras);
            rv.setOnClickFillInIntent(R.id.layout, fillInIntent);
        }

    }
    // Return the remote views object.
    // AppWidgetManager manager = AppWidgetManager.getInstance(mContext);
    // manager.updateAppWidget(thisWidget, rv);
    return rv;
}

From source file:com.best.ui.Otpdescdetail.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    System.out.println("in onOptionsItemSelected of stops.java");
    // Handle item selection
    switch (item.getItemId()) {
    /*case com.best.ui.R.id.mnusearch:
        System.out.println("in mnusearch of stops.java");
        if(tripsDisplayed == false)//  www .j a va 2s.  co  m
        {
            Intent intent = new Intent(m_context, Search.class);
            intent.putExtra( "callFromStops" , true );
            me.startActivityForResult( intent, 5 );
            return true;
        }
        else
        {
            Intent intent = new Intent(m_context, Search.class);
            intent.putExtra( "callFromStops" , false );
            me.startActivityForResult( intent, 5 );
            return true;
        } */

    case com.best.ui.R.id.map:
        if (NearTripRoute._stopLat != null && NearTripRoute._stopLon != null) {
            System.out.println("in map of stops.java");
            Bundle bundle1 = new Bundle();
            bundle1.putBoolean("showSingle", false);
            bundle1.putSerializable("StopsGeoX", NearTripRoute._stopLat);
            bundle1.putSerializable("StopsGeoY", NearTripRoute._stopLon);
            Intent intent1 = new Intent(m_context, Map.class);
            intent1.putExtras(bundle1);
            me.startActivityForResult(intent1, 5);
        }
        return true;

    default:
        System.out.println("in default of stops.java");
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.dreamspace.uucampus.ui.base.BaseLazyFragment.java

/**
 * startActivity with bundle/*from www .  j  a va 2  s.c  om*/
 *
 * @param clazz
 * @param bundle
 */
protected void readyGo(Class<?> clazz, Bundle bundle) {
    Intent intent = new Intent(getActivity(), clazz);
    if (null != bundle) {
        intent.putExtras(bundle);
    }
    startActivity(intent);
    getActivity().overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
}

From source file:com.dreamspace.uucampus.ui.base.BaseLazyFragment.java

/**
 * startActivityForResult with bundle// w ww.j av a2 s.c  om
 *
 * @param clazz
 * @param requestCode
 * @param bundle
 */
protected void readyGoForResult(Class<?> clazz, int requestCode, Bundle bundle) {
    Intent intent = new Intent(getActivity(), clazz);
    if (null != bundle) {
        intent.putExtras(bundle);
    }
    startActivityForResult(intent, requestCode);
    getActivity().overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
}