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.hybris.mobile.lib.commerce.sync.CatalogSyncService.java

@Override
public void onCreate() {
    Log.i(TAG, "Service for the CatalogSyncAdapter starting");

    // The sync adapter is created as a singleton
    synchronized (mSingletonLock) {
        if (mSyncAdapter == null) {

            try {
                ComponentName componentName = new ComponentName(this, this.getClass());
                Bundle bundle = getPackageManager().getServiceInfo(componentName,
                        PackageManager.GET_META_DATA).metaData;

                String urlBackend = bundle
                        .getString(getApplicationContext().getString(R.string.sync_url_backend_metadata_name));
                String urlPathCatalogMetadataName = bundle.getString(
                        getApplicationContext().getString(R.string.sync_url_path_catalog_metadata_name));
                String urlPathCatalogIdMetadataName = bundle.getString(
                        getApplicationContext().getString(R.string.sync_url_path_catalog_id_metadata_name));
                String urlPathCatalogVersionIdMetadataName = bundle.getString(getApplicationContext()
                        .getString(R.string.sync_url_path_catalog_version_id_metadata_name));
                String idMainCategory = bundle
                        .getString(getApplicationContext().getString(R.string.sync_id_category_main));

                if (StringUtils.isBlank(urlBackend) || StringUtils.isBlank(urlBackend)
                        || StringUtils.isBlank(urlBackend) || StringUtils.isBlank(idMainCategory)) {
                    throw new IllegalArgumentException("You must provide the metadata "
                            + getApplicationContext().getString(R.string.sync_url_backend_metadata_name) + ", "
                            + getApplicationContext().getString(R.string.sync_url_path_catalog_metadata_name)
                            + ", "
                            + getApplicationContext().getString(R.string.sync_url_path_catalog_id_metadata_name)
                            + ", "
                            + getApplicationContext()
                                    .getString(R.string.sync_url_path_catalog_version_id_metadata_name)
                            + ", " + getApplicationContext().getString(R.string.sync_id_category_main) + " for "
                            + this.getClass());
                }//from w  ww .  j a  va 2s .c  om

                Configuration configuration = new Configuration();
                configuration.setBackendUrl(urlBackend);
                configuration.setCatalog(urlPathCatalogMetadataName);
                configuration.setCatalogId(urlPathCatalogIdMetadataName);
                configuration.setCatalogVersionId(urlPathCatalogVersionIdMetadataName);
                configuration.setCatalogIdMainCategory(idMainCategory);

                // Provider authority
                String provider_authority = getString(R.string.sync_default_authority);

                try {
                    componentName = new ComponentName(this, CatalogProvider.class);

                    // Authority name from the manifest file
                    String tmpAuthority = getPackageManager().getProviderInfo(componentName,
                            PackageManager.GET_META_DATA).authority;

                    if (StringUtils.isNotBlank(tmpAuthority)) {
                        provider_authority = tmpAuthority;
                    }

                } catch (PackageManager.NameNotFoundException e) {
                    Log.e(TAG, "Package name not found. Details:" + e.getLocalizedMessage());
                }

                configuration.setCatalogAuthority(provider_authority);

                // SSL Helper for the ssl factory and hostname verifier
                String sslHelperClassName = bundle
                        .getString(getApplicationContext().getString(R.string.sync_ssl_helper));
                SSLSocketFactory sslSocketFactory = null;
                HostnameVerifier hostnameVerifier = null;

                if (StringUtils.isNotBlank(sslHelperClassName)) {
                    SSLHelper sslHelper = null;
                    String errorMessage = null;
                    try {
                        Class sslFactory = Class.forName(sslHelperClassName);
                        Constructor<SSLHelper> constructor = sslFactory.getConstructor();
                        sslHelper = constructor.newInstance();

                        sslSocketFactory = sslHelper.getSSLSocketFactory();
                        hostnameVerifier = sslHelper.getHostnameVerifier();
                    } catch (ClassNotFoundException e) {
                        errorMessage = e.getLocalizedMessage();
                        Log.e(TAG, "ClassNotFoundException with SSLHelper. Details: " + errorMessage);
                    } catch (InvocationTargetException e) {
                        errorMessage = e.getLocalizedMessage();
                        Log.e(TAG, "InvocationTargetException with SSLHelper. Details: " + errorMessage);
                    } catch (NoSuchMethodException e) {
                        errorMessage = e.getLocalizedMessage();
                        Log.e(TAG, "NoSuchMethodException with SSLHelper. Details: " + errorMessage);
                    } catch (InstantiationException e) {
                        errorMessage = e.getLocalizedMessage();
                        Log.e(TAG, "InstantiationException with SSLHelper. Details: " + errorMessage);
                    } catch (IllegalAccessException e) {
                        errorMessage = e.getLocalizedMessage();
                        Log.e(TAG, "IllegalAccessException with SSLHelper. Details: " + errorMessage);
                    }

                    if (sslHelper == null) {
                        throw new IllegalArgumentException(
                                "Error instantiating SSLHelper. Details: " + errorMessage);
                    }
                }

                // Create the sync adapter
                mSyncAdapter = buildSyncAdapter(configuration, sslSocketFactory, hostnameVerifier);
            } catch (PackageManager.NameNotFoundException e) {
                Log.e(TAG, "Package name not found. Details:" + e.getLocalizedMessage());
                throw new IllegalArgumentException(
                        "Error getting the information from the metadata of " + this.getClass());
            }

        }
    }
}

