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.scigames.registration.ProfileActivity.java

/** Called with the activity is first created. */
@Override/*from w  w w  . j  ava 2 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");
    firstNameIn = i.getStringExtra("fName");
    lastNameIn = i.getStringExtra("lName");
    //       passwordIn = i.getStringExtra("password");
    //       massIn = i.getStringExtra("mass");
    //       emailIn = i.getStringExtra("email");
    //       classIdIn = i.getStringExtra("classId");
    studentIdIn = i.getStringExtra("studentId");
    visitIdIn = i.getStringExtra("visitId");
    //       rfidIn = i.getStringExtra("rfid");
    photoUrl = i.getStringExtra("photoUrl");
    photoUrl = "http://db.scigam.es/" + photoUrl;
    //       slideLevel = i.getStringExtra("slideLevel");
    //       cartLevel = i.getStringExtra("cartLevel");
    Log.d(TAG, "...getStringExtra");
    // Inflate our UI from its XML layout description.
    setContentView(R.layout.profile_page);
    Log.d(TAG, "...setContentView");

    //display name and profile info
    Resources res = getResources();
    greets = (TextView) findViewById(R.id.student_name);
    greets.setText(String.format(res.getString(R.string.profile_name), firstNameIn, lastNameIn));
    setTextViewFont(Museo700Regular, greets);

    //schoolname = (TextView)findViewById(R.id.school_name);
    //schoolname.setText(String.format(res.getString(R.string.profile_school_name), "from DB"));

    teachername = (TextView) findViewById(R.id.teacher_name);
    //teachername.setText(String.format(res.getString(R.string.profile_teacher_name), "from DB"));

    classname = (TextView) findViewById(R.id.class_name);

    classid = (TextView) findViewById(R.id.class_id);
    //classid.setText(String.format(res.getString(R.string.profile_classid), classIdIn));

    mpass = (TextView) findViewById(R.id.password);
    //mpass.setText(String.format(res.getString(R.string.profile_password), passwordIn));

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

    //       TextView welcome = (TextView)findViewById(R.id.welcome);
    //       TextView notascigamersentence = (TextView)findViewById(R.id.notascigamersentence);

    // Hook up button presses to the appropriate event handler.
    //((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);
    //((Button) findViewById(R.id.clear)).setOnClickListener(mClearListener);

    Log.d(TAG, "...instantiateButtons");
    Done = (Button) findViewById(R.id.done);
    Done.setOnClickListener(mDone);
    setButtonFont(ExistenceLightOtf, Done);

    alertDialog = new AlertDialog.Builder(ProfileActivity.this).create();
    // Setting Dialog Title
    alertDialog.setTitle("alert title");
    // Setting Dialog Message
    alertDialog.setMessage("alert message");
    // Setting Icon to Dialog
    //alertDialog.setIcon(R.drawable.tick);

    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(), "Check your login info!", Toast.LENGTH_SHORT).show();
        }
    });

    //set listener
    task.setOnResultsListener(this);

    //push picture back.-- photo
    task.cancel(true);

    //create a new async task for every time you hit login (each can only run once ever)
    task = new SciGamesHttpPoster(ProfileActivity.this, "http://db.scigam.es/pull/return_profile.php");
    //set listener
    task.setOnResultsListener(ProfileActivity.this);

    //prepare key value pairs to send
    String[] keyVals = { "student_id", studentIdIn, "visit_id", visitIdIn };

    //create AsyncTask, then execute
    @SuppressWarnings("unused")
    AsyncTask<String, Void, JSONObject> serverResponse = null;
    serverResponse = task.execute(keyVals);
    Log.d(TAG, "...task.execute(keyVals)");

}

From source file:net.olejon.mdapp.NotesEditActivity.java

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

    // Intent/*from  www .j a  v  a 2 s.c  o  m*/
    final Intent intent = getIntent();

    final String noteTitle = intent.getStringExtra("title");

    noteId = intent.getIntExtra("id", 0);

    // Layout
    setContentView(R.layout.activity_notes_edit);

    // Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.notes_edit_toolbar);

    final String title = (noteId == 0) ? getString(R.string.notes_edit_title_new)
            : getString(R.string.notes_edit_title_edit);

    toolbar.setTitle(title);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Elements
    mTitleEditText = (EditText) findViewById(R.id.notes_edit_title);
    mTextEditText = (EditText) findViewById(R.id.notes_edit_text);
    mPatientIdEditText = (EditText) findViewById(R.id.notes_edit_patient_id);
    mPatientNameEditText = (EditText) findViewById(R.id.notes_edit_patient_name);
    mPatientDoctorEditText = (EditText) findViewById(R.id.notes_edit_patient_doctor);
    mPatientDepartmentEditText = (EditText) findViewById(R.id.notes_edit_patient_department);
    mPatientRoomEditText = (EditText) findViewById(R.id.notes_edit_patient_room);
    mPatientMedicationsTextView = (TextView) findViewById(R.id.notes_edit_patient_medications);

    if (noteTitle != null && !noteTitle.equals(""))
        mTitleEditText.setText(noteTitle);

    Button patientAddMedicationButton = (Button) findViewById(R.id.notes_edit_patient_add_medication);

    patientAddMedicationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(mContext, NotesEditMedicationsActivity.class);
            startActivityForResult(intent, MEDICATION_REQUEST_CODE);
        }
    });

    // Note
    getNote();
}

