Example usage for android.os Bundle getString

List of usage examples for android.os Bundle getString

Introduction

In this page you can find the example usage for android.os Bundle getString.

Prototype

@Nullable
public String getString(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.wso2.mobile.mdm.DisplayDeviceInfoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display_device_info);
    DeviceInfo deviceInfo = new DeviceInfo(DisplayDeviceInfoActivity.this);
    TextView device_id = (TextView) findViewById(R.id.txtId);
    TextView device = (TextView) findViewById(R.id.txtDevice);
    TextView model = (TextView) findViewById(R.id.txtModel);
    TextView operator = (TextView) findViewById(R.id.txtOperator);
    TextView sdk = (TextView) findViewById(R.id.txtSDK);
    TextView os = (TextView) findViewById(R.id.txtOS);
    TextView root = (TextView) findViewById(R.id.txtRoot);

    device_id.setText(getResources().getString(R.string.info_label_imei) + " " + deviceInfo.getDeviceId());
    device.setText(getResources().getString(R.string.info_label_device) + " " + deviceInfo.getDevice());
    model.setText(getResources().getString(R.string.info_label_model) + " " + deviceInfo.getDeviceModel());
    JSONArray jsonArray = null;/*ww  w.  j  a  v a2  s.co m*/
    String operators = "";
    if (deviceInfo.getNetworkOperatorName() != null) {
        jsonArray = deviceInfo.getNetworkOperatorName();
    }

    for (int i = 0; i < jsonArray.length(); i++) {
        try {
            if (jsonArray.getString(i) != null) {
                if (i == (jsonArray.length() - 1)) {
                    operators += jsonArray.getString(i);
                } else {
                    operators += jsonArray.getString(i) + ", ";
                }
            }
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    if (operators.equals(null)) {
        operators = getResources().getString(R.string.info_label_no_sim);
    }
    operator.setText(getResources().getString(R.string.info_label_operator) + " " + operators);
    if (deviceInfo.getIMSINumber() != null) {
        sdk.setText(getResources().getString(R.string.info_label_imsi) + " " + deviceInfo.getIMSINumber());
    } else {
        sdk.setText(getResources().getString(R.string.info_label_imsi) + " " + operators);
    }
    os.setText(getResources().getString(R.string.info_label_os) + " " + deviceInfo.getOsVersion());
    root.setText(getResources().getString(R.string.info_label_rooted) + " "
            + (deviceInfo.isRooted() ? getResources().getString(R.string.info_label_rooted_answer_yes)
                    : getResources().getString(R.string.info_label_rooted_answer_no)));

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        if (extras.containsKey(getResources().getString(R.string.intent_extra_from_activity))) {
            FROM_ACTIVITY = extras.getString(getResources().getString(R.string.intent_extra_from_activity));
        }

        if (extras.containsKey(getResources().getString(R.string.intent_extra_regid))) {
            REG_ID = extras.getString(getResources().getString(R.string.intent_extra_regid));
        }
    }

}

From source file:li.klass.fhem.fragments.SendCommandFragment.java

private void sendCommandIntent(String command) {
    final Context context = getActivity();
    Intent intent = new Intent(Actions.EXECUTE_COMMAND);
    intent.setClass(getActivity(), SendCommandIntentService.class);
    intent.putExtra(BundleExtraKeys.COMMAND, command);
    intent.putExtra(BundleExtraKeys.RESULT_RECEIVER, new ResultReceiver(new Handler()) {
        @Override/*from w  w  w. ja  va2s .co  m*/
        protected void onReceiveResult(int resultCode, Bundle resultData) {
            if (resultData != null && resultCode == ResultCodes.SUCCESS
                    && resultData.containsKey(BundleExtraKeys.COMMAND_RESULT)) {
                String result = resultData.getString(BundleExtraKeys.COMMAND_RESULT);
                if (result == null || result.equals("")) {
                    update(false);
                    return;
                }

                if (isEmpty(result.replaceAll("[\\r\\n]", "")))
                    return;
                new AlertDialog.Builder(context).setTitle(R.string.command_execution_result).setMessage(result)
                        .setPositiveButton(R.string.okButton, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                dialogInterface.cancel();
                                update(false);
                            }
                        }).show();
            }
        }
    });
    getActivity().startService(intent);
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.MainActivity.java

private void restoreInstanceStateOrShowDefault(Bundle savedInstanceState) {
    if (null == savedInstanceState) {
        showSignBrowser();//from w w w. j  a v  a  2 s . c o m
    } else {
        final String toolbarTitle = savedInstanceState.getString(KEY_TOOLBAR_TITLE);
        Validate.notNull(toolbarTitle, "Toolbar title is empty in saved instance state bundle.");
        setActionBarTitle(toolbarTitle);
    }
}

From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticator.java

/**
 * {@inheritDoc}/* w w w. j a va2s  .com*/
 */
@Override
public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) {
    if (options != null && options.containsKey(AccountManager.KEY_PASSWORD)) {
        final String password = options.getString(AccountManager.KEY_PASSWORD);
        final Bundle verified = onlineConfirmPassword(account, password);
        final Bundle result = new Bundle();
        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, verified != null);
        return result;
    }
    // Launch AuthenticatorActivity to confirm credentials
    final Intent intent = getAuthenticator(mContext);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_USERNAME, account.name);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_CONFIRMCREDENTIALS, true);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:org.jboss.aerogear.android.sync.SyncService.java

