Example usage for android.content Intent getStringExtra

List of usage examples for android.content Intent getStringExtra

Introduction

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

Prototype

public String getStringExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:net.eledge.android.europeana.gui.activity.SearchActivity.java

private void handleIntent(Intent intent) {
    String query = null;/*from  ww  w.  j  a va  2s .c  o m*/
    String[] qf = null;
    if (intent != null) {

        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            query = intent.getStringExtra(SearchManager.QUERY);
            qf = splitFacets(intent.getStringExtra(SearchManager.USER_QUERY));
        } else if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
            Parcelable[] parcelables = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
            NdefMessage msg = (NdefMessage) parcelables[0];
            Uri uri = Uri.parse(new String(msg.getRecords()[0].getPayload()));
            query = uri.getQueryParameter("query");
            qf = StringArrayUtils.toArray(uri.getQueryParameters("qf"));
        } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
            query = intent.getDataString();
            if (!TextUtils.isEmpty(query)) {
                if (StringUtils.contains(query, "europeana.eu/")) {
                    Uri uri = Uri.parse(query);
                    query = uri.getQueryParameter("query");
                    qf = StringArrayUtils.toArray(uri.getQueryParameters("qf"));
                }
            }
        } else {
            // no search action recognized? end this activity...
            closeSearchActivity();
        }
        if (!TextUtils.isEmpty(query) && !TextUtils.equals(runningSearch, query)) {
            runningSearch = query;
            if (StringArrayUtils.isNotBlank(qf)) {
                searchController.newSearch(this, query, qf);
            } else {
                searchController.newSearch(this, query);
            }
            getSupportActionBar().setTitle(searchController.getSearchTitle(this));
        }
    }
}

From source file:io.v.android.apps.account_manager.AccountActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account);
    mBaseContext = V.init(this);

    Intent intent = getIntent();
    if (intent == null) {
        replyWithError("Intent not found.");
        return;/*from  w  w  w .  jav a2 s.c  o m*/
    }
    // See if the caller wants to use a specific Google account to create the Vanadium account.
    // If null or empty string is passed, the user will be prompted to choose the Google
    // account to use.
    mAccountName = intent.getStringExtra(GOOGLE_ACCOUNT);
    if (mAccountName != null && !mAccountName.isEmpty()) {
        getIdentity();
        return;
    }
    Intent chooseIntent = AccountManager.newChooseAccountIntent(null, null, new String[] { "com.google" },
            false, null, null, null, null);
    startActivityForResult(chooseIntent, REQUEST_CODE_PICK_ACCOUNTS);
}

From source file:cm.aptoide.pt.RemoteInTab.java

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

    File local_path = new File(LOCAL_PATH);
    if (!local_path.exists())
        local_path.mkdir();//  ww  w .  j av  a2  s.  c om

    File icon_path = new File(ICON_PATH);
    if (!icon_path.exists())
        icon_path.mkdir();

    db = new DbHandler(this);

    sPref = getSharedPreferences("aptoide_prefs", MODE_PRIVATE);
    prefEdit = sPref.edit();
    prefEdit.putBoolean("update", true);
    prefEdit.commit();

    myTabHost = getTabHost();
    myTabHost.addTab(myTabHost.newTabSpec("avail")
            .setIndicator("Available", getResources().getDrawable(android.R.drawable.ic_menu_add))
            .setContent(new Intent(this, TabAvailable.class)));
    myTabHost.addTab(myTabHost.newTabSpec("inst")
            .setIndicator("Installed", getResources().getDrawable(android.R.drawable.ic_menu_agenda))
            .setContent(new Intent(this, TabInstalled.class)));
    myTabHost.addTab(myTabHost.newTabSpec("updt")
            .setIndicator("Updates", getResources().getDrawable(android.R.drawable.ic_menu_info_details))
            .setContent(new Intent(this, TabUpdates.class)));

    myTabHost.setPersistentDrawingCache(ViewGroup.PERSISTENT_SCROLLING_CACHE);

    Vector<ServerNode> srv_lst = db.getServers();
    if (srv_lst.isEmpty()) {
        Intent call = new Intent(this, ManageRepo.class);
        call.putExtra("empty", true);
        call.putExtra("uri", "http://apps.aptoide.org");
        startActivityForResult(call, NEWREPO_FLAG);
    }

    Intent i = getIntent();
    if (i.hasExtra("uri")) {
        Intent call = new Intent(this, ManageRepo.class);
        call.putExtra("uri", i.getStringExtra("uri"));
        startActivityForResult(call, NEWREPO_FLAG);
    } else if (i.hasExtra("newrepo")) {
        Intent call = new Intent(this, ManageRepo.class);
        call.putExtra("newrepo", i.getStringExtra("newrepo"));
        startActivityForResult(call, NEWREPO_FLAG);
    }
}

