Example usage for android.content Intent getExtras

List of usage examples for android.content Intent getExtras

Introduction

In this page you can find the example usage for android.content Intent getExtras.

Prototype

public @Nullable Bundle getExtras() 

Source Link

Document

Retrieves a map of extended data from the intent.

Usage

From source file:se.anyro.tagtider.TransferActivity.java

@Override
protected void onNewIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras.getString("id") != null) {
        mTransferId = extras.getString("id");
    }//www  .jav a  2 s  .com
    new FetchChangesTask().execute(mTransferId);
}

From source file:com.BreakingBytes.SifterReader.SifterReader.java

/** Determine activity by result code. */
@Override/*from  w  w  w.  j  av a 2s  .  co m*/
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (intent == null)
        return;

    Bundle extras = intent.getExtras();
    if (extras == null)
        return;

    switch (requestCode) {
    case ACTIVITY_LOGIN:
        mDomain = extras.getString(DOMAIN);
        mAccessKey = extras.getString(ACCESS_KEY);
        mSifterHelper = new SifterHelper(this, mAccessKey);
        if (mDomain.length() == 0 || mAccessKey.length() == 0) {
            try {
                mLoginError = mSifterHelper.onMissingToken();
                loginKeys();
            } catch (Exception e) {
                e.printStackTrace();
                mSifterHelper.onException(e.toString());
                return;
            }
            break;
        } // if keys are empty return to LoginActivity
        String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS;
        URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL);
        if (sifterConnection == null) {
            loginKeys();
            break;
        } // if URL misformatted return to LoginActivity
        mDialog = ProgressDialog.show(this, "", "Loading ...", true);
        new DownloadSifterTask().execute(sifterConnection);
        break;
    }
}

From source file:com.example.appf.CS3570.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    cam = false;//  w  w w  . jav a  2s  . c  om

    // Just in case we are coming from the ServerActivity
    if (extras != null) {
        if (extras.containsKey("server_name"))
            SERVER_IP = extras.getString("server_name");
        if (extras.containsKey("server_port"))
            SERVERPORT = Integer.parseInt(extras.getString("server_port"));
    }
    filter = new IMUfilter(.1f, 5);
    filter.reset();

    // Set up reset button
    Button b = new Button(this);
    b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            filter.reset();
        }
    });
    b.setText("Reset");

    // Set up camera mode. Are we going to use this?
    Button c = new Button(this);
    c.setText("Camera Mode");
    c.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            filter.reset();
            mGLView.mRenderer.mCamera = new Camera();
            cam = !cam;
        }
    });
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setBackgroundColor(Color.parseColor("#21C9FF"));
    ll.addView(b);
    ll.addView(c);
    // Create a GLSurfaceView instance and set it
    // as the ContentView for this Activity
    mGLView = new MyGLSurfaceView(this, this);
    ll.addView(mGLView);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    gyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    accelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    magnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    setContentView(ll);
    new Thread(new SocketThread()).start();
}

From source file:com.rei.lolchat.ui.Login.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == LOGIN_REQUEST_CODE) {
        mIsResult = true;/*from ww  w  .  j a va2 s  .co  m*/
        if (resultCode == Activity.RESULT_OK) {
            startActivity(new Intent(this, ContactList.class));
            finish();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            if (data != null) {
                String tmp = data.getExtras().getString("message");
                Toast.makeText(Login.this, tmp, Toast.LENGTH_SHORT).show();
                mTextView.setText(tmp);

                SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this);
                String server = mSettings.getString(BeemApplication.LEVEL_KEY, "");

                tv_na = (TextView) findViewById(R.id.status_na);
                tv_eune = (TextView) findViewById(R.id.status_eune);
                tv_euw = (TextView) findViewById(R.id.status_euw);

                String text = "";

                text = "<font color='#0099FF'>[US]</font> Checking...";
                tv_na.setText(Html.fromHtml(text));

                text = "<font color='#0099FF'>[EU-NE]</font> Checking...";
                tv_eune.setText(Html.fromHtml(text));

                text = "<font color='#0099FF'>[EU-W]</font> Checking...";
                tv_euw.setText(Html.fromHtml(text));

                loadServerStatusTask task = new loadServerStatusTask();
                task.execute("na");

                loadServerStatusTask task2 = new loadServerStatusTask();
                task2.execute("eune");

                loadServerStatusTask task3 = new loadServerStatusTask();
                task3.execute("euw");

            }
        }
    }
}

From source file:com.qbcps.sifterclient.SifterReader.java

