List of usage examples for android.os Bundle getString
@Nullable
public String getString(@Nullable String key)
From source file:net.idlesoft.android.apps.github.activities.SingleActivityItem.java
@Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.single_activity_item); mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0); mEditor = mPrefs.edit();//from w w w.ja v a 2 s . c o m ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { startActivity(new Intent(SingleActivityItem.this, Search.class)); } }); final Bundle extras = getIntent().getExtras(); if (extras != null) { try { mJson = new JSONObject(extras.getString("item_json")); loadActivityItemBox(); final WebView content = (WebView) findViewById(R.id.wv_single_activity_item_content); content.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(final WebView view, final String url) { if (url.startsWith("hubroid://")) { final String parts[] = url.substring(10).split("/"); if (parts[0].equals("showCommit")) { final Intent intent = new Intent(SingleActivityItem.this, Commit.class); intent.putExtra("repo_owner", parts[1]); intent.putExtra("repo_name", parts[2]); intent.putExtra("commit_sha", parts[3]); startActivity(intent); } else if (parts[0].equals("showRepo")) { final Intent intent = new Intent(SingleActivityItem.this, Repository.class); intent.putExtra("repo_owner", parts[1]); intent.putExtra("repo_name", parts[2]); startActivity(intent); } else if (parts[0].equals("showUser")) { final Intent intent = new Intent(SingleActivityItem.this, Profile.class); intent.putExtra("username", parts[1]); startActivity(intent); } else if (parts[0].equals("showIssues")) { final Intent intent = new Intent(SingleActivityItem.this, Issues.class); intent.putExtra("repo_owner", parts[1]); intent.putExtra("repo_name", parts[2]); startActivity(intent); } return true; } return false; } }); String html = ""; final String eventType = mJson.getString("type"); if (eventType.equals("PushEvent")) { html = NewsFeedHelpers.linkifyPushItem(mJson); } else if (eventType.equals("CreateEvent")) { final String object = mJson.getJSONObject("payload").getString("object"); if (object.equals("branch")) { html = NewsFeedHelpers.linkifyCreateBranchItem(mJson); } else if (object.equals("repository")) { html = NewsFeedHelpers.linkifyCreateRepoItem(mJson); } } else if (eventType.equals("CommitCommentEvent")) { html = NewsFeedHelpers.linkifyCommitCommentItem(mJson); } else if (eventType.equals("FollowEvent")) { html = NewsFeedHelpers.linkifyFollowItem(mJson); } else if (eventType.equals("ForkEvent")) { html = NewsFeedHelpers.linkifyForkItem(mJson); } else if (eventType.equals("IssuesEvent")) { html = NewsFeedHelpers.linkifyIssueItem(mJson); } else if (eventType.equals("WatchEvent")) { html = NewsFeedHelpers.linkifyWatchItem(mJson); } final String out = CSS + html; content.loadData(out, "text/html", "UTF-8"); } catch (final JSONException e) { e.printStackTrace(); } } }
From source file:com.marcosedo.lagramola.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //INICIALIZAMOS PROPIEDADES devid = Settings.Secure.getString(getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID); preferences = getSharedPreferences(Constantes.SP_FILE, MODE_PRIVATE); setContentView(R.layout.activity_main); configureToolbarAndTabLayout();//ww w. j ava 2 s .com registerDevice(); Bundle extras = getIntent().getExtras(); if (extras != null) { String msg = extras.getString("msg"); String idevent = extras.getString("idevento"); String titulo = extras.getString("titulo"); if (idevent != null) {//if the message has an event id then if ((msg != null) && (titulo != null)) {//show Dialog with a message showDialogMsgArrived(titulo, msg); } openViewDetail(idevent); } } }
From source file:com.ntsync.android.sync.client.NetworkUtilities.java
/** * /*from w w w . j av a2 s .c o m*/ * @param acm * @param account * * * @param Activity * if null show a notification when Login is needed otherwise * show the Login-Activity in the context of the provided * Activity. * * @return SessionId * @throws OperationCanceledException * @throws ServerException * @throws NetworkErrorException */ @SuppressWarnings("deprecation") public static String blockingGetAuthToken(AccountManager acm, Account account, Activity activity) throws OperationCanceledException, ServerException, NetworkErrorException { String authToken = null; try { Bundle result; if (activity == null) { // New is available from API 14 -> use deprecated API result = acm.getAuthToken(account, Constants.AUTHTOKEN_TYPE, true, null, null).getResult(); } else { result = acm.getAuthToken(account, Constants.AUTHTOKEN_TYPE, null, activity, null, null) .getResult(); } if (result != null) { if (result.containsKey(AccountManager.KEY_AUTHTOKEN)) { authToken = result.getString(AccountManager.KEY_AUTHTOKEN); } if (result.containsKey(AccountManager.KEY_ERROR_CODE)) { int errorCode = result.getInt(AccountManager.KEY_ERROR_CODE, -1); String msg = result.getString(AccountManager.KEY_ERROR_MESSAGE); if (errorCode == Constants.AUTH_ERRORCODE_SERVEREXCEPTION) { throw new ServerException(msg); } else { LogHelper.logE(TAG, "Authentification failed with unknown errorCode:" + errorCode + " Message:" + msg, null); } } } } catch (AuthenticatorException e) { LogHelper.logE(TAG, "Authentification failed.", e); // Should not happen -> report error ErrorHandler.reportException(e); } catch (IOException ex) { throw new NetworkErrorException(ex); } return authToken; }
From source file:com.eleybourn.bookcatalogue.goodreads.api.ListReviewsApiHandler.java
void date2Sql(Bundle b, String key) { if (b.containsKey(key)) { String date = b.getString(key); try {//from w ww . ja v a 2 s.c o m Date d = mUpdateDateFmt.parse(date); date = Utils.toSqlDateTime(d); b.putString(key, date); } catch (Exception e) { b.remove(key); } } }
From source file:com.example.gps_project.Places.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); location = new JSONObject(); setContentView(R.layout.places_list); Bundle extras = getIntent().getExtras(); double a, b;/* w w w .j a va 2 s.c om*/ //get the bundle LATITUDE = extras.getDouble("Latitude"); LONGITUDE = extras.getDouble("Longitude"); params.putString("Start", extras.getString("Start")); params.putString("End", extras.getString("End")); session = Session.openActiveSessionWithAccessToken(Places.this, AccessToken.createFromExistingAccessToken(extras.getString("accesstoken"), null, null, null, null), new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { // TODO Auto-generated method stub } }); fetchPlaces(); }
From source file:net.idlesoft.android.apps.github.activities.Commit.java
@Override protected void onRestoreInstanceState(final Bundle savedInstanceState) { try {/*from w w w . ja v a 2 s . c o m*/ if (savedInstanceState.containsKey("json")) { mJson = new JSONObject(savedInstanceState.getString("json")); } if (mJson != null) { buildUi(); } } catch (final JSONException e) { e.printStackTrace(); } super.onRestoreInstanceState(savedInstanceState); }
From source file:com.facebook.Util.java
/** * Connect to an HTTP URL and return the response as a string. * * Note that the HTTP method override is used on non-GET requests. (i.e. * requests are made as "POST" with method specified in the body). * * @param url - the resource to open: must be a welformed URL * @param method - the HTTP method to use ("GET", "POST", etc.) * @param params - the query parameter for the URL (e.g. access_token=foo) * @return the URL contents as a String//w w w .j a va 2 s . c o m * @throws MalformedURLException - if the URL format is invalid * @throws IOException - if a network problem occurs */ @SuppressWarnings("deprecation") public static String openUrl(String url, String method, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os; if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Log.d("Facebook-Util", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK"); if (!method.equals("GET")) { Bundle dataparams = new Bundle(); for (String key : params.keySet()) { if (params.getByteArray(key) != null) { dataparams.putByteArray(key, params.getByteArray(key)); } } // use method override if (!params.containsKey("method")) { params.putString("method", method); } if (params.containsKey("access_token")) { String decoded_token = URLDecoder.decode(params.getString("access_token")); params.putString("access_token", decoded_token); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = read(conn.getErrorStream()); } return response; }
From source file:com.nextgis.maplibui.formcontrol.Coordinates.java
@Override public void init(JSONObject element, List<Field> fields, Bundle savedState, Cursor featureCursor, SharedPreferences preferences) throws JSONException { JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY); mFieldName = attributes.getString(JSON_FIELD_NAME_KEY); mHidden = attributes.optBoolean(JSON_HIDDEN_KEY); // TODO crs, format String value;/*from ww w . j a va2 s .c o m*/ if (ControlHelper.hasKey(savedState, mFieldName)) value = savedState.getString(ControlHelper.getSavedStateKey(mFieldName)); else value = getFormattedValue(); setText(value); setSingleLine(true); setEnabled(false); }
From source file:com.khoahuy.phototag.HomeActivity.java
@Override protected void onResume() { super.onResume(); try {//from w ww . j a v a 2 s .c o m loadContent(); Intent callerIntent = getIntent(); if (callerIntent != null && Intent.EXTRA_UID.equals(callerIntent.getAction())) { Bundle packageFromCaller = callerIntent.getBundleExtra("MyPackage"); if (packageFromCaller != null) { nfcid = packageFromCaller.getString("nfcid"); // processNfcID(); setIntent(callerIntent); dispatchTakePictureIntent(ACTION_TAKE_PHOTO_B); } } } catch (Exception e) { e.printStackTrace(); } }