From source file:com.ptts.fragments.BusLocation.java

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

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    showProgressBar();//from   w  w w.  j  a v a2 s .c om

    txtBusId = (TextView) findViewById(R.id.bus_plate);
    txtBusTime = (TextView) findViewById(R.id.time_label);

    Intent in = getIntent();
    cd = new ConnectionDetector(getApplicationContext());

    bus_id = in.getStringExtra(FetchBusTask.getKeyBusid());
    String latitude = in.getStringExtra(FetchBusTask.getKeyLatitude());
    String longitude = in.getStringExtra(FetchBusTask.getKeyLongitude());

    bus_id = bus_id.substring(6).replace("/", "");

    txtBusId.setText("Bus " + bus_id);
    //txtBusTime.setText(latitude);
    if (!cd.isConnectingToInternet()) {
        Toast.makeText(getApplicationContext(), "Connect to Internet First", Toast.LENGTH_LONG).show();
        return;
    } else {
        //to get bus plate number
        ServerConnection connect = new ServerConnection();
        connect.execute(new String[] { bus_id });

    }

    // Getting LocationManager object from System Service LOCATION_SERVICE
    locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    // Getting Google Play availability status
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

    if (status != ConnectionResult.SUCCESS) { // Google Play Services are not available

        int requestCode = 10;
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
        dialog.show();

    } else { // Google Play Services are available

        // Getting reference to the SupportMapFragment
        SupportMapFragment fragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);

        // Getting Google Map
        mGoogleMap = fragment.getMap();

        // Enabling MyLocation in Google Map
        mGoogleMap.setMyLocationEnabled(true);

        // Creating a criteria object to retrieve provider
        Criteria criteria = new Criteria();

        // Getting the name of the best provider
        String provider = locationManager.getBestProvider(criteria, true);

        if (provider != null) {

            // Getting Current Location From GPS
            Location location = locationManager.getLastKnownLocation(provider);

            if (location != null) {
                onLocationChanged(location);
            }

            locationManager.requestLocationUpdates(provider, 20000, 0, this);

        }

    } //end else

    mGoogleMap.addMarker(new MarkerOptions()
            .position(new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude))).title(bus_id)
            .snippet(latitude));

    //find the distance between the two
    LatLng origin = new LatLng(mLatitude, mLongitude);
    LatLng dest = new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude));

    // Getting URL to the Google Directions API
    String url = getDirectionsUrl(origin, dest);

    DownloadTask downloadTask = new DownloadTask();

    // Start downloading json data from Google Directions API
    downloadTask.execute(url);

}

From source file:com.androidquery.simplefeed.fragments.CommentFragment.java

public void postCb(int requestCode, int resultCode, Intent data) {

    AQUtility.debug("getting result!");

    if (data == null)
        return;//w  ww  . j a  v  a  2s. c o m

    String toast = data.getStringExtra("toast");
    act.showToast(toast);

    String itemId = data.getStringExtra("itemId");
    String message = data.getStringExtra("message");
    if (itemId != null) {
        commented(itemId, message);
    }

}

From source file:it.feio.android.omninotes.async.DataBackupIntentService.java

