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:a14n.geolocationdemo.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    // Reload the Flutter Dart code when the activity receives an intent
    // from the "flutter refresh" command.
    // This feature should only be enabled during development.  Use the
    // debuggable flag as an indicator that we are in development mode.
    if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        if (Intent.ACTION_RUN.equals(intent.getAction())) {
            flutterView.runFromBundle(intent.getDataString(), intent.getStringExtra("snapshot"));
        }/*from   ww w.ja v  a 2 s .c om*/
    }
}

From source file:com.hybris.mobile.activity.OrderDetailActivity.java

private void handleIntent(Intent intent) {

    if (Hybris.isUserLoggedIn()) {
        if (intent.hasExtra("orderDetails")) {
            ((TextView) findViewById(R.id.lbl_thankYou)).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.lbl_orderConfirmation)).setVisibility(View.VISIBLE);
            // TODO
            setmOrderDetails(JsonUtils.fromJson(intent.getStringExtra("orderDetails"), CartOrder.class));
        }//from   ww  w.j  a v  a 2  s  .co  m
        if (intent.hasExtra(DataConstants.ORDER_ID)) {
            setmOrderID(intent.getStringExtra(DataConstants.ORDER_ID));
        }
        // Call from another application (QR Code) 
        else if (StringUtils.equals(intent.getAction(), Intent.ACTION_VIEW)) {
            setmOrderID(RegexUtil.getOrderIdFromHybrisPattern(intent.getDataString()));
        }
    }
    // User not logged in, redirection to the login page
    else {
        Intent loginIntent = new Intent(this, LoginActivity.class);

        // Call from another application (QR Code) 
        if (StringUtils.equals(intent.getAction(), Intent.ACTION_VIEW)) {
            loginIntent.putExtra(DataConstants.ORDER_ID,
                    RegexUtil.getOrderIdFromHybrisPattern(intent.getDataString()));
        }

        loginIntent.putExtra(DataConstants.INTENT_DESTINATION, DataConstants.INTENT_ORDER_DETAILS);
        loginIntent.putExtras(intent);
        startActivity(loginIntent);
    }
}

From source file:com.mobicage.rogerthat.plugins.messaging.AttachmentViewerActivity.java

@Override
protected void onServiceBound() {
    T.UI();//from  ww w  .  ja v a 2s.  c  om

    mProgressDialog = new ProgressDialog(AttachmentViewerActivity.this);
    mProgressDialog.setMessage(mService.getString(R.string.downloading));
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setCancelable(true);

    mMessagingPlugin = mService.getPlugin(MessagingPlugin.class);

    final Intent intent = getIntent();
    mThreadKey = intent.getStringExtra("thread_key");
    mMessageKey = intent.getStringExtra("message");
    mContentType = intent.getStringExtra("content_type");
    mDownloadUrl = intent.getStringExtra("download_url");
    mName = intent.getStringExtra("name");
    mDownloadUrlHash = intent.getStringExtra("download_url_hash");
    mGenerateThumbnail = intent.getBooleanExtra("generate_thumbnail", false);

    if (mContentType.toLowerCase(Locale.US).startsWith("video/")) {
        setContentView(R.layout.file_viewer_video);
        mVideoview = (VideoView) findViewById(R.id.videoView);
    } else {
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        setContentView(R.layout.file_viewer);
        mWebview = (WebView) findViewById(R.id.webview);

        mWebview.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onConsoleMessage(String message, int lineNumber, String sourceID) {
                if (sourceID != null) {
                    try {
                        sourceID = new File(sourceID).getName();
                    } catch (Exception e) {
                        L.d("Could not get fileName of sourceID: " + sourceID, e);
                    }
                }
                L.d(sourceID + ":" + lineNumber + " | " + message);
            }
        });

        mWebview.setWebViewClient(new WebViewClient() {

            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                L.d(failingUrl + ":" + errorCode + " | " + description);
            }
        });

        final TextView titleTextView = (TextView) findViewById(R.id.title);
        if (TextUtils.isEmptyOrWhitespace(mName)) {
            titleTextView.setVisibility(View.GONE);
            findViewById(R.id.divider).setVisibility(View.GONE);
        } else {
            titleTextView.setVisibility(View.VISIBLE);
            titleTextView.setText(mName);
            findViewById(R.id.divider).setVisibility(View.VISIBLE);
        }
    }

    try {
        mAttachmentsDir = mMessagingPlugin.attachmentsDir(mThreadKey, null);
    } catch (IOException e) {
        L.d("Unable to create attachment directory", e);
        UIUtils.showAlertDialog(this, "", R.string.unable_to_read_write_sd_card);
        return;
    }

    mFile = new File(mAttachmentsDir, mDownloadUrlHash);

    if (mMessagingPlugin.attachmentExists(mAttachmentsDir, mDownloadUrlHash)) {
        updateView(false);
    } else {
        try {
            mAttachmentsDir = mMessagingPlugin.attachmentsDir(mThreadKey, mMessageKey);
        } catch (IOException e) {
            L.d("Unable to create attachment directory", e);
            UIUtils.showAlertDialog(this, "", R.string.unable_to_read_write_sd_card);
            return;
        }

        mFile = new File(mAttachmentsDir, mDownloadUrlHash);

        if (mMessagingPlugin.attachmentExists(mAttachmentsDir, mDownloadUrlHash)) {
            updateView(false);
        } else {
            downloadAttachment();
        }
    }
}

