Example usage for android.content Intent hasExtra

List of usage examples for android.content Intent hasExtra

Introduction

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

Prototype

public boolean hasExtra(String name) 

Source Link

Document

Returns true if an extra value is associated with the given name.

Usage

From source file:auribises.com.visitorbook.Activites.AdminEntryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_admin_entry);

    ButterKnife.inject(this);

    preferences = getSharedPreferences(Util.PREFS_NAME, MODE_PRIVATE);
    editor = preferences.edit();//from  w  ww .  j  a v  a  2 s .co  m

    progressDialog = new ProgressDialog(this);
    progressDialog.setMessage("Please Wait..");
    progressDialog.setCancelable(false);

    adminentry = new Adminentry();

    adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item);
    adapter1.add("--Select IDProof--");
    adapter1.add("Aadhar Card");
    adapter1.add("License");
    adapter1.add("PAN Card");
    adapter1.add("Voter Card");

    spIDProof.setAdapter(adapter1);

    spIDProof.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            if (i != 0) {
                adminentry.setIDProof(adapter1.getItem(i));
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    adapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item);
    adapter2.add("--Vehicle Type--");
    adapter2.add("None");
    adapter2.add("Car");
    adapter2.add("Bike");
    adapter2.add("Activa");

    spVehicle.setAdapter(adapter2);

    spVehicle.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            if (i != 0) {
                adminentry.setVehicle(adapter2.getItem(i));
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    rbMale.setOnCheckedChangeListener(this);
    rbFemale.setOnCheckedChangeListener(this);

    resolver = getContentResolver();

    requestQueue = Volley.newRequestQueue(this);

    Intent rcv = getIntent();
    updateMode = rcv.hasExtra("keyAdminentry");

    if (updateMode) {
        rcvAdminentry = (Adminentry) rcv.getSerializableExtra("keyAdminentry");
        eTxtName.setText(rcvAdminentry.getName());
        eTxtPhone.setText(rcvAdminentry.getPhone());
        eTxtEmail.setText(rcvAdminentry.getEmail());
        eTxtAddress.setText(rcvAdminentry.getAddress());
        eTxtPurpose.setText(rcvAdminentry.getPurpose());
        eTxtDate.setText(rcvAdminentry.getDate());
        eTxtTime.setText(rcvAdminentry.getTime());
        eTxtAdmin.setText(rcvAdminentry.getAdmin());
        eTxtIDProofNumber.setText(rcvAdminentry.getIDProofnumber());
        eTxtVehicleNumber.setText(rcvAdminentry.getVehiclenumber());

        if (rcvAdminentry.getGender().equals("Male")) {
            rbMale.setChecked(true);
        } else {
            rbFemale.setChecked(true);
        }

        int q = 0;
        for (int i = 0; i < adapter1.getCount(); i++) {
            if (adapter1.getItem(i).equals(rcvAdminentry.getIDProof())) {
                Log.i("TEST2", adapter1.getItem(i) + " - " + rcvAdminentry.getIDProof());
                q = i;
                break;
            }
        }
        spIDProof.setSelection(q);

        int r = 0;
        for (int i = 0; i < adapter2.getCount(); i++) {
            if (adapter2.getItem(i).equals(rcvAdminentry.getVehicle())) {
                Log.i("TEST3", adapter2.getItem(i) + " - " + rcvAdminentry.getVehicle());
                r = i;
                break;
            }
        }
        spVehicle.setSelection(r);

        btnSubmit.setText("Update");
    }
}

From source file:com.ycdyng.onemulti.OneActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    mFragmentManager = getSupportFragmentManager();
    if (savedInstanceState != null) {
        mCurrentPrimaryItem = getNextFragment();
        if (mCurrentPrimaryItem != null) {
            return;
        }//from   w ww . j av  a2  s .c  o m
    }
    String className = null;
    Intent intent = getIntent();
    if (intent != null && intent.hasExtra(FRAGMENT_NAME)) {
        className = intent.getStringExtra(FRAGMENT_NAME);
    } else {
        Class cls = getDefaultFragment();
        if (cls != null) {
            className = cls.getName();
        }
    }
    if (className != null) {
        initFragment(className, intent == null ? null : intent.getExtras());
    }
}

