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:com.easy.facebook.android.facebook.FBLoginManager.java

public void loginSuccess(Intent data) {

    String expireTime = data.getStringExtra("expires_in");
    String accessToken = data.getStringExtra("access_token");
    Facebook facebook = new Facebook(this, expireTime, accessToken);
    facebook.save();/*www.ja  v  a  2s  .co  m*/

    ((LoginListener) activity).loginSuccess(facebook);
}

From source file:org.angellist.angellistmobile.LoginActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == 1) {
        if (resultCode == RESULT_OK) {
            String code = intent.getStringExtra("result");

            HashMap<String, String> data = new HashMap<String, String>();

            AsyncHttpPost asyncHttpPost = new AsyncHttpPost(data);
            String client_id = getResources().getString(R.string.client_id);
            String client_secret = getResources().getString(R.string.client_secret);

            asyncHttpPost.execute("https://angel.co/api/oauth/token?client_id=" + client_id + "&client_secret="
                    + client_secret + "&code=" + code + "&grant_type=authorization_code");

        }//from  w ww. j  ava  2s .co  m
        if (resultCode == RESULT_CANCELED) {
            // Write your code if there's no result
        }
    }
}

From source file:com.ateam.alleneatonautorentals.SalesViewCars.java

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

    Intent getIntent = getIntent();
    userEmail = getIntent.getStringExtra("email");
    key = getIntent.getStringExtra("key");
    name = getIntent.getStringExtra("name");

    carsList = new ArrayList<HashMap<String, String>>();

    new LoadAllCars().execute();

    ListView lv = getListView();/*  www.j  ava2  s . c  o  m*/

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent ii = new Intent(getApplicationContext(), SalesCheckoutCar.class);
            String carid = ((TextView) view.findViewById(R.id.car_id_list)).getText().toString();

            ii.putExtra("carid", carid);
            ii.putExtra("reservation", "0");
            ii.putExtra("email", userEmail);
            ii.putExtra("key", key);
            ii.putExtra("name", name);

            startActivity(ii);
            finish();
        }

    });
}

From source file:com.facebook.notifications.internal.activity.CardActivity.java

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

    appEventsLogger = new AppEventsLogger(this);

    Intent intent = getIntent();
    campaignIdentifier = intent.getStringExtra(EXTRA_CAMPAIGN_IDENTIFIER);

    String payloadString = intent.getStringExtra(EXTRA_CARD_PAYLOAD);
    CardConfiguration configuration = intent.getParcelableExtra(EXTRA_CONFIGURATION);

    AssetManager assetManager = intent.getParcelableExtra(EXTRA_ASSET_MANAGER);
    ContentManager contentManager = intent.getParcelableExtra(EXTRA_CONTENT_MANAGER);

    assetManager = assetManager != null ? assetManager : new AssetManager();
    contentManager = contentManager != null ? contentManager : new ContentManager();

    assetManager.setContext(this);
    contentManager.setContext(this);

    this.assetManager = assetManager;
    this.contentManager = contentManager;

    try {//from   w  w  w .jav  a2s .  co  m
        configurationPayload = new JSONObject(payloadString);
    } catch (JSONException ex) {
        Log.e(LOG_TAG, "Error parsing JSON payload", ex);
    }

    if (configuration == null) {
        beginLoadingContent();
    } else {
        displayConfiguration(configuration);
    }

    appEventsLogger.logPushOpen(campaignIdentifier);
}

From source file:eu.trentorise.smartcampus.ac.authenticator.AuthenticatorActivity.java

