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.notifry.android.SourceList.java

/**
 * Fetch the account that this source list is for.
 * //from  w  w w  . j a  va  2s . c  o  m
 * @return
 */
public NotifryAccount getAccount() {
    if (this.account == null) {
        // Get the account from the intent.
        // We store it in a private variable to save us having to query the
        // DB each time.
        Intent sourceIntent = getIntent();
        this.account = NotifryAccount.FACTORY.getByAccountName(this, sourceIntent.getStringExtra("account"));
    }

    return this.account;
}

From source file:org.lol.reddit.activities.PostSubmitActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    super.onCreate(savedInstanceState);

    final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.post_submit);

    typeSpinner = (Spinner) layout.findViewById(R.id.post_submit_type);
    usernameSpinner = (Spinner) layout.findViewById(R.id.post_submit_username);
    subredditEdit = (EditText) layout.findViewById(R.id.post_submit_subreddit);
    titleEdit = (EditText) layout.findViewById(R.id.post_submit_title);
    textEdit = (EditText) layout.findViewById(R.id.post_submit_body);

    final Intent intent = getIntent();
    if (intent != null) {

        if (intent.hasExtra("subreddit")) {

            final String subreddit = intent.getStringExtra("subreddit");

            if (subreddit != null && subreddit.length() > 0 && !subreddit.matches("/?(r/)?all/?")
                    && subreddit.matches("/?(r/)?\\w+/?")) {
                subredditEdit.setText(subreddit);
            }//from   w ww .  java2  s .c om

        } else if (Intent.ACTION_SEND.equalsIgnoreCase(intent.getAction())
                && intent.hasExtra(Intent.EXTRA_TEXT)) {
            final String url = intent.getStringExtra(Intent.EXTRA_TEXT);
            textEdit.setText(url);
        }

    } else if (savedInstanceState != null && savedInstanceState.containsKey("post_title")) {
        titleEdit.setText(savedInstanceState.getString("post_title"));
        textEdit.setText(savedInstanceState.getString("post_body"));
        subredditEdit.setText(savedInstanceState.getString("subreddit"));
        typeSpinner.setSelection(savedInstanceState.getInt("post_type"));
    }

    final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts();
    final ArrayList<String> usernames = new ArrayList<String>();

    for (RedditAccount account : accounts) {
        if (!account.isAnonymous()) {
            usernames.add(account.username);
        }
    }

    if (usernames.size() == 0) {
        General.quickToast(this, R.string.error_toast_notloggedin);
        finish();
    }

    usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames));
    typeSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, postTypes));

    // TODO remove the duplicate code here
    setHint();

    typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            setHint();
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    final ScrollView sv = new ScrollView(this);
    sv.addView(layout);
    setContentView(sv);
}

From source file:com.librelio.activity.MainMagazineActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1001) {
        //         int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
        String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
        //         String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");

        if (resultCode == RESULT_OK & purchaseData != null) {
            try {
                JSONObject jo = new JSONObject(purchaseData);
                String sku = jo.getString("productId");
                Log.d(TAG, "You have bought the " + sku + ". Excellent choice,adventurer!");
            } catch (JSONException e) {
                Log.e(TAG, "Failed to parse purchase data.", e);
            }//from  ww w. ja v a2s . c o  m
        }
    }
}

From source file:com.scigames.slidegame.ObjectiveActivity.java