From source file:com.example.ridemedriver.SignupStepTwoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signup_step_two);
    getActionBar().hide();/*from w  ww.j  a v  a 2  s. c  om*/

    Bundle extras = getIntent().getExtras();
    phone = extras.getString(EXTRA_PHONE);
    password = extras.getString(EXTRA_PHONE);
    name = extras.getString(EXTRA_PHONE);
    alipay = extras.getString(EXTRA_PHONE);

    signup_steptwo_signup = (Button) findViewById(R.id.signup_steptwo_signup);
    signup_steptwo_signup.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            new sign_up().execute();
        }
    });
    signup_steptwo_btn_back = (ImageButton) findViewById(R.id.signup_steptwo_btn_back);
    signup_steptwo_govid_edit = (EditText) findViewById(R.id.signup_steptwo_govid_edit);
    signup_steptwo_stuid_edit = (EditText) findViewById(R.id.signup_steptwo_stuid_edit);
    signup_steptwo_model_edit = (EditText) findViewById(R.id.signup_steptwo_model_edit);
    signup_steptwo_vid_edit = (EditText) findViewById(R.id.signup_steptwo_vid_edit);
    signup_steptwo_avatar_imgview = (ImageView) findViewById(R.id.signup_steptwo_avatar_imgview);
    signup_steptwo_avatar_imgview.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent1 = new Intent(Intent.ACTION_PICK, null);
            intent1.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
            startActivityForResult(intent1, 1);
        }
    });
}

From source file:com.loadsensing.app.Chart.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.chart);/*from  w w  w .j  av  a  2  s .co  m*/
    final WebView googleChartView = (WebView) findViewById(R.id.chart);

    Bundle extras = null;

    if (savedInstanceState == null) {
        extras = getIntent().getExtras();
        if (extras == null) {
            SensorSelected = null;
        } else {
            SensorSelected = extras.getString("idsensorselected");
            Log.d(DEB_TAG, "Xarxa que hem triat anteriorment: " + SensorSelected);
        }
    }

    // Listener para generar el grfico cada vez que se escoge la opcin en
    // el radiobutton
    RadioGroup rg = (RadioGroup) findViewById(R.id.tipochart);
    rg.clearCheck();
    rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            generaChart(googleChartView, checkedId, SensorSelected);
        }
    });

}