@Override
protected void setUp() {
    Intent request = getIntent();
    String authTokenType = request.getStringExtra(Constants.KEY_AUTHORITY) != null
            ? request.getStringExtra(Constants.KEY_AUTHORITY)
            : Constants.AUTHORITY_DEFAULT;
    if (Constants.TOKEN_TYPE_ANONYMOUS.equals(authTokenType)) {
        new AsyncTask<Void, Void, UserData>() {
            private ProgressDialog progress = null;

            protected void onPostExecute(UserData result) {
                if (progress != null) {
                    try {
                        progress.cancel();
                    } catch (Exception e) {
                        Log.w(getClass().getName(), "Problem closing progress dialog: " + e.getMessage());
                    }/* w  ww.j a  v  a 2  s.c om*/
                }
                if (result != null && result.getToken() != null) {
                    getAuthListener().onTokenAcquired(result);
                } else {
                    getAuthListener().onAuthFailed("Failed to create anonymous account");
                }
                // TODO
            }

            @Override
            protected void onPreExecute() {
                progress = ProgressDialog.show(AuthenticatorActivity.this, "",
                        AuthenticatorActivity.this.getString(R.string.auth_in_progress), true);
                super.onPreExecute();
            }

            @Override
            protected UserData doInBackground(Void... params) {
                try {
                    return RemoteConnector.createAnonymousUser(Constants.getAuthUrl(AuthenticatorActivity.this),
                            new DeviceUuidFactory(AuthenticatorActivity.this).getDeviceUuid().toString());
                } catch (NameNotFoundException e) {
                    Log.e(Authenticator.class.getName(), "Failed to create anonymous user: " + e.getMessage());
                    return null;
                }
            }
        }.execute();
    } else {
        super.setUp();
    }
}

From source file:first.endtoend.GCMIntentService.java

@Override
protected void onMessage(Context context, Intent intent) {

    String message = intent.getStringExtra("message");
    JSONObject json = null;/* w  w w  .java  2 s .c o m*/

    Log.d(TAG, "RECEIVED A MESSAGE :" + message);

    System.out.println("GCMItentService onMessage :" + message);
    try {
        json = new JSONObject(message);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("notif", json.toString());
        JSONArray array = json.getJSONArray("data");
        int code = json.getInt(Constant.RESPONSE_CODE_KEY);

        switch (code) {
        //add new family
        case Constant.CODE_GCM_1:
            //update existing family
        case Constant.CODE_GCM_2:
            AQueryHelper.load_families(context, params);

            break;

        //delete existing family and all data related to its
        case Constant.CODE_GCM_3:
            if (array.length() > 0)
                for (int i = 0; i < array.length(); i++)
                    AQueryHelper.delete_family(context, array.getInt(i));

            break;

        //add new product
        case Constant.CODE_GCM_4:
            //update existing product
        case Constant.CODE_GCM_5:

            AQueryHelper.load_products(context, params);

            break;

        //delete existing product and all data related to its
        case Constant.CODE_GCM_6:
            if (array.length() > 0)
                for (int i = 0; i < array.length(); i++)
                    AQueryHelper.delete_product(context, array.getInt(i));

            break;

        //add new aid
        case Constant.CODE_GCM_7:

            //update existing aid
        case Constant.CODE_GCM_8:

            AQueryHelper.load_aids(context, params);

            break;

        //delete existing aid and all data related to its
        case Constant.CODE_GCM_9:
            if (array.length() > 0)
                for (int i = 0; i < array.length(); i++)
                    AQueryHelper.delete_aid(context, array.getInt(i));
            break;

        case Constant.CODE_GCM_12:
            try {
                int beneficiaryId = array.getInt(0);
                System.out.println("the id to delete is :" + beneficiaryId);
                BeneficiaryFacade bFacade = new BeneficiaryFacade(context);
                Beneficiary b = bFacade.findById(beneficiaryId);
                if (b != null) {
                    System.out.println(JsonHelper.createJsonObject(b));
                    int familyId = b.getFamily().getFamilyId();
                    List<Integer> list = new ArrayList<Integer>();
                    list.add(familyId);
                    AQueryHelper.delete_beneficiary(context, beneficiaryId);

                    JSONArray jsonArray = new JSONArray(list);
                    Map<String, Object> parameters = new HashMap<String, Object>();
                    JSONObject jo = new JSONObject();
                    jo.put("code", Constant.CODE_GCM_1);
                    jo.put("data", jsonArray);
                    parameters.put("notif", jo.toString());

                    AQueryHelper.load_families(context, parameters);

                } else {
                    System.out.println("No Beneficiary in local with id :" + beneficiaryId);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            break;

        default:
            System.out.println("Code : " + code + " - Non-contracted Code");
            break;
        }

    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.tencent.wetest.activity.DataDetailActivity.java

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

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*ww  w .  j a v a  2s  . c  o  m*/

    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintColor(Color.parseColor("#3367d6"));
        tintManager.setStatusBarTintEnabled(true);
    }

    tvDataDetail = (TextView) findViewById(R.id.dataDetail);

    Intent intent = this.getIntent();

    if (intent != null && intent.hasExtra("filename")) {
        mLogName = intent.getStringExtra("filename");

    }

    String fileDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/wetest";
    mLogFile = new File(fileDir + "/" + mLogName);

    tvFilePathName = (TextView) findViewById(R.id.filePathName);
    tvFilePathName.setText(mLogFile.getAbsolutePath());

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                dataContent = ReportUtil.readFileContent(mLogFile);
            } catch (Exception e) {

                Logger.error("readFileContent error :" + e.toString());
                e.printStackTrace();
            }

            Message msg = mHandler.obtainMessage();
            mHandler.sendMessage(msg);
        }
    }).start();
}