/** Called with the activity is first created. */
@Override/*from   w  ww  .java2 s .c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    Log.d(TAG, "super.OnCreate");
    Intent i = getIntent();
    Log.d(TAG, "getIntent");
    rfidIn = i.getStringExtra("rfid");
    studentIdIn = i.getStringExtra("studentId");
    slideLevelIn = i.getStringExtra("slideLevel");
    //       photoUrl = i.getStringExtra("photo");
    //       photoUrl = "http://db.scigam.es/" + photoUrl;
    Log.d(TAG, "...getStringExtra");
    // Inflate our UI from its XML layout description.
    setContentView(R.layout.objective_page);
    Log.d(TAG, "...setContentView");
    objectiveImgNum = 0;

    //resultImg[0] = "http://db.scigam.es/narrative_images/Level0/results/_0012_Layer-Comp-13.png";
    //resultImg[1] = "http://db.scigam.es/narrative_images/Level0/results/_0012_Layer-Comp-13.png";

    alertDialog = new AlertDialog.Builder(ObjectiveActivity.this).create();
    alertDialog.setTitle("No Registration System Attached ");
    alertDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT).show();
            finish();
        }
    });

    infoDialog = new AlertDialog.Builder(ObjectiveActivity.this).create();
    infoDialog.setTitle("Debug Info");
    infoDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            //Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT).show();
        }
    });

    needSlideDataDialog = new AlertDialog.Builder(ObjectiveActivity.this).create();
    needSlideDataDialog.setTitle("Debug Info");
    needSlideDataDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            //Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT).show();
            Intent i = new Intent(ObjectiveActivity.this, LoginActivity.class);
            Log.d(TAG, "new LoginActivity Intent");
            i.putExtra("page", "login");
            Log.d(TAG, "startActivity...");
            ObjectiveActivity.this.startActivity(i);
            Log.d(TAG, "...startActivity");
        }
    });

    ExistenceLightOtf = Typeface.createFromAsset(getAssets(), "fonts/Existence-Light.ttf");
    Museo300Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo300-Regular.otf");
    Museo500Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo500-Regular.otf");
    Museo700Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo700-Regular.otf");

    reviewBtnNext = (Button) findViewById(R.id.btn_next);
    reviewBtnNext.setOnClickListener(mNext);
    reviewBtnNext.setVisibility(View.INVISIBLE);
    reviewBtnBack = (Button) findViewById(R.id.btn_back);
    reviewBtnBack.setOnClickListener(mBack);
    reviewBtnBack.setVisibility(View.INVISIBLE);
    btnContinue = (Button) findViewById(R.id.btn_continue);
    btnContinue.setOnClickListener(mContinue);

    getObjectiveImages(slideLevelIn);
    //level 0 : 50 kin, 50 therm
    //level 1 : 60 kin, 40 therm
    //level 2 : 40 kin, 60 therm
    //level 3 : 70 kin, 30 therm
    //level 4 : 30 kin, 70 therm
}

From source file:io.v.android.apps.syncslides.DeckChooserFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_CODE_IMPORT_DECK:
        if (resultCode != Activity.RESULT_OK) {
            String errorStr = data != null && data.hasExtra(DocumentsContract.EXTRA_ERROR)
                    ? data.getStringExtra(DocumentsContract.EXTRA_ERROR)
                    : "";
            toast("Error selecting deck to import " + errorStr);
            break;
        }//from   w w  w  . j  av  a 2s  .  c om
        Uri uri = data.getData();
        importDeck(DocumentFile.fromTreeUri(getContext(), uri));
        break;
    }
}

From source file:com.gmail.srivi.sundaram.locgenie.DisplayPlacesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);/*from w  w  w .j a v a  2 s.  c om*/
    Intent intent = getIntent();
    Location loc = (Location) intent.getExtras().getParcelable(MainActivity.EXTRA_MESSAGE);
    String radius = intent.getStringExtra(MainActivity.RADIUS);
    String activityChosen = intent.getStringExtra(MainActivity.ACTIVITY);
    radiusMain = radius;
    activity = activityChosen;
    userIcon = R.drawable.user;

    if (theMap == null) {
        SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        theMap = mapFrag.getMap();
        /*theMap = ((MapFragment) getFragmentManager().findFragmentById(
              R.id.map)).getMap();*/
        if (theMap != null) {
            theMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
            placeMarkers = new Marker[MAX_PLACES];
        }

    }

    double lat = loc.getLatitude();
    double lng = loc.getLongitude();
    LatLng lastLatLng = new LatLng(lat, lng);
    theMap.moveCamera(CameraUpdateFactory.newLatLngZoom(lastLatLng, 8));
    if (userMarker != null)
        userMarker.remove();
    userMarker = theMap.addMarker(
            new MarkerOptions().position(lastLatLng).anchor(0.0f, 1.0f).title("You are currently here")
                    .icon(BitmapDescriptorFactory.fromResource(userIcon)).snippet("Your most recent location"));

    displayPlaces(loc, radius, activityChosen);

}

