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:foo.fruitfox.evend.LoginActivity.java

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

    setContentView(R.layout.activity_login);

    Intent intent = getIntent();
    registrationType = intent.getStringExtra("type");

    LinearLayout activityLogin = (LinearLayout) findViewById(R.id.activity_login);
    setLayout(registrationType, activityLogin);

    verificationLayout = (LinearLayout) findViewById(R.id.verificationLayout);
    verificationLayout.setVisibility(View.GONE);

}

From source file:eu.e43.impeller.account.LoginActivity.java

@Override
public void onCreate(Bundle icicle) {
    Log.v(TAG, "onCreate(" + icicle + ")");
    super.onCreate(icicle);
    setContentView(R.layout.activity_login);

    m_accountManager = AccountManager.get(this);
    final Intent intent = getIntent();

    String id = intent.getStringExtra("id");

    m_idView = (TextView) findViewById(R.id.id);
    m_loginButton = (Button) findViewById(R.id.sign_in_button);
    m_loginFormView = findViewById(R.id.login_form);
    m_loginStatusView = findViewById(R.id.login_status);
    m_webView = (WebView) findViewById(R.id.web_view);
    m_idView.setText(id);//from   w  w  w.j  av a 2s. c o m

    m_loginButton.setOnClickListener(this);
    m_webView.setWebViewClient(new WebViewListener());
}

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

/**
 * Reload adapter with correct data/*from   w  w  w. j  a  v a 2 s  . c om*/
 * 
 * @param intent
 *            the intent
 */
private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);

        DataHolder dataHolder = DataHolder.getInstance();
        BusData busData = dataHolder.getBusData();
        TrainData trainData = dataHolder.getTrainData();

        List<Station> foundStations = new ArrayList<Station>();

        for (Entry<TrainLine, List<Station>> e : trainData.getAllStations().entrySet()) {
            for (Station station : e.getValue()) {
                boolean res = StringUtils.containsIgnoreCase(station.getName(), query.trim());
                if (res) {
                    if (!foundStations.contains(station)) {
                        foundStations.add(station);
                    }
                }
            }
        }

        List<BusRoute> foundBusRoutes = new ArrayList<BusRoute>();

        for (BusRoute busRoute : busData.getRoutes()) {
            boolean res = StringUtils.containsIgnoreCase(busRoute.getId(), query.trim())
                    || StringUtils.containsIgnoreCase(busRoute.getName(), query.trim());
            if (res) {
                if (!foundBusRoutes.contains(busRoute)) {
                    foundBusRoutes.add(busRoute);
                }
            }
        }

        List<BikeStation> foundBikeStations = new ArrayList<BikeStation>();
        if (mBikeStations != null) {
            for (BikeStation bikeStation : mBikeStations) {
                boolean res = StringUtils.containsIgnoreCase(bikeStation.getName(), query.trim())
                        || StringUtils.containsIgnoreCase(bikeStation.getStAddress1(), query.trim());
                if (res) {
                    if (!foundBikeStations.contains(bikeStation)) {
                        foundBikeStations.add(bikeStation);
                    }
                }
            }
        }
        mAdapter.updateData(foundStations, foundBusRoutes, foundBikeStations);
        mAdapter.notifyDataSetChanged();
    }
}