From source file:hongik.android.project.best.HistoryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_history);

    backHandler = new BackPressCloseHandler(this);

    Intent intent = new Intent(this.getIntent());
    cid = intent.getStringExtra("CID");
    historyTable = (TableLayout) findViewById(R.id.history_table);

    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    startActivity(enableBtIntent);// ww  w  .  j av a 2  s  . c o m

    setCentralManager();
    drawHistory();
}

From source file:com.hybris.mobile.activity.BarCodeScannerActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        String contents = data.getStringExtra(SCAN_RESULT);
        String format = data.getStringExtra(SCAN_RESULT_FORMAT);

        Log.i(TAG, "Contents: " + contents);
        Log.i(TAG, "format: " + format);
        String isUseSpecificBaseUrl = Hybris
                .getSharedPreferenceString(InternalConstants.KEY_PREF_TOGGLE_SPECIFIC_BASE_URL);

        if (StringUtils.equals(isUseSpecificBaseUrl, String.valueOf(false))) {
            Log.i(TAG, "calling default handler for url: " + contents);
            // We run the task to check the format and data availability of the barcode scanned
            new CheckBarcodeFormatAndValueTask().execute(contents, format);
        } else {// w w  w  .  ja v  a2s .c o m
            //isScannerRunning = false;
            //            WebView myWebView = new WebView(this);
            //            myWebView = (WebView) findViewById(R.layout.app_web_view);
            Log.i(TAG, "calling webview activity with url: " + contents);
            //            myWebView.loadUrl(contents);
            //            WebSettings webSettings = myWebView.getSettings();
            //            webSettings.setJavaScriptEnabled(true);
            Intent localintent = new Intent(Hybris.getAppContext(), ScanCodeWebViewActivity.class);
            localintent.putExtra(Constants.DATA, contents);
            localintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            Log.i(TAG, "Sending intent to start webview for url");
            Hybris.getAppContext().startActivity(localintent);
        }
    } else if (resultCode == RESULT_CANCELED) {
        Message msg = new Message();
        msg.what = BarCodeScannerActivity.MSG_CANCEL_SCAN;
        mHandler.sendMessage(msg);
    }
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.SignSearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate() " + this.hashCode());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_activity);
    if (null != savedInstanceState) {
        this.query = savedInstanceState.getString(QUERY);
    } else {// www  . ja  v  a  2  s  .  co  m
        final Intent intent = getIntent();
        this.query = StringUtils
                .trimToEmpty(StringUtils.stripToEmpty(intent.getStringExtra(SearchManager.QUERY)));
        Validate.notNull(this.query, "The query supplied to this activity is null!");
    }
    setupRecyclerView();
    setupSupportActionBar();
    this.signSearchTask = new SearchSignsTask(this);
    this.signSearchTask.execute(this.query);
}