From source file:org.quantumbadger.redreader.activities.PostSubmitActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    super.onCreate(savedInstanceState);

    final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.post_submit);

    typeSpinner = (Spinner) layout.findViewById(R.id.post_submit_type);
    usernameSpinner = (Spinner) layout.findViewById(R.id.post_submit_username);
    subredditEdit = (EditText) layout.findViewById(R.id.post_submit_subreddit);
    titleEdit = (EditText) layout.findViewById(R.id.post_submit_title);
    textEdit = (EditText) layout.findViewById(R.id.post_submit_body);

    final Intent intent = getIntent();
    if (intent != null) {

        if (intent.hasExtra("subreddit")) {

            final String subreddit = intent.getStringExtra("subreddit");

            if (subreddit != null && subreddit.length() > 0 && !subreddit.matches("/?(r/)?all/?")
                    && subreddit.matches("/?(r/)?\\w+/?")) {
                subredditEdit.setText(subreddit);
            }/* ww  w .j ava2s  .c  o  m*/

        } else if (intent.getAction().equalsIgnoreCase(Intent.ACTION_SEND)
                && intent.hasExtra(Intent.EXTRA_TEXT)) {
            final String url = intent.getStringExtra(Intent.EXTRA_TEXT);
            textEdit.setText(url);
        }

    } else if (savedInstanceState != null && savedInstanceState.containsKey("post_title")) {
        titleEdit.setText(savedInstanceState.getString("post_title"));
        textEdit.setText(savedInstanceState.getString("post_body"));
        subredditEdit.setText(savedInstanceState.getString("subreddit"));
        typeSpinner.setSelection(savedInstanceState.getInt("post_type"));
    }

    final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts();
    final ArrayList<String> usernames = new ArrayList<String>();

    for (RedditAccount account : accounts) {
        if (!account.isAnonymous()) {
            usernames.add(account.username);
        }
    }

    if (usernames.size() == 0) {
        General.quickToast(this, R.string.error_toast_notloggedin);
        finish();
    }

    usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames));
    typeSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, postTypes));

    // TODO remove the duplicate code here
    setHint();

    typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            setHint();
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    final ScrollView sv = new ScrollView(this);
    sv.addView(layout);
    setContentView(sv);
}

From source file:com.scigames.slidegame.Registration3MassActivity.java