From source file:com.mocap.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1001) {
        String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
        if (resultCode == RESULT_OK) {
            try {
                JSONObject jo = new JSONObject(purchaseData);
                String sku = jo.getString(inappid);
                Toast.makeText(this, "You have bought the " + sku, Toast.LENGTH_LONG).show();
                ;/*from  w w  w . j  a  va2 s  .com*/
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:com.tcs.geofenceplugin.GeofenceTransitionsIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.d(TAG, "Handling intent");
    gcmid = intent.getStringExtra("gcmid");
    tokenid = intent.getStringExtra("tokenid");
    GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
    if (geofencingEvent.hasError()) {
        String errorMessage = GeofenceErrorMessages.getErrorString(this, geofencingEvent.getErrorCode());
        Log.d(TAG, errorMessage);//  ww w  .  ja va2  s  .co m
        return;
    }

    int geofenceTransition = geofencingEvent.getGeofenceTransition();

    if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER
            || geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) {

        Log.d(TAG, "recieved");
        URL url;
        HttpURLConnection urlConnection = null;
        try {
            url = new URL("https://apphonics.tcs.com/geofence/Analytics?tokenid=" + tokenid);
            urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.setRequestMethod("GET");
            urlConnection.connect();
            int responseCode = urlConnection.getResponseCode();
            if (responseCode == 200) {
                Log.d(TAG, "Analytics data entered");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences();

        getGeofenceTransitionDetails(this, geofenceTransition, triggeringGeofences);

    } else {
        Log.e(TAG, getString(R.string.geofence_transition_invalid_type, geofenceTransition));
    }

}

From source file:export.GooglePlus.java

@Override
public Status getAuthResult(int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        try {//from w w  w. ja  v  a2 s . c  om
            String authConfig = data.getStringExtra(DB.ACCOUNT.AUTH_CONFIG);
            JSONObject tmp = new JSONObject(authConfig);
            access_token = tmp.getString("access_token");
            refresh_token = tmp.optString("refresh_token", null);
            expire_time = tmp.getLong("expires_in");
            token_now = System.currentTimeMillis();
            return Status.OK;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    return Status.ERROR;
}

From source file:biz.atelecom.communicator.RegistrationIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (mSharedPreferences == null) {
        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    }/*from  w  ww  . j  a  v  a2  s  .c  om*/
    mNumber = intent.getStringExtra(ARG_NUMBER);

    try {
        // [START register_for_gcm]
        // Initially this call goes out to the network to retrieve the token, subsequent calls
        // are local.
        // R.string.gcm_defaultSenderId (the Sender ID) is typically derived from google-services.json.
        // See https://developers.google.com/cloud-messaging/android/start for details on this file.
        // [START get_token]
        InstanceID instanceID = InstanceID.getInstance(this);
        String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
                GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
        // [END get_token]
        Log.d(TAG, "GCM Registration Token: " + token);

        sendRegistrationToServer(token);

        // Subscribe to topic channels
        subscribeTopics(token);

        // [END register_for_gcm]
    } catch (Exception e) {
        Log.d(TAG, "Failed to complete token refresh", e);
    }
    // Notify UI that registration has completed, so the progress indicator can be hidden.
    Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE);
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}

From source file:com.cloverstudio.spika.GCMIntentService.java

/**
 * Method called on Receiving a new message
 * *///from   w  ww  .  j  ava 2 s .com
@Override
protected void onMessage(Context context, Intent intent) {

    Bundle pushExtras = intent.getExtras();
    String pushMessage = intent.getStringExtra(Const.PUSH_MESSAGE);
    String pushFromName = intent.getStringExtra(Const.PUSH_FROM_NAME);
    try {
        boolean appIsInForeground = new SpikaApp.ForegroundCheckAsync().execute(getApplicationContext()).get();
        boolean screenLocked = ((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE))
                .inKeyguardRestrictedInputMode();
        if (appIsInForeground && !screenLocked) {

            mPushBroadcast.replaceExtras(pushExtras);

            LocalBroadcastManager.getInstance(this).sendBroadcast(mPushBroadcast);
        } else {
            triggerNotification(this, pushMessage, pushFromName, pushExtras);
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }

}

From source file:com.google.zxing.BarcodeScanner.java

/**
* Called when the barcode scanner intent completes
*
* @param requestCode       The request code originally supplied to startActivityForResult(),
*                          allowing you to identify who this result came from.
* @param resultCode        The integer result code returned by the child activity through its setResult().
* @param intent            An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
*///from  w ww .  j  a  v  a  2s  . c  o m
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            JSONObject obj = new JSONObject();
            try {
                obj.put(TEXT, intent.getStringExtra("SCAN_RESULT"));
                obj.put(FORMAT, intent.getStringExtra("SCAN_RESULT_FORMAT"));
                obj.put(CANCELLED, false);
            } catch (JSONException e) {
                //Log.d(LOG_TAG, "This should never happen");
            }
            this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback);
        }
        if (resultCode == Activity.RESULT_CANCELED) {
            JSONObject obj = new JSONObject();
            try {
                obj.put(TEXT, "");
                obj.put(FORMAT, "");
                obj.put(CANCELLED, true);
            } catch (JSONException e) {
                //Log.d(LOG_TAG, "This should never happen");
            }
            this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback);
        } else {
            this.error(new PluginResult(PluginResult.Status.ERROR), this.callback);
        }
    }
}

From source file:com.kraker.myocmd.TestService1.DeviceControlActivity.java

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

    setContentView(R.layout.device_control);
    mTitle = mDrawerTitle = getTitle();/*from w  w  w  .jav a  2  s  . c  om*/
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        //setSupportActionBar(toolbar);
    }

    final Intent intent = getIntent();
    String mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
    mHandler = new android.os.Handler();
    mHandler.postDelayed(mStatusChecker, 5000);
    DisplayMetrics metrics = new DisplayMetrics();
}