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.futureplatforms.kirin.extensions.networking.NetworkingBackend.java

private void listenForChangeInNetworkStatus() {
    Log.i(C.TAG, "NetworkingBackend.listenForChangeInNetworkStatus: ");
    mReceiver = new BroadcastReceiver() {

        @Override/*from   ww w . ja v  a 2 s.  com*/
        public void onReceive(Context context, Intent intent) {
            if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) {
                String reason = intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
                if (reason == null || reason.trim().length() == 0) {
                    reason = mContext.getString(R.string.networking_connection_lost);
                }
                cancelAllDownloads(reason);
            }
        }

    };
    mContext.registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));

}

From source file:com.gigathinking.simpleapplock.ResetUnlockMethod.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_reset);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    mDialog = new ProgressDialog(this, ProgressDialog.STYLE_SPINNER);
    mDialog.setIndeterminate(true);/*from w ww  . j  a  v  a2  s .com*/
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    mResetReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            prefs.edit().putString(AppLockApplication.LOCKTYPE, AppLockApplication.LOCKTYPE_PIN).commit();
            prefs.edit()
                    .putString(AppLockApplication.PASSWORD, intent.getStringExtra(AppLockApplication.PASSWORD))
                    .commit();
            Toast.makeText(context, getString(R.string.pin_reset), Toast.LENGTH_LONG).show();
            startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)
                    .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
            //startActivity(new Intent(ResetUnlockMethod.this,UnlockWithPIN.class).putExtra("test","test"));
            finish();
        }
    };
    LocalBroadcastManager.getInstance(this).registerReceiver(mResetReceiver,
            new IntentFilter(AppLockApplication.RESET_UNLOCK));

    if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.register_complete),
            false)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(getString(R.string.reset_register_device));
        builder.setTitle(getString(R.string.info));
        builder.setPositiveButton(getString(R.string.register), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                new Register().execute();
                if (mDialog != null) {
                    mDialog.setMessage(getString(R.string.register_ongoing));
                    mDialog.show();
                }
                dialog.dismiss();
            }
        });
        builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_HOME);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }
        });
        builder.create().show();
    } else {
        if (mDialog != null) {
            mDialog.setMessage(getString(R.string.connect_to_server));
            mDialog.show();
        }
        new DoRequestReset().execute();
    }
}

From source file:com.google.zxing.client.android.book.SearchBookContentsActivity.java

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

    fakeR = new FakeR(this);

    // 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  w  w.  j  ava  2s .  com*/
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(fakeR.getId("string", "sbc_name")));
    } else {
        setTitle(getString(fakeR.getId("string", "sbc_name")) + ": ISBN " + isbn);
    }

    setContentView(fakeR.getId("layout", "search_book_contents"));
    queryTextView = (EditText) findViewById(fakeR.getId("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(fakeR.getId("id", "query_button"));
    queryButton.setOnClickListener(buttonListener);

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

From source file:com.example.android.rowanparkingpass.Activities.PassActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pass);
    i = 0;//w ww  .  j  ava 2  s. c om

    Intent pastIntent = getIntent();
    currentMode = pastIntent.getStringExtra(MODE);

    db = new DatabaseHandlerPasses(getApplicationContext());

    Pass pass = (Pass) pastIntent.getSerializableExtra("Pass");
    if (pass == null) {
        driver = (Driver) pastIntent.getSerializableExtra("Driver");
        vehicle = (Vehicle) pastIntent.getSerializableExtra("Vehicle");
    } else {
        driver = pass.getDriver();
        vehicle = pass.getVehicle();
    }

    setDriverView();
    setVehicleView();

    dateFormatter = new SimpleDateFormat("MM/dd/yyyy");

    startDate = (EditText) findViewById(R.id.createstartdatefield);
    startDate.setInputType(InputType.TYPE_NULL);
    startDate.setOnClickListener(this);

    endDate = (EditText) findViewById(R.id.createenddatefield);
    endDate.setInputType(InputType.TYPE_NULL);
    endDate.setOnClickListener(this);

    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    calendar.set(year, month, day);

    startDate.setText(dateFormatter.format(calendar.getTime()));
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    endDate.setText(dateFormatter.format(calendar.getTime()));

    startDatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar newDate = Calendar.getInstance();
            newDate.set(year, monthOfYear, dayOfMonth);
            startDate.setText(dateFormatter.format(newDate.getTime()));
            try {
                Date d = newDate.getTime();
                Date d2 = dateFormatter.parse(endDate.getText().toString());
                if (d.after(d2)) {
                    newDate.add(Calendar.DAY_OF_MONTH, 1);
                    endDate.setText(dateFormatter.format(newDate.getTime()));
                }
            } catch (ParseException pe) {
                pe.printStackTrace();
            }

        }
    }, year, month, day);

    endDatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
            Calendar newDate = Calendar.getInstance();
            newDate.set(year, monthOfYear, dayOfMonth);
            endDate.setText(dateFormatter.format(newDate.getTime()));
            try {
                Date d = newDate.getTime();
                Date d2 = dateFormatter.parse(startDate.getText().toString());
                if (d.before(d2)) {
                    newDate.add(Calendar.DAY_OF_MONTH, -1);
                    startDate.setText(dateFormatter.format(newDate.getTime()));
                }
            } catch (ParseException pe) {
                pe.printStackTrace();
            }
        }
    }, year, month, day);

    createPass = (Button) findViewById(R.id.createPassButton);
    mainMenu = (Button) findViewById(R.id.goMainMenuButton);

    createPass.setOnClickListener(this);
    mainMenu.setOnClickListener(this);
}

