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.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java

@Override
protected void onServiceBound() {
    T.UI();/*w  ww . j  av  a2 s.  c  o m*/

    mFriendsPlugin = mService.getPlugin(FriendsPlugin.class);
    mBroadcastReceiver = getBroadcastReceiver();

    final IntentFilter filter = new IntentFilter(FriendsPlugin.FRIEND_INFO_RECEIVED_INTENT);
    filter.addAction(FriendsPlugin.SERVICE_ACTION_INFO_RECEIVED_INTENT);
    filter.addAction(URL_REDIRECTION_DONE);
    registerReceiver(mBroadcastReceiver, filter);

    Intent intent = getIntent();
    final String url = intent.getStringExtra(URL);
    final String emailHash = intent.getStringExtra(EMAILHASH);

    if (url == null && emailHash == null) {
        L.bug("url == null && emailHash == null");
        finish();
    } else {
        startSpinner(intent.getBooleanExtra(SCAN_RESULT, false));
        if (url != null)
            processUrl(url);
        else
            processEmailHash(emailHash);
    }
}

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

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {

        apiKey = intent.getStringExtra(MvdServiceReceiver.EXTRA_SERVICE_API_KEY);

        feedId = intent.getStringExtra(MvdServiceReceiver.EXTRA_SERVICE_FEED_ID);

        mqtt = new MQTT();

        try {/*w w  w  .ja v a  2  s .  c om*/
            mqtt.setHost(host, port);

            mqtt.setUserName(apiKey);

            connection = mqtt.callbackConnection();

            connection.listener(mqttListener);

            connection.connect(mqttCallback);

        } catch (URISyntaxException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

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

    return START_STICKY;
}

From source file:com.example.AllSOSservice.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), Activity.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/*from   w w  w  .j av a 2  s  .  co m*/

    String message = intent.getStringExtra("message");
    String email = intent.getStringExtra("email");
    String latitude = intent.getStringExtra("latitude");
    String longitude = intent.getStringExtra("longitude");

    Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
    toast.show();

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_launcher).setContentTitle("Novo Pedido de Ajuda!")
            .setContentText("Alguem precisa de um " + message);

    Intent resultIntent = null;
    try {
        if (isLoggedIn()) {
            resultIntent = new Intent(context, LoggedInActivity.class);
        } else {
            resultIntent = new Intent(context, LoginActivity.class);
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (TimeoutException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }

    // Because clicking the notification opens a new ("special") activity, there's
    // no need to create an artificial back stack.
    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    mBuilder.setContentIntent(resultPendingIntent);

    int mNotificationId = 001;
    // Gets an instance of the NotificationManager service
    NotificationManager mNotifyMgr = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    // Builds the notification and issues it.
    mNotifyMgr.notify(mNotificationId, mBuilder.build());
}

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

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("ELEPHANT", "STARTING HTTPSERVICE");
    if (!started) {
        url = intent.getStringExtra(MvdServiceReceiver.EXTRA_SERVICE_URL);

        // Make sure the url ends with a slash
        if (!url.endsWith("/")) {
            url = url + "/";
        }/* w w  w  . jav a2  s .  c  om*/

        delay = intent.getIntExtra(MvdServiceReceiver.EXTRA_SERVICE_DELAY, 5000);

        startGetRequests(delay);

        started = true;

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

    return START_STICKY;
}

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

/** Called with the activity is first created. */
@Override//www . j ava 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");
    visitIdIn = i.getStringExtra("visitId");
    studentIdIn = i.getStringExtra("studentId");

    firstNameIn = i.getStringExtra("fName");
    lastNameIn = i.getStringExtra("lName");
    //classIdIn = i.getStringExtra("mClass");
    //passwordIn = i.getStringExtra("mPass");
    Log.d(TAG, "...getStringExtra:");
    //Log.d(TAG,firstNameIn+lastNameIn);

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

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

    //        Log.d(TAG,"firstNameIn:");
    //        Log.d(TAG,firstNameIn);
    //        Log.d(TAG,"lastNameIn:");
    //        Log.d(TAG,lastNameIn);

    //set info to what we know already
    //lastName.setText(lastNameIn);
    // Log.d(TAG,"...lastName.setText");
    //firstName.setText(firstNameIn);
    // Log.d(TAG,"...firstName.setText");

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

    // 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");

    task.setOnResultsListener(this);
}

From source file:com.cpyf.twelve.spies.qr.code.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  w  w .  ja v  a2 s  .co  m*/
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        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:com.scigames.registration.Registration1UserNameActivity.java