synchronized private void deleteData(Intent intent) {

    // Gets backup folder
    String backupName = intent.getStringExtra(INTENT_BACKUP_NAME);
    File backupDir = StorageHelper.getBackupDir(backupName);

    // Backup directory removal
    StorageHelper.delete(this, backupDir.getAbsolutePath());

    String title = getString(R.string.data_deletion_completed);
    String text = backupName + " " + getString(R.string.deleted);
    createNotification(intent, this, title, text, backupDir);
}

From source file:com.amazonaws.mobileconnectors.s3.transferutility.TransferService.java

@Override
@SuppressWarnings("checkstyle:hiddenfield")
public int onStartCommand(Intent intent, int flags, int startId) {
    this.startId = startId;

    if (intent == null) {
        return START_REDELIVER_INTENT;
    }//from  w ww  .  j  a  va  2  s .c  o m

    final String keyForS3Client = intent.getStringExtra(INTENT_BUNDLE_S3_REFERENCE_KEY);
    s3 = S3ClientReference.get(keyForS3Client);
    if (s3 == null) {
        LOGGER.warn("TransferService can't get s3 client, and it will stop.");
        stopSelf(startId);
        return START_NOT_STICKY;
    }

    updateHandler.sendMessage(updateHandler.obtainMessage(MSG_EXEC, intent));
    if (isFirst) {
        registerReceiver(networkInfoReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
        isFirst = false;
    }
    /*
     * The service will not restart if it's killed by system.
     */
    return START_NOT_STICKY;
}

From source file:com.google.sample.beaconservice.MainActivityFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == Constants.REQUEST_CODE_PICK_ACCOUNT) {
        // Receiving a result from the AccountPicker
        if (resultCode == Activity.RESULT_OK) {
            String name = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            accountNameView.setText(name);
            SharedPreferences.Editor editor = sharedPreferences.edit();
            editor.putString("accountName", name);
            editor.apply();/*from  www . ja v  a 2 s.  c o  m*/
        } else if (resultCode == Activity.RESULT_CANCELED) {
            // The account picker dialog closed without selecting an account.
            // Notify users that they must pick an account to proceed.
            Toast.makeText(getActivity(), "Please pick an account", Toast.LENGTH_SHORT).show();
        }
    } else if (requestCode == Constants.REQUEST_CODE_ENABLE_BLE) {
        if (resultCode == Activity.RESULT_OK) {
            createScanner();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Toast.makeText(getActivity(), "Please enable Bluetooth", Toast.LENGTH_SHORT).show();
        }
    }
}

From source file:it.gmariotti.android.examples.googleaccount.SmsBackupGDriveActivity.java

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    switch (requestCode) {
    case REQUEST_ACCOUNT_PICKER:

        if (resultCode == RESULT_OK) {
            mAccountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
            prefs.edit().putString(PREF_ACCOUNT_NAME, mAccountName).commit();

            if (mAccountName != null) {
                backupSmsToGDrive();//from   w w w .  j a v a 2 s. c o  m
            }

        }
        break;
    case REQUEST_AUTHORIZATION_FOLDER:
        if (resultCode == RESULT_OK) {
            backupSmsToGDrive();
        } else {
            startActivityForResult(mCredential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
        }
        break;

    }
}

From source file:com.ucai.test.control.DeviceControlActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gatt_services_characteristics);
    initView();/* w  ww .ja  v a  2s  .  co  m*/
    //EditActivity
    Intent intentCon = getIntent();
    sex = intentCon.getIntExtra("sex", 1);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.UI
    //TODO 
    //((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
    //mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
    //  mGattServicesList.setOnChildClickListener(servicesListClickListner);
    mConnectionState = (TextView) findViewById(R.id.connection_state);//?
    mDataField = (TextView) findViewById(R.id.data_value);
    mDeviceDataField = (TextView) findViewById(R.id.device_type_value);//?
    mDeviceDataName = (TextView) findViewById(R.id.device_type_name);//?

    //        getActionBar().setTitle(mDeviceName);
    //        getActionBar().setDisplayHomeAsUpEnabled(true);
    //TODO ??
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);

    //???
    tv_weight_center.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(DeviceControlActivity.this, DeviceScanActivity.class);
            new DeviceScanActivity();
            //                startActivity(intent);
            //                finish();
        }
    });
}