From source file:com.mtomczak.nausicaa.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i("Nausicaa", "Procssing activity result");
    if (resultCode == RESULT_OK) {
        try {//from   w ww  .  j a v  a2s .com
            DataSource ds = DataSource.fromPath(data.getStringExtra(DATASOURCE_INTENT));
            telemachusAddress = ds;
            SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
            editor.putString(ADDRESS_PREF, telemachusAddress.getPath());
            editor.commit();
            establishConnection();
        } catch (DataSource.ParseError e) {
            Log.e("Nausicaa", "Bad data from preferences intent: " + e.toString());
        }
    }
}

From source file:cc.arduino.mvd.services.ElisService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    if (!started) {

        url = intent.getStringExtra(MvdServiceReceiver.EXTRA_SERVICE_URL);

        port = intent.getIntExtra(MvdServiceReceiver.EXTRA_SERVICE_PORT, 11414);

        List<BasicNameValuePair> extraHeaders = new ArrayList<>();

        URI uri = URI.create(url + ":" + port);

        webSocketClient = new WebSocketClient(uri, webSocketListener, extraHeaders);

        webSocketClient.connect();/*from www  . ja va 2s .  c  o  m*/

        started = true;

        if (DEBUG) {
            Log.d(TAG, TAG + " started.");
        }
    }

    return START_STICKY;
}

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

/** Called with the activity is first created. */
@Override/*from   w  w w. j av  a 2 s . c om*/
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://mysweetwebsite.com/" + 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");

    // Hook up button presses to the appropriate event handler.
    //((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);
    //((Button) findViewById(R.id.clear)).setOnClickListener(mClearListener);
    ((Button) findViewById(R.id.done)).setOnClickListener(mDone);
    //Log.d(TAG,"...instantiateButtons");

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

    TextView fname = (TextView) findViewById(R.id.first_name);
    fname.setText(String.format(res.getString(R.string.profile_first_name), firstNameIn));

    TextView lname = (TextView) findViewById(R.id.last_name);
    lname.setText(String.format(res.getString(R.string.profile_last_name), lastNameIn));

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

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

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

    TextView mmass = (TextView) findViewById(R.id.mass);
    mmass.setText(String.format(res.getString(R.string.profile_mass), massIn));

    TextView memail = (TextView) findViewById(R.id.email);
    memail.setText(String.format(res.getString(R.string.profile_email), emailIn));

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

    TextView mRfid = (TextView) findViewById(R.id.rfid);
    mRfid.setText(String.format(res.getString(R.string.profile_rfid), rfidIn));

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

    TextView welcome = (TextView) findViewById(R.id.welcome);
    TextView notascigamersentence = (TextView) findViewById(R.id.notascigamersentence);
    setTextViewFont(ExistenceLightOtf, greets);
    setTextViewFont(Museo500Regular, fname, lname, school, teacher, classid, mmass, memail, mpass, mRfid);

    Button Done = (Button) findViewById(R.id.done);
    setButtonFont(ExistenceLightOtf, Done);

    //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://mysweetwebsite.com/push/update_mass.php"); //i'm using MASS just for now
    //set listener
    task.setOnResultsListener(ProfileActivity.this);

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

    //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:com.newtifry.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 NewtifryAccount 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 = NewtifryAccount.FACTORY.getByAccountName(this, sourceIntent.getStringExtra("account"));
    }

    return this.account;
}

From source file:net.evecom.androidecssp.activity.TaskResponseAddActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case 1: // 
        String filePath = data.getStringExtra("filePath");
        Log.v("mars", filePath);
        manageFileDataAndListView(filePath);
        break;//  ww w.jav  a2 s . c  o m
    case 2: //   listView
        fileList.removeAll(fileList);
        List<FileManageBean> allPictures = db.findAll(FileManageBean.class);
        // listView
        for (FileManageBean item : allPictures) {
            fileList.add(item);
        }
        // listView
        uploadPictureAdapter.notifyDataSetChanged();
        if (null != imageListView) {
            UiUtil.setListViewHeightBasedOnChildren(imageListView);
        }
        break;
    default:
        break;
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.bellman.bible.android.view.activity.search.SearchIndex.java

/**
 * Show progress monitor screen/*w  w  w.  j a  v  a 2 s .  co  m*/
 */
private void monitorProgress() {
    // monitor the progress
    Intent intent = new Intent(this, SearchIndexProgressStatus.class);

    // a search may be pre-defined, if so then pass the pre-defined search through so it can be executed directly
    if (getIntent().getExtras() != null) {
        intent.putExtras(getIntent().getExtras());
    }

    // always need to specify which document is being indexed
    if (StringUtils.isEmpty(intent.getStringExtra(SearchControl.SEARCH_DOCUMENT))) {
        // must tell the progress status screen which doc is being downloaded because it checks it downloaded successfully
        intent.putExtra(SearchControl.SEARCH_DOCUMENT, getDocumentToIndex().getInitials());
    }

    startActivity(intent);
    finish();
}