@Override
public void onCreate() {
    try {/*from   w ww.  ja  v  a  2  s.  co  m*/
        super.onCreate();

        ComponentName myService = new ComponentName(this, this.getClass());
        Bundle data = getPackageManager().getServiceInfo(myService, PackageManager.GET_META_DATA).metaData;

        if (data.getString(SERVER_HOST) == null) {
            throw new IllegalStateException(SERVER_HOST + " may not be null");
        }

        if (data.getString(SERVER_PATH) == null) {
            throw new IllegalStateException(SERVER_PATH + " may not be null");
        }

        if (data.getInt(SERVER_PORT, -1) == -1) {
            throw new IllegalStateException(SERVER_PORT + " may not be null");
        }

        JsonPatchClientSynchronizer synchronizer = new JsonPatchClientSynchronizer();
        ClientInMemoryDataStore<JsonNode, JsonPatchEdit> dataStore = new ClientInMemoryDataStore<JsonNode, JsonPatchEdit>();
        ClientSyncEngine<JsonNode, JsonPatchEdit> clientSyncEngine = new ClientSyncEngine<JsonNode, JsonPatchEdit>(
                synchronizer, dataStore, new DefaultPatchObservable<JsonNode>());

        syncClient = NettySyncClient.<JsonNode, JsonPatchEdit>forHost(data.getString(SERVER_HOST))
                .port(data.getInt(SERVER_PORT)).path(data.getString(SERVER_PATH)).syncEngine(clientSyncEngine)
                .build();

        Log.i(SyncService.class.getName(), "onCreated");
    } catch (PackageManager.NameNotFoundException ex) {
        Log.e(TAG, ex.getMessage(), ex);
        throw new IllegalStateException(ex);
    }
}

From source file:edu.mit.mobile.android.locast.accounts.Authenticator.java

/**
 * {@inheritDoc}//from  w  w  w . j  av a 2  s  .c o  m
 */
@Override
public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) {
    if (options != null && options.containsKey(AccountManager.KEY_PASSWORD)) {
        final String password = options.getString(AccountManager.KEY_PASSWORD);
        final Bundle verified = onlineConfirmPassword(account, password);
        final Bundle result = new Bundle();
        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, verified != null);
        return result;
    }
    // Launch AuthenticatorActivity to confirm credentials
    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.EXTRA_USERNAME, account.name);
    intent.putExtra(AuthenticatorActivity.EXTRA_CONFIRMCREDENTIALS, true);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:edu.rit.csh.androidwebnews.ComposeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    hc.getNewsGroups(); // used for list of newsgroups to look through

    if (extras != null) {
        if (extras.containsKey("SUBJECT")) { // coming from a reply
            subject = extras.getString("SUBJECT");
            body = extras.getString("QUOTED_TEXT");
            parentId = extras.getInt("PARENT");
        }//w  w w .  java 2  s .  c o  m
        // for when a new post is done from a newsgroup
        newsgroup = extras.getString("NEWSGROUP");
    }

    setContentView(R.layout.activity_compose);
    dialog = new InvalidApiKeyDialog(this);

    ArrayList<String> groupNames = new ArrayList<String>();
    listAdapter = new ArrayAdapter<String>(this, R.layout.rowlayout, groupNames);
    spinner = (Spinner) findViewById(R.id.newsgroupSpinner);
    if (parentId <= 0) {// do not display the spinner if it is a reply to a post
        spinner.setAdapter(listAdapter);
        spinner.setSelection(listAdapter.getPosition(newsgroup));
    } else {
        spinner.setVisibility(View.GONE);
    }

    subLine = (EditText) findViewById(R.id.subject_line);
    subLine.setText(subject);

    bodyText = (EditText) findViewById(R.id.post_body);
    bodyText.setText(body);

    setTitle("Compose");
}

From source file:com.jakebasile.android.linkshrink.ShortenUrl.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    reshare = false;//from w  w  w  .  ja  va 2s .c om
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    shorten(prefs, extras.getString(Intent.EXTRA_TEXT));
}

From source file:fr.cph.stock.android.activity.ChartActivity.java

@SuppressLint("SetJavaScriptEnabled")
@Override/*  w w w .  ja v a 2 s . com*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chart_activity);

    Bundle b = getIntent().getExtras();
    portfolio = b.getParcelable("portfolio");
    chartType = ChartType.getEnum(b.getString("chartType"));

    errorView = (TextView) findViewById(R.id.errorMessage);
    actionBar = getActionBar();
    webView = (WebView) findViewById(R.id.webView);
    String data = getData();
    webView.setWebChromeClient(new DebugWebChromeClient());
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    // myWebView.setBackgroundColor(0x00000000);
    // myWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    webView.loadDataWithBaseURL("file:///android_asset/www/", data, "text/html", "UTF-8", null);
    webView.reload();

    // Set context
    EasyTracker.getInstance().setContext(getApplicationContext());
    // Instantiate the Tracker
    tracker = EasyTracker.getTracker();
}