From source file:com.jaus.albertogiunta.justintrain_oraritreni.journeyFavourites.FavouriteJourneysActivity.java

private void checkIntent(Intent intent) {
    if (intent.hasExtra("on_notification_click_action")) {
        ClickActionHelper.startActivity(intent.getStringExtra("on_notification_click_action"),
                intent.getExtras(), this);
    }/*w  ww. j av  a2  s. c om*/
}

From source file:com.spondbob.bluetooth.BluetoothActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case 0:/*from  ww  w .  java  2 s  . c o  m*/
        if (resultCode == RESULT_OK) {
            Toast.makeText(this, "Bluetooth enabled", Toast.LENGTH_SHORT).show();
            doDiscovery();
        } else {
            Toast.makeText(this, "Bluetooth still disabled", Toast.LENGTH_SHORT).show();
        }
        break;
    case 1:
        if (resultCode == RESULT_OK) {
            if (data.hasExtra("classId")) {
                doSendData(data.getExtras().getString("classId"));
            } else {
                Toast.makeText(this, "no selected class", Toast.LENGTH_SHORT).show();
            }
        }
        break;
    }
}

From source file:com.ubergeek42.WeechatAndroid.WeechatActivity.java

@MainThread
@Override/*from www . ja v  a  2s .  c o  m*/
@Cat("Intent")
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent.hasExtra(NOTIFICATION_EXTRA_BUFFER_FULL_NAME)) {
        setIntent(intent);
        if (started)
            openBufferFromIntent();
    }
}

From source file:com.shearosario.tothepathandback.ClosestStationsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_closest_stations);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    context = this;
    activity = this;

    adView = (AdView) this.findViewById(R.id.adViewClosest);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice("949F5429A9EC251C1DD4395558D33531").build();
    // AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);//  www .  j a va  2  s.  c  om

    if (intent.hasExtra("Manual")) {
        double[] manual = intent.getDoubleArrayExtra("Manual");
        origin = new LatLng(manual[0], manual[1]);
    } else if (intent.hasExtra("Current")) {
        double[] current = intent.getDoubleArrayExtra("Current");
        origin = new LatLng(current[0], current[1]);
    }

    double[] entranceMeasures = intent.getDoubleArrayExtra("closestSortMeasures");
    ArrayList<Entrance> closestEntrances = intent.getParcelableArrayListExtra("closestEntrances");

    MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, R.layout.listitem, closestEntrances,
            entranceMeasures);
    //ListAdapter adapter = createListAdapter(allStationsSortDistance);
    ListView listview = (ListView) findViewById(R.id.ClosestStationsList);
    listview.setAdapter(adapter);
    //setListAdapter(adapter);

    final GoogleMap gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapview)).getMap();
    gMap.setMyLocationEnabled(false);
    gMap.addMarker(new MarkerOptions().title("Origin").position(origin));
    gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(origin, 13));
    gMap.setBuildingsEnabled(false);
    gMap.getUiSettings().setZoomControlsEnabled(false);

    TextView textView = (TextView) findViewById(R.id.osm_directions);
    textView.setText(Html.fromHtml("Data provided by  OpenStreetMap contributors "
            + "<a href=\"http://www.openstreetmap.org/copyright\">License</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    textView = (TextView) findViewById(R.id.directions_text);
    textView.setText(Html.fromHtml(
            "Directions, Nominatim Search Courtesy of " + "<a href=\"http://www.mapquest.com\">MapQuest</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Entrance item = (Entrance) parent.getItemAtPosition(position);

            gMap.clear();

            LatLngBounds bounds = new LatLngBounds.Builder().include(origin)
                    .include(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])).build();

            gMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));

            gMap.addMarker(new MarkerOptions().title("Origin").position(origin));

            String stationName = null;
            for (int i = 0; i < MainActivity.getAllStations().size(); i++) {
                if (item.getStopid().equalsIgnoreCase(MainActivity.getAllStations().get(i).getStopID())) {
                    stationName = MainActivity.getAllStations().get(i).getStopName();
                    break;
                }
            }

            gMap.addMarker(new MarkerOptions()
                    // .title(item.getStationName())
                    .title(stationName)
                    .position(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])));

            Button button = (Button) findViewById(R.id.button_destination);
            button.setEnabled(true);
            // button.setText("Select " + item.getStationName());
            button.setText("Select " + stationName);

            button.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    /*
                     * To check if the phone is currently using a network connection. 
                     * Listens to broadcasts when the the device is or is not connected to 
                     * a network
                     */
                    ConnectivityManager cm = (ConnectivityManager) context
                            .getSystemService(Context.CONNECTIVITY_SERVICE);
                    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
                    boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
                    if (!isConnected) {
                        Toast.makeText(context, "No network connection", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    new DisplayDirectionsIntent(context, activity, origin, item);
                }
            });
        }
    });
}