From source file:com.sawyer.advadapters.app.adapters.nfjsonadapter.NFJSONAdapterFragment.java

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

    if (savedInstanceState != null) {
        mCheckedCount = savedInstanceState.getInt(STATE_CAB_CHECKED_COUNT);
        try {//  w  w  w  .ja  v a  2  s  . c o m
            JSONArray list = new JSONArray(savedInstanceState.getString(STATE_LIST));
            setListAdapter(new MovieNFJSONArrayAdapter(getActivity(), list));
        } catch (JSONException e) {
            Log.e(NFJSONAdapterFragment.class.getSimpleName(), "OnRestore Error", e);
            mCheckedCount = 0;
            setListAdapter(new MovieNFJSONArrayAdapter(getActivity()));
        }
    } else {
        setListAdapter(new MovieNFJSONArrayAdapter(getActivity()));
    }
}

From source file:net.idlesoft.android.apps.github.activities.Repository.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.repository);

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);
    mEditor = mPrefs.edit();// ww w  .j  av  a  2  s.c o m

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");
    mIsWatching = false;

    mGapi.authenticate(mUsername, mPassword);

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(Repository.this, Search.class));
        }
    });

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepositoryName = extras.getString("repo_name");
        mRepositoryOwner = extras.getString("repo_owner");

        mLoadRepositoryTask = (LoadRepositoryTask) getLastNonConfigurationInstance();
        if (mLoadRepositoryTask == null) {
            mLoadRepositoryTask = new LoadRepositoryTask();
        }
        mLoadRepositoryTask.activity = Repository.this;
        if (mLoadRepositoryTask.getStatus() == AsyncTask.Status.PENDING) {
            mLoadRepositoryTask.execute();
        }
    }
}

From source file:com.vishnuvalleru.travelweatheralertsystem.MainActivity.java