/** Called with the activity is first created. */
@Override// w w  w  .j a  v  a2 s  .co 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");
    passwordIn = i.getStringExtra("pword");

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

    lastName = (EditText) findViewById(R.id.last_name);
    password = (EditText) findViewById(R.id.password);
    password_confirm = (EditText) findViewById(R.id.confirm_password);
    firstName = (EditText) findViewById(R.id.first_name);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    firstName.setCursorVisible(false);
    firstName.setInputType(InputType.TYPE_NULL);
    firstName.setOnTouchListener(new View.OnTouchListener() {
        //@Override
        public boolean onTouch(View v, MotionEvent event) {
            firstName.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
            firstName
                    .setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
            firstName.setCursorVisible(true);
            firstName.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });

    Log.d(TAG, "...instantiateEditTexts");

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

    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");

    setEditTextFont(Museo500Regular, firstName, lastName, password, password_confirm);

    //set info to what we know already
    firstName.setText(firstNameIn);
    lastName.setText(lastNameIn);
    //password.setText(passwordIn);
    Log.d(TAG, "...setTexts with incoming name/pw");

    //set listener
    task.setOnResultsListener(this);

    alertDialog = new AlertDialog.Builder(Registration1UserNameActivity.this).create();
    // Setting Dialog Title
    alertDialog.setTitle("Login Failed");
    // Setting Dialog Message
    alertDialog.setMessage("Welcome to AndroidHive.info");
    // 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(), "", Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java

private void showError(Intent intent) {
    final String errorMessage = intent.getStringExtra(ERROR_MESSAGE);
    if (TextUtils.isEmptyOrWhitespace(errorMessage)) {
        finish();//w  ww. ja  v a 2  s  . c o  m
        showErrorToast();
    } else {
        final String errorCaption = intent.getStringExtra(ERROR_CAPTION);
        final String errorAction = intent.getStringExtra(ERROR_ACTION);
        final String errorTitle = intent.getStringExtra(ERROR_TITLE);

        final AlertDialog.Builder builder = new AlertDialog.Builder(ProcessScanActivity.this);
        builder.setTitle(errorTitle);
        builder.setMessage(errorMessage);
        builder.setNegativeButton(R.string.rogerthat, new AlertDialog.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });

        if (!TextUtils.isEmptyOrWhitespace(errorCaption) && !TextUtils.isEmptyOrWhitespace(errorAction)) {
            builder.setPositiveButton(errorCaption, new AlertDialog.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(errorAction));
                    startActivity(intent);
                    dialog.dismiss();
                    finish();
                }
            });
        }

        builder.show();
    }
}

From source file:cc.softwarefactory.lokki.android.activities.SignUpActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (data == null) {
        Log.e(TAG, "Get default account returned null. Nothing to do.");
        return;//  ww  w .ja v  a2 s .c o  m
    }
    Log.e(TAG, "onActivityResult. Data: " + data.getExtras());
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CODE_EMAIL && resultCode == RESULT_OK) {
        String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
        if (accountName != null) {
            aq.id(R.id.email).text(accountName);
        }
    }
}

From source file:com.parse.CN1ParsePushBroadcastReceiver.java

@Override
protected void onPushReceive(Context context, Intent intent) {
    /*//w  w w.  j  av a2 s .c  om
     Adapted from ParsePushBroadcastReceiver.onPushReceived(). Main changes:
     1. Implemented callbacks to ParsePush with the push payload based on
    app state
     */

    JSONObject pushData = null;
    try {
        pushData = new JSONObject(intent.getStringExtra(ParsePushBroadcastReceiver.KEY_PUSH_DATA));
    } catch (JSONException e) {
        writeErrorLog("Unexpected JSONException when parsing received push data:\n" + e);
    }
    writeDebugLog("Push received: " + (pushData == null ? "<no payload>" : pushData.toString()));

    boolean handled = false;
    if (pushData != null && CN1AndroidApplication.isAppRunning()) {
        if (CN1AndroidApplication.isAppInForeground()) {
            writeDebugLog("App in foreground; will allow app to directly handle push message, if desired");
            handled = ParsePush.handlePushReceivedForeground(pushData.toString());
        } else if (CN1AndroidApplication.isAppInBackground()) {
            writeDebugLog("App in background; will allow app to directly handle push message, if desired");
            handled = ParsePush.handlePushReceivedBackground(pushData.toString());
        }
    }

    if (!handled) {
        // If the push data includes an action string, that broadcast intent is fired.
        String action = null;
        if (pushData != null) {
            action = pushData.optString("action", null);
        }
        if (action != null) {
            writeDebugLog("Firing broadcast for action " + action);
            Bundle extras = intent.getExtras();
            Intent broadcastIntent = new Intent();
            broadcastIntent.putExtras(extras);
            broadcastIntent.setAction(action);
            broadcastIntent.setPackage(context.getPackageName());
            context.sendBroadcast(broadcastIntent);
        }

        Notification notification = getNotification(context, intent);

        if (notification != null) {
            writeDebugLog("Scheduling notification for push message since it was not handled by app");
            ParseNotificationManager.getInstance().showNotification(context, notification);
        } else {
            // If, for any reason, creating the notification fails (typically because
            // the push is a 'hidden' push with no alert/title fields),
            // store it for later processing.
            if (pushData != null) {
                writeDebugLog("Requesting ParsePush to handle unprocessed (hidden?) push message");
                ParsePush.handleUnprocessedPushReceived(pushData.toString());
            }
        }
    } else {
        writeDebugLog("Push already handled by app so not scheduling any notification");
    }
}