From source file:fi.hut.soberit.accelerometer.AccelerometerAxisUploader.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d(TAG, "onStartCommand");
    int res = super.onStartCommand(intent, flags, startId);

    if (intent == null) {
        return res;
    }// ww w.j  a v a2  s. c  o  m

    handler = new Handler();

    final StringBuilder builder = new StringBuilder();

    builder.append(intent.getStringExtra(INTENT_AHL_URL));
    builder.append("?");
    builder.append("username=");
    builder.append(intent.getStringExtra(INTENT_USERNAME));
    builder.append("&");
    builder.append("password=");
    builder.append(intent.getStringExtra(INTENT_PASSWORD));
    builder.append("&");
    builder.append("weblet=");
    builder.append(intent.getStringExtra(INTENT_WEBLET));

    baseUrl = builder.toString();

    Log.d(TAG, baseUrl);

    handler.postDelayed(updater, UploadRecords.UPLOAD_FREQUENCY);

    return res;
}

From source file:com.mytalentfolio.h_daforum.MainActivityChat1.java

/**
 * Gets the attached intent data.//www . j  a  va  2s  .c o m
 */
private void getIntentData() {
    Intent i = getIntent();
    courseID = i.getStringExtra("courseID");
    userID = i.getStringExtra("userID");
    //getDataFromServer(courseID);
}

From source file:com.offbye.bookmaster.android.book.SearchBookContentsActivity.java

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

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();
    if (intent == null || (!intent.getAction().equals(Intents.SearchBookContents.ACTION))) {
        finish();//from w  ww  . ja va  2s  .c om
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (isbn.startsWith("http://google.com/books?id=")) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && initialQuery.length() > 0) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = (Button) findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
}

From source file:org.geometerplus.android.fbreader.network.NetworkCatalogActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case BASIC_AUTHENTICATION_CODE:
        synchronized (myCredentialsCreator) {
            if (resultCode == AuthenticationActivity.RESULT_OK && data != null) {
                myCredentialsCreator.myUsername = data.getStringExtra(AuthenticationActivity.USERNAME_KEY);
                myCredentialsCreator.myPassword = data.getStringExtra(AuthenticationActivity.PASSWORD_KEY);
            }/*from   ww w . j  av  a  2s. c  o  m*/
            myCredentialsCreator.notify();
        }
        break;
    case CUSTOM_AUTHENTICATION_CODE:
        Util.processCustomAuthentication(this, ((NetworkCatalogTree) myTree).Item.Link, resultCode, data);
        break;
    case SIGNUP_CODE:
        Util.processSignup(((NetworkCatalogTree) myTree).Item.Link, resultCode, data);
        break;
    }
}

From source file:com.krayzk9s.imgurholo.services.DownloadService.java