@SuppressLint("NewApi")
@Override/*from   www. j  a  v a 2  s.  c  o  m*/
protected void onCreate(Bundle savedInstanceState) {
    Bundle b = getIntent().getExtras();
    String fromLocation = b.getString("from");
    String toLocation = b.getString("to");
    Geocoder coder = new Geocoder(this);
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    try {
        ArrayList<Address> frmAddresses = (ArrayList<Address>) coder.getFromLocationName(fromLocation, 50);
        ArrayList<Address> toAddresses = (ArrayList<Address>) coder.getFromLocationName(toLocation, 50);
        for (Address add : frmAddresses) {
            src_long = add.getLongitude();
            src_lat = add.getLatitude();
        }
        for (Address add : toAddresses) {
            dest_long = add.getLongitude();
            dest_lat = add.getLatitude();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    LatLng srcLatLng = new LatLng(src_lat, src_long);
    LatLng destLatLng = new LatLng(dest_lat, dest_long);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    FragmentManager myFragmentManager = getFragmentManager();
    MapFragment myMapFragment = (MapFragment) myFragmentManager.findFragmentById(R.id.map);

    myMap = myMapFragment.getMap();
    myMap.setInfoWindowAdapter(new PopupAdapter(getLayoutInflater()));
    myMap.setOnMapClickListener(new OnMapClickListener() {

        @Override
        public void onMapClick(LatLng point) {
            // Drawing marker on the map
            drawMarker(point);
        }
    });

    // Enabling MyLocation in Google Map
    myMap.setMyLocationEnabled(true);
    myMap.getUiSettings().setZoomControlsEnabled(true);
    myMap.getUiSettings().setCompassEnabled(true);
    myMap.getUiSettings().setMyLocationButtonEnabled(true);
    myMap.getUiSettings().setAllGesturesEnabled(true);
    myMap.setTrafficEnabled(true);
    myMap.animateCamera(CameraUpdateFactory.newLatLngZoom(destLatLng, 6));
    markerOptions = new MarkerOptions();

    drawMarker(srcLatLng);
    drawMarker(destLatLng);

    connectAsyncTask _connectAsyncTask = new connectAsyncTask();
    _connectAsyncTask.execute();
}

From source file:com.google.android.apps.gutenberg.provider.SyncAdapter.java

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {/*from   w  w w .  ja  v a  2 s. c o m*/
    String authToken = extras.getString(EXTRA_AUTH_TOKEN);
    if (TextUtils.isEmpty(authToken)) {
        Log.d(TAG, "Not authorized. Cannot sync.");
        return;
    }
    mApiClient.blockingConnect(5, TimeUnit.SECONDS);
    try {
        String cookie = getCookie(authToken);
        syncCheckins(provider, cookie);
        if (!extras.getBoolean(EXTRA_ONLY_CHECKINS, false)) {
            syncEvents(provider, cookie);
        }
    } catch (IOException e) {
        Log.e(TAG, "Error performing sync.", e);
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.internet_download_comments_list);
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    registerForContextMenu(getListView());

    Bundle extras = getIntent().getExtras();
    XStream xstream = new XStream();
    mBoard = (InternetFullBoard) xstream.fromXML(extras.getString(DownloadBoard.BOARD_KEY));
    mLoggedIn = extras.getBoolean(DownloadBoardList.LOGGED_IN_KEY);

    if (mLoggedIn) {
        mUserId = extras.getString(InternetMenu.USER_ID_KEY);
        mSessionToken = extras.getString(InternetMenu.SESSION_TOKEN_KEY);
    }//from   w  ww  .  j av  a2  s  .  com

    this.setTitle(mBoard.getUploaderUsername() + " - " + mBoard.getBoardName());

    mListView = (ListView) findViewById(android.R.id.list);
    mList = new ArrayList<Comment>();
    mMaxResults = 40;
    refreshList();

    Button sendComment = (Button) findViewById(R.id.sendComment);
    final EditText commentInput = (EditText) findViewById(R.id.commentInput);

    if (mLoggedIn) {
        sendComment.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (commentInput.getText().toString().length() > 0) {
                    mWaitDialog = new TimeoutProgressDialog(DownloadBoardComments.this, "Waiting for response",
                            TAG, false);
                    HashMap<String, String> sendList = new HashMap<String, String>();
                    sendList.put(InternetMenu.BOARD_ID_KEY, Integer.toString(mBoard.getBoardId()));
                    sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                    sendList.put(InternetMenu.USER_ID_KEY, mUserId);
                    sendList.put(InternetMenu.COMMENT_KEY, commentInput.getText().toString());
                    commentInput.setText("");
                    new ConnectionManager(DownloadBoardComments.this, InternetMenu.mCommentURL, sendList);
                } else {
                    Toast.makeText(DownloadBoardComments.this, "Type your comment...", Toast.LENGTH_LONG)
                            .show();
                }
            }
        });
    } else {
        commentInput.setHint("Login to comment");
        commentInput.setFocusable(false);
    }

    getListView().setOnScrollListener(this);
}

From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java

private void handleExtra(Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null && extras.size() > 0) {
        for (String k : extras.keySet()) {
            Log.i(TAG, "k = " + k + " : " + extras.getString(k));
        }/*from  w w w.j a  v a 2  s  .com*/
    }
    if (extras != null && "dialog".equals(extras.get("_extra1"))) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
        alertDialogBuilder.setTitle("" + extras.get("_extra2"));
        alertDialogBuilder.setMessage("" + extras.get("_extra3")).setCancelable(false).setPositiveButton("OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        alertDialogBuilder.create().show();
    }
}

From source file:com.openerp.addons.note.AddFollowerFragment.java

public void onStart() {
    super.onStart();
    Bundle bundle = getArguments();
    if (bundle.containsKey("res_id")) {
        record_id = bundle.getInt("res_id");
        message = bundle.getString("message");
    }/*from   w  ww.j  ava  2 s.  c  om*/
    getPartnersFromLocal();
}