/** Determine activity by result code. */
@Override//w  ww.  ja v a 2s.  c  om
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (intent == null)
        return;

    Bundle extras = intent.getExtras();
    if (extras == null)
        return;

    switch (requestCode) {
    case ACTIVITY_LOGIN:
        mDomain = extras.getString(DOMAIN);
        mAccessKey = extras.getString(ACCESS_KEY);
        mSifterHelper = new SifterHelper(this, mAccessKey);
        if (mDomain.length() == 0 || mAccessKey.length() == 0) {
            try {
                mLoginError = mSifterHelper.onMissingToken();
                loginKeys(null);
            } catch (Exception e) {
                e.printStackTrace();
                mSifterHelper.onException(e.toString());
                return;
            }
            break;
        } // if keys are empty return to LoginActivity
        String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS;
        URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL);
        if (sifterConnection == null) {
            loginKeys(null);
            break;
        } // if URL misformatted return to LoginActivity
        mDialog = ProgressDialog.show(this, "", "Loading ...", true);
        new DownloadSifterTask().execute(sifterConnection);
        break;
    }
}

From source file:org.peterbaldwin.client.android.tinyurl.SendTinyUrlActivity.java

private void send() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");

    Intent originalIntent = getIntent();
    if (Intent.ACTION_SEND.equals(originalIntent.getAction())) {
        // Copy extras from the original intent because they might contain
        // additional information about the URL (e.g., the title of a
        // YouTube video). Do this before setting Intent.EXTRA_TEXT to avoid
        // overwriting the TinyURL.
        intent.putExtras(originalIntent.getExtras());
    }/*from w ww.  j  a va  2 s  .  c o  m*/

    intent.putExtra(Intent.EXTRA_TEXT, mTinyUrl);
    try {
        CharSequence template = getText(R.string.title_send);
        String title = String.format(String.valueOf(template), mTinyUrl);
        startActivity(Intent.createChooser(intent, title));
        finish();
    } catch (ActivityNotFoundException e) {
        handleError(e);
    }
}

From source file:com.polyvi.xface.extension.XMessagingExt.java

private void genMsgReceiveBroadcastReceive() {
    if (null == mMsgReceiveBroadcaseReveiver) {
        mMsgReceiveBroadcaseReveiver = new BroadcastReceiver() {
            @Override/*w  w  w . jav a 2s.  c  o  m*/
            public void onReceive(Context context, Intent intent) {
                if (INTENT_ACTION.equals(intent.getAction())) {
                    Bundle bundle = intent.getExtras();
                    if (null != bundle) {
                        // pdus??
                        Object[] pdus = (Object[]) bundle.get("pdus");
                        // 
                        SmsMessage[] msgs = new SmsMessage[pdus.length];
                        for (int i = 0; i < pdus.length; i++) {
                            // ???pdu?,?
                            msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                        }
                        JSONArray receivedMsgs = buildSmsList(msgs);
                        XEvent evt = XEvent.createEvent(XEventType.MSG_RECEIVED, receivedMsgs.toString());
                        XSystemEventCenter.getInstance().sendEventAsync(evt);
                    }
                }
            }
        };
    }
}

From source file:fi.mikuz.boarder.gui.internet.InternetMenu.java

@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    switch (requestCode) {
    case LOGIN_RETURN:
        if (resultCode == RESULT_OK) {
            Bundle extras = intent.getExtras();
            @SuppressWarnings("unchecked")
            HashMap<String, String> returnInfo = (HashMap<String, String>) extras.getSerializable(LOGIN_KEY);
            mLoginInfo = returnInfo;//w  ww  .  j  a v a  2s  .  c  o  m
            sendDonationInfo();

            if (mLoginInfo == null) {
                setLoggedOutView();
            } else {
                setLoggedInView();
            }

            String accountMessage = extras.getString(ACCOUNT_MESSAGE_KEY);
            updateAccountMessage(accountMessage);
        }
        break;
    }
}

From source file:com.photon.phresco.nativeapp.eshop.activity.RegistrationActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    try {// w w  w . java 2s. c  o  m
        if (resultCode == RESULT_OK && requestCode == 1) {
            Intent homeActivity = new Intent(getApplicationContext(), HomeActivity.class);
            homeActivity.putExtra("currentActivity", "home");
            if (data != null) {
                Constants.setUserId(data.getExtras().getInt("userId"));
            } else {
                Constants.setUserId(0);
            }
            startActivity(homeActivity);
            finish();
        }
    } catch (Exception ex) {
        PhrescoLogger.info(TAG + " - backButton  - Exception : " + ex.toString());
        PhrescoLogger.warning(ex);
    }
}