@Override
protected void onHandleIntent(Intent intent) {
    final NotificationManager notificationManager = (NotificationManager) this
            .getSystemService(Context.NOTIFICATION_SERVICE);
    ids = intent.getParcelableArrayListExtra("ids");
    albumName = "/";
    downloaded = 0;/*from   w ww  . j  a  va  2  s  .co m*/
    if (ids.size() > 0) {
        albumName += intent.getStringExtra("albumName") + "/";
        File myDirectory = new File(
                android.os.Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                albumName);
        if (!myDirectory.exists()) {
            myDirectory.mkdirs();
        }
    }
    for (int i = 0; i < ids.size(); i++) {
        try {
            final String type = ids.get(i).getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TYPE)
                    .split("/")[1];
            final String id = ids.get(i).getJSONObject().getString("id");
            final String link = ids.get(i).getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK);
            Log.d("data", ids.get(i).getJSONObject().toString());
            Log.d(ImgurHoloActivity.IMAGE_DATA_TYPE,
                    ids.get(0).getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TYPE).split("/")[1]);
            Log.d("id", ids.get(i).getJSONObject().getString("id"));
            Log.d(ImgurHoloActivity.IMAGE_DATA_LINK,
                    ids.get(0).getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK));
            final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
            notificationBuilder.setContentTitle(getString(R.string.picture_download))
                    .setContentText(getString(R.string.download_in_progress))
                    .setSmallIcon(R.drawable.icon_desaturated);
            Ion.with(getApplicationContext(), link).progress(new ProgressCallback() {
                @Override
                public void onProgress(int i, int i2) {
                    notificationBuilder.setProgress(i2, i, false);
                }
            }).write(new File(
                    android.os.Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
                            + albumName + id + "." + type))
                    .setCallback(new FutureCallback<File>() {
                        @Override
                        public void onCompleted(Exception e, File file) {
                            if (file == null)
                                return;
                            downloaded += 1;
                            if (downloaded == ids.size()) {
                                NotificationCompat.Builder notificationComplete = new NotificationCompat.Builder(
                                        getApplicationContext());
                                if (ids.size() == 1) {
                                    Intent viewImageIntent = new Intent(Intent.ACTION_VIEW);
                                    viewImageIntent.setDataAndType(Uri.fromFile(file), "image/*");
                                    Intent shareIntent = new Intent(Intent.ACTION_SEND);
                                    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                                    shareIntent.setType("image/*");
                                    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
                                    PendingIntent viewImagePendingIntent = PendingIntent.getActivity(
                                            getApplicationContext(), (int) System.currentTimeMillis(),
                                            viewImageIntent, 0);
                                    PendingIntent sharePendingIntent = PendingIntent.getActivity(
                                            getApplicationContext(), (int) System.currentTimeMillis(),
                                            shareIntent, 0);
                                    notificationComplete.setContentTitle(getString(R.string.download_complete))
                                            .setSmallIcon(R.drawable.icon_desaturated)
                                            .setContentText(String.format(getString(R.string.download_progress),
                                                    downloaded))
                                            .setContentIntent(viewImagePendingIntent)
                                            .addAction(R.drawable.dark_social_share, getString(R.string.share),
                                                    sharePendingIntent);
                                } else {
                                    Intent i = new Intent(Intent.ACTION_PICK);
                                    i.setDataAndType(
                                            Uri.fromFile(new File(
                                                    android.os.Environment.getExternalStoragePublicDirectory(
                                                            Environment.DIRECTORY_PICTURES) + albumName)),
                                            "image/*");
                                    PendingIntent viewImagePendingIntent = PendingIntent.getActivity(
                                            getApplicationContext(), (int) System.currentTimeMillis(), i, 0);
                                    notificationComplete.setContentTitle(getString(R.string.download_complete))
                                            .setSmallIcon(R.drawable.icon_desaturated).setContentText(String
                                                    .format(getString(R.string.download_progress), downloaded))
                                            .setContentIntent(viewImagePendingIntent);
                                }
                                notificationManager.cancel(0);
                                notificationManager.cancel(1);
                                notificationManager.notify(1, notificationComplete.build());
                            }
                            MediaScannerConnection.scanFile(getApplicationContext(),
                                    new String[] { android.os.Environment.getExternalStoragePublicDirectory(
                                            Environment.DIRECTORY_PICTURES) + albumName + id + "." + type },
                                    null, new MediaScannerConnection.OnScanCompletedListener() {
                                        @Override
                                        public void onScanCompleted(final String path, final Uri uri) {
                                            Log.i("Scanning", String.format("Scanned path %s -> URI = %s", path,
                                                    uri.toString()));
                                        }
                                    });
                        }
                    });
            notificationManager.notify(0, notificationBuilder.build());
        } catch (JSONException e) {
            Log.e("Error!", e.toString());
        }
    }
}

From source file:com.microsoft.onenote.pickerlib.OneNotePickerActivity.java

private void readExtras() {
    Intent intent = getIntent();
    mNavTextColor = intent.getIntExtra("NAV_TEXT_COLOR", -1);
    mAccessToken = intent.getStringExtra("ACCESS_TOKEN");
    mThemeColor = (OneNotePickerThemeColor) intent.getSerializableExtra("THEME_COLOR");
}

From source file:net.kourlas.voipms_sms.activities.ConversationsActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1001 && resultCode == RESULT_OK) {
        try {/*from  ww  w .j  a va2s.c  om*/
            String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
            JSONObject json = new JSONObject(purchaseData);
            String token = json.getString("purchaseToken");
            billing.postDonation(token, this);
        } catch (Exception ignored) {
            // Do nothing.
        }
    }
}