From source file:my.madet.uniteninfo.OpenVPN.java

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

    if (requestCode == 1001) {
        String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
        String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");

        Log.d("onActivityResult", "purchaseData: " + purchaseData);
        Log.d("onActivityResult", "dataSignature: " + dataSignature);
        Log.d("onActivityResult", "resultCode: " + resultCode);

        if (purchaseData != null) {

            // save to preference
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putString("purchaseData", purchaseData);
            editor.putString("dataSignature", purchaseData);
            editor.commit();//  ww w  .ja v  a2s. c  o  m
            Log.d("onActivityResult", "New preference purchaseData and dataSignature set");

            Toast.makeText(rootView.getContext(), "Successfully subscribed!", Toast.LENGTH_SHORT).show();

            // inform myvpn service about this new purchase
            // call myvpn API async
            sendResponseDataToMyVPN(purchaseData, dataSignature);

        }
    } else {
        Log.d("onActivityResult", "resultCode: " + resultCode);
    }
}

From source file:me.henrytao.bootstrapandroidlibrarydemo.activity.BaseActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, 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) {
            new AlertDialog.Builder(BaseActivity.this).setMessage(getString(R.string.text_donate_thanks))
                    .setPositiveButton(R.string.text_close, null).show();
        } else {/*from w  w w  .  j  a  v  a 2  s  . co  m*/
            showDonateDialogErrorCallback(null);
        }
    }
}

From source file:com.parse.ParsePushBroadcastReceiver.java

/**
 * Called when the push notification is opened by the user. Sends analytics info back to Parse
 * that the application was opened from this push notification. By default, this will navigate
 * to the {@link Activity} returned by {@link #getActivity(Context, Intent)}. If the push contains
 * a 'uri' parameter, an Intent is fired to view that URI with the Activity returned by
 * {@link #getActivity} in the back stack.
 *
 * @param context/*from w  ww  .  j  a v  a  2 s  .  c om*/
 *      The {@code Context} in which the receiver is running.
 * @param intent
 *      An {@code Intent} containing the channel and data of the current push notification.
 */
protected void onPushOpen(Context context, Intent intent) {
    // Send a Parse Analytics "push opened" event
    ParseAnalytics.trackAppOpenedInBackground(intent);

    String uriString = null;
    try {
        JSONObject pushData = new JSONObject(intent.getStringExtra(KEY_PUSH_DATA));
        uriString = pushData.optString("uri", null);
    } catch (JSONException e) {
        PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e);
    }

    Class<? extends Activity> cls = getActivity(context, intent);
    Intent activityIntent;
    if (uriString != null) {
        activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriString));
    } else {
        activityIntent = new Intent(context, cls);
    }

    activityIntent.putExtras(intent.getExtras());
    /*
      In order to remove dependency on android-support-library-v4
      The reason why we differentiate between versions instead of just using context.startActivity
      for all devices is because in API 11 the recommended conventions for app navigation using
      the back key changed.
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilderHelper.startActivities(context, cls, activityIntent);
    } else {
        activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(activityIntent);
    }
}

From source file:com.google.zxing.client.android.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)
            && !intent.getAction().equals(Intents.SearchBookContents.DEPRECATED_ACTION))) {
        finish();/*from  w ww.j  av a 2 s.c o m*/
        return;
    }

    mISBN = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    setTitle(getString(R.string.sbc_name) + ": ISBN " + mISBN);

    setContentView(R.layout.search_book_contents);
    mQueryTextView = (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
        mQueryTextView.setText(initialQuery);
    }
    mQueryTextView.setOnKeyListener(mKeyListener);

    mQueryButton = (Button) findViewById(R.id.query_button);
    mQueryButton.setOnClickListener(mButtonListener);

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

    mUserAgent = getString(R.string.zxing_user_agent);
}

From source file:it.gmariotti.android.examples.googleaccount.SmsRestoreGDriveActivity.java

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    switch (requestCode) {
    case REQUEST_ACCOUNT_PICKER:

        if (resultCode == RESULT_OK) {
            mAccountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
            prefs.edit().putString(PREF_ACCOUNT_NAME, mAccountName).commit();

            if (mAccountName != null) {
                restoreSmsFromGDrive();//  ww  w  .  j  av a2  s .  c  om
            }

        }
        break;
    case REQUEST_AUTHORIZATION_FOLDER:
        if (resultCode == RESULT_OK) {
            restoreSmsFromGDrive();
        } else {
            startActivityForResult(mCredential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
        }
        break;

    }
}

From source file:com.josephblough.sbt.activities.ShortcutActivity.java

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

    // If criteria has been selected then load the details data
    if (resultCode == RESULT_OK && data != null && data.hasExtra(SEARCH_TYPE)) {
        final int searchType = data.getIntExtra(SEARCH_TYPE, 0);
        final String criteria = data.getStringExtra(CRITERIA);

        createLauncher(searchType, criteria);
    } else {/*w w  w . jav  a2 s  .  co  m*/
        setResult(RESULT_CANCELED, new Intent());
        finish();
    }
}

From source file:com.androidrocks.bex.zxing.client.android.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)
            && !intent.getAction().equals(Intents.SearchBookContents.DEPRECATED_ACTION))) {
        finish();/*ww  w . ja  v a2s  . c o m*/
        return;
    }

    mISBN = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    setTitle(getString(R.string.sbc_name) + ": ISBN " + mISBN);

    setContentView(R.layout.search_book_contents);
    mQueryTextView = (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
        mQueryTextView.setText(initialQuery);
    }
    mQueryTextView.setOnKeyListener(mKeyListener);

    mQueryButton = (Button) findViewById(R.id.query_button);
    mQueryButton.setOnClickListener(mButtonListener);

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