/** Called with the activity is first created. */
@Override/*from   ww  w.  ja va 2  s  .c  o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "super.OnCreate");
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    Intent i = getIntent();
    Log.d(TAG, "getIntent");
    firstNameIn = i.getStringExtra("fName");
    lastNameIn = i.getStringExtra("lName");
    studentIdIn = i.getStringExtra("studentId");
    visitIdIn = i.getStringExtra("visitId");
    Log.d(TAG, "...getStringExtra");

    // Inflate our UI from its XML layout description.
    setContentView(R.layout.registration3_mass);
    Log.d(TAG, "...setContentView");

    // Find the text editor view inside the layout, because we
    // want to do various programmatic things with it.
    thisMass = (EditText) findViewById(R.id.mass);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    thisMass.setInputType(InputType.TYPE_NULL);
    thisMass.setOnTouchListener(new View.OnTouchListener() {
        //@Override
        public boolean onTouch(View v, MotionEvent event) {
            thisMass.setInputType(InputType.TYPE_CLASS_TEXT);
            thisMass.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });
    Log.d(TAG, "...instantiateEditTexts");

    //display name in greeting sentence
    Resources res = getResources();
    TextView greets = (TextView) findViewById(R.id.greeting);
    greets.setText(String.format(res.getString(R.string.greeting), firstNameIn, lastNameIn));
    Log.d(TAG, greets.toString());
    Log.d(TAG, "...Greetings");

    //set info to what we know already
    //firstName.setText(firstNameIn);
    //lastName.setText(lastNameIn);

    // Hook up button presses to the appropriate event handler.
    ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);
    ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener);
    ((Button) findViewById(R.id.scan)).setOnClickListener(mScanButtonListener);
    Log.d(TAG, "...instantiateButtons");

    //set listener
    task.setOnResultsListener(this);
}

From source file:com.clearcenter.mobile_demo.mdAuthenticatorActivity.java

public void onCreate(Bundle bundle) {
    Log.i(TAG, "onCreate(" + bundle + ")");
    super.onCreate(bundle);
    setContentView(R.layout.login_activity);

    account_manager = AccountManager.get(this);

    Log.i(TAG, "loading data from Intent");
    final Intent intent = getIntent();

    nickname = intent.getStringExtra(PARAM_NICKNAME);
    username = intent.getStringExtra(PARAM_USERNAME);
    hostname = intent.getStringExtra(PARAM_HOSTNAME);

    request_new_account = nickname == null;
    confirm_credentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);
    Log.i(TAG, "new account? " + request_new_account + ", confirm credentials? " + confirm_credentials);

    scroll_view = (ScrollView) findViewById(R.id.scroll_view);

    message = (TextView) findViewById(R.id.message);

    nickname_label = (TextView) findViewById(R.id.nickname_label);
    nickname_edit = (EditText) findViewById(R.id.nickname_edit);
    nickname_label.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    nickname_edit.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    if (nickname != null)
        nickname_edit.setText(nickname);

    hostname_label = (TextView) findViewById(R.id.hostname_label);
    hostname_edit = (EditText) findViewById(R.id.hostname_edit);
    hostname_label.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    hostname_edit.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    if (hostname != null)
        hostname_edit.setText(hostname);

    username_label = (TextView) findViewById(R.id.username_label);
    username_edit = (EditText) findViewById(R.id.username_edit);
    username_label.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    username_edit.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    if (username != null)
        username_edit.setText(username);

    password_edit = (EditText) findViewById(R.id.password_edit);

    if (confirm_credentials) {
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager notification_manager;
        notification_manager = (NotificationManager) getApplicationContext().getSystemService(ns);
        notification_manager.cancelAll();
        Log.i(TAG, "TODO: Cancel all notifications?");
    }/*from  w ww .java  2s  . c  o m*/

    if (!TextUtils.isEmpty(nickname))
        nickname_edit.setText(nickname);

    if (request_new_account)
        message.setText(getText(R.string.login_activity_new_account));
    else if (confirm_credentials) {
        message.setText(getText(R.string.login_activity_confirm_credentials));
    }

    try {
        mdSSLUtil.DisableSecurity();
    } catch (GeneralSecurityException e) {
        Toast.makeText(getApplicationContext(), e.getMessage(), 4).show();
    }
}

From source file:com.scrachx.foodfacts.checker.ui.main.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    setIntent(intent);// ww  w.ja  v a  2 s. c  o  m
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        Bundle args = new Bundle();
        args.putString("query", query);
        if (EAN13CheckDigit.EAN13_CHECK_DIGIT.isValid(query) && (!query.substring(0, 3).contains("977")
                || !query.substring(0, 3).contains("978") || !query.substring(0, 3).contains("979"))) {
            mPresenter.loadProduct(query);
        } else {
            mSearchView.clearFocus();
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.fragment_container, SearchFragment.newInstance(args), SearchFragment.TAG)
                    .commit();
        }
    }
}