From source file:com.ichi2.anki.Reviewer.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_STATISTICS || requestCode == REQUEST_BROWSE_CARDS) {
        // select original deck if the statistics or card browser were opened,
        // which can change the selected deck
        if (data != null && data.hasExtra("originalDeck")) {
            getCol().getDecks().select(data.getLongExtra("originalDeck", 0L));
        }//from   w  w w .j a v a2 s  . co  m
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.scigames.registration.Registration4PhotoActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAMERA_REQUEST) {
        or.setVisibility(View.VISIBLE);
        retakeButton.setVisibility(View.VISIBLE);
        saveButton.setVisibility(View.VISIBLE);
        takePhotoButton.setVisibility(View.INVISIBLE);

        if (data.hasExtra("data")) {
            //change to new view
            photo = (Bitmap) data.getExtras().get("data");
            //photoUri = data.getExtras().get("data");
            Log.d(TAG, "photoDensity: ");
            Log.d(TAG, String.valueOf(photo.getDensity()));
            Log.d(TAG, "photo getHeight:");
            Log.d(TAG, String.valueOf(photo.getHeight()));
            Log.d(TAG, "photo getWidth");
            Log.d(TAG, String.valueOf(photo.getWidth()));
            Log.d(TAG, "photo config:");
            if (photo.getHeight() < photo.getWidth()) {
                Log.d(TAG, "height < width");

                Log.d(TAG, photo.getConfig().toString());
                photoToSend = Bitmap.createBitmap(120, 160, photo.getConfig());
                //photoToSend = Bitmap.createBitmap(photo);
                Canvas canvas = new Canvas(photoToSend);
                Log.d(TAG, "photo getScaledHeight:");
                Log.d(TAG, String.valueOf(photo.getScaledHeight(canvas)));
                Log.d(TAG, "photo getScaledWidth");
                Log.d(TAG, String.valueOf(photo.getScaledWidth(canvas)));
                Matrix matrix = new Matrix();
                //matrix.preScale(-1.0f, 1.0f);
                //Bitmap mirroredBitmap = Bitmap.createBitmap(photo, 0, 0, photo.getWidth(), photo.getHeight());
                matrix.setRotate(270, photo.getWidth() / 2, photo.getHeight() / 2);

                //matrix.postTranslate(photo.getWidth(),photo.getHeight());
                Log.d(TAG, matrix.toString());
                canvas.drawBitmap(photo, matrix, new Paint());
            } else {
                Log.d(TAG, photo.getConfig().toString());
                photoToSend = Bitmap.createBitmap(120, 160, photo.getConfig());
                //photoToSend = Bitmap.createBitmap(photo); 
                Canvas canvas = new Canvas(photoToSend);
                Log.d(TAG, "photo getScaledHeight:");
                Log.d(TAG, String.valueOf(photo.getScaledHeight(canvas)));
                Log.d(TAG, "photo getScaledWidth");
                Log.d(TAG, String.valueOf(photo.getScaledWidth(canvas)));
                Matrix matrix = new Matrix();
                //matrix.preScale(-1.0f, 1.0f);
                //Bitmap mirroredBitmap = Bitmap.createBitmap(photo, 0, 0, photo.getWidth(), photo.getHeight());
                //matrix.setRotate(0, photo.getWidth()/2, photo.getHeight()/2);
                //matrix.setScale(0.9f, 0.9f);
                Log.d(TAG, matrix.toString());
                //matrix.postTranslate(photo.getWidth(),photo.getHeight());

                canvas.drawBitmap(photo, matrix, new Paint());
                avatarPhoto.setScaleX(0.95f);
                avatarPhoto.setScaleY(0.95f);
                avatarPhoto.setX(180f);/*from   ww  w .j a  v a  2 s.  com*/
                avatarPhoto.setY(440f);
            }
            avatarPhoto.setImageBitmap(photoToSend);

            Log.d(TAG, "photoToSendDensity: ");
            Log.d(TAG, String.valueOf(photoToSend.getDensity()));
            Log.d(TAG, "photoToSend getScaledHeight:");
            Log.d(TAG, String.valueOf(photoToSend.getHeight()));
            Log.d(TAG, "photoToSend getScaledWidth");
            Log.d(TAG, String.valueOf(photoToSend.getWidth()));
        } else {
            or.setVisibility(View.INVISIBLE);
            saveButton.setVisibility(View.INVISIBLE);
            retakeButton.setVisibility(View.INVISIBLE);
            takePhotoButton.setVisibility(View.VISIBLE);
            //instruction.setText("");
        }
    }
}

From source file:com.razza.apps.iosched.myschedule.MyScheduleActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    LogUtils.LOGD(TAG, "onNewIntent, extras " + intent.getExtras());
    if (intent.hasExtra(EXTRA_DIALOG_MESSAGE)) {
        mShowedAnnouncementDialog = false;
        showAnnouncementDialogIfNeeded(intent);
    }//from ww w.j  a v a2s  .  c om
}

From source file:com.achep.base.ui.activities.SettingsActivity.java

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

    // Should happen before any call to getIntent()
    getMetaData();//from  w w  w  .  j  a v a  2 s  . co  m

    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
        getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
    }

    // Getting Intent properties can only be done after the super.onCreate(...)
    final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);

    mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent)
            || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false);

    final ComponentName cn = intent.getComponent();
    final String className = cn.getClassName();

    boolean isShowingDashboard = className.equals(Settings2.class.getName());

    // This is a "Sub Settings" when:
    // - this is a real SubSettings
    // - or :settings:show_fragment_as_subsetting is passed to the Intent
    final boolean isSubSettings = className.equals(SubSettings.class.getName())
            || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);

    // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content insets
    if (isSubSettings) {
        // Check also that we are not a Theme Dialog as we don't want to override them
        /*
        final int themeResId = getTheme(). getThemeResId();
        if (themeResId != R.style.Theme_DialogWhenLarge &&
            themeResId != R.style.Theme_SubSettingsDialogWhenLarge) {
        setTheme(R.style.Theme_SubSettings);
        }
        */
    }

    setContentView(R.layout.settings_main_dashboard);

    mContent = (ViewGroup) findViewById(android.R.id.content);

    getSupportFragmentManager().addOnBackStackChangedListener(this);

    if (savedState != null) {
        // We are restarting from a previous saved state; used that to initialize, instead
        // of starting fresh.

        setTitleFromIntent(intent);

        ArrayList<DashboardCategory> categories = savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES);
        if (categories != null) {
            mCategories.clear();
            mCategories.addAll(categories);
            setTitleFromBackStack();
        }

        mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
    } else {
        if (!isShowingDashboard) {
            mDisplayHomeAsUpEnabled = isSubSettings;
            setTitleFromIntent(intent);

            Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
            switchToFragment(initialFragmentName, initialArguments, true, false, mInitialTitleResId,
                    mInitialTitle, false);
        } else {
            mDisplayHomeAsUpEnabled = false;
            mInitialTitleResId = R.string.app_name;
            switchToFragment(DashboardFragment.class.getName(), null, false, false, mInitialTitleResId,
                    mInitialTitle, false);
        }
    }

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
        actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
    }
}