List of usage examples for android.os Bundle putString
public void putString(@Nullable String key, @Nullable String value)
From source file:com.android.gallery3d.app.Gallery.java
public void startDefaultPage() { PicasaSource.showSignInReminder(this); Bundle data = new Bundle(); data.putString(AlbumSetPage.KEY_MEDIA_PATH, getDataManager().getTopSetPath(DataManager.INCLUDE_ALL)); getStateManager().startState(AlbumSetPage.class, data); mVersionCheckDialog = PicasaSource.getVersionCheckDialog(this); if (mVersionCheckDialog != null) { mVersionCheckDialog.setOnCancelListener(this); }//from w ww.j a va 2 s.c o m }
From source file:com.burntout.burntout.DemoActivity.java
public void onClick(final View view) { if (view == findViewById(R.id.send)) { new AsyncTask<Void, Void, String>() { @Override// w w w.j a va 2 s. c o m protected String doInBackground(Void... params) { String msg = ""; try { Bundle data = new Bundle(); data.putString("my_message", "Hello World"); //data.putString("my_action", "com.google.android.gcm.demo.app.ECHO_NOW"); String id = Integer.toString(msgId.incrementAndGet()); gcm.send(SENDER_ID + "@gcm.googleapis.com", id, data); msg = "Sent message"; Log.d("regid", regid); Log.d("regid length", Integer.toString(regid.length())); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } return msg; } @Override protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); sendRegistrationIdToBackend(); } }.execute(null, null, null); } else if (view == findViewById(R.id.clear)) { mDisplay.setText(""); } }
From source file:com.gridtelefon.DemoActivity.java
public void onClick(final View view) { if (view == findViewById(R.id.send)) { new AsyncTask<Void, Void, String>() { @Override// ww w . ja v a 2 s . co m protected String doInBackground(Void... params) { String msg = ""; try { Bundle data = new Bundle(); data.putString("my_message", "Hello World"); data.putString("my_action", "com.gridtelefon.ECHO_NOW"); String id = Integer.toString(msgId.incrementAndGet()); gcm.send(SENDER_ID + "@gcm.googleapis.com", id, data); msg = "Sent message"; } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } return msg; } @Override protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } else if (view == findViewById(R.id.clear)) { mDisplay.setText(""); } }
From source file:com.facebook.TestUserManager.java
private synchronized void retrieveTestAccountsForAppIfNeeded() { if (appTestAccounts != null) { return;//from ww w . j ava 2 s . c om } appTestAccounts = new HashMap<String, JSONObject>(); // The data we need is split across two different graph API queries. We construct two // queries, submit them together (the second one depends on the first one), then // cross-reference the results. GraphRequest.setDefaultBatchApplicationId(testApplicationId); Bundle parameters = new Bundle(); parameters.putString("access_token", getAppAccessToken()); GraphRequest requestTestUsers = new GraphRequest(null, "app/accounts/test-users", parameters, null); requestTestUsers.setBatchEntryName("testUsers"); requestTestUsers.setBatchEntryOmitResultOnSuccess(false); Bundle testUserNamesParam = new Bundle(); testUserNamesParam.putString("access_token", getAppAccessToken()); testUserNamesParam.putString("ids", "{result=testUsers:$.data.*.id}"); testUserNamesParam.putString("fields", "name"); GraphRequest requestTestUserNames = new GraphRequest(null, "", testUserNamesParam, null); requestTestUserNames.setBatchEntryDependsOn("testUsers"); List<GraphResponse> responses = GraphRequest.executeBatchAndWait(requestTestUsers, requestTestUserNames); if (responses == null || responses.size() != 2) { throw new FacebookException("Unexpected number of results from TestUsers batch query"); } JSONObject testAccountsResponse = responses.get(0).getJSONObject(); JSONArray testAccounts = testAccountsResponse.optJSONArray("data"); // Response should contain a map of test accounts: { id's => { user } } JSONObject userAccountsMap = responses.get(1).getJSONObject(); populateTestAccounts(testAccounts, userAccountsMap); }
From source file:com.facebook.TestUserManager.java
private JSONObject createTestAccount(List<String> permissions, Mode mode, String uniqueUserTag) { Bundle parameters = new Bundle(); parameters.putString("installed", "true"); parameters.putString("permissions", getPermissionsString(permissions)); parameters.putString("access_token", getAppAccessToken()); // If we're in shared mode, we want to rename this user to encode its permissions, so we can // find it later. If we're in private mode, don't bother renaming it since we're just going // to delete it at the end. if (mode == Mode.SHARED) { parameters.putString("name", String.format("Shared %s Testuser", getSharedTestAccountIdentifier(permissions, uniqueUserTag))); }/*from w w w . ja v a 2 s . c om*/ String graphPath = String.format("%s/accounts/test-users", testApplicationId); GraphRequest createUserRequest = new GraphRequest(null, graphPath, parameters, HttpMethod.POST); GraphResponse response = createUserRequest.executeAndWait(); FacebookRequestError error = response.getError(); JSONObject testAccount = response.getJSONObject(); if (error != null) { return null; } else { assert testAccount != null; // If we are in shared mode, store this new account in the dictionary so we can re-use // it later. if (mode == Mode.SHARED) { // Remember the new name we gave it, since we didn't get it back in the results of // the create request. try { testAccount.put("name", parameters.getString("name")); } catch (JSONException e) { Log.e(LOG_TAG, "Could not set name", e); } storeTestAccount(testAccount); } return testAccount; } }
From source file:com.brodev.socialapp.view.MarketPlaceDetail.java
/** Called when the activity is first created. */ @Override//from w ww.j a v a 2 s. c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.market_place_content_view); getSupportActionBar().setDisplayHomeAsUpEnabled(true); Bundle bundle = getIntent().getExtras(); marketPlace = (MarketPlace) bundle.get("marketplace"); phraseManager = new PhraseManager(getApplicationContext()); user = (User) getApplicationContext(); colorView = new ColorView(getApplicationContext()); this.imageGetter = new ImageGetter(getApplicationContext()); if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } if (marketPlace.getTime_stamp().equals("0")) { this.getMarketPlaceAdapter(); } getSupportActionBar().setTitle(phraseManager.getPhrase(getApplicationContext(), "marketplace.marketplace")); initView(); // get comment fragment Bundle comment = new Bundle(); comment.putString("type", "marketplace"); comment.putInt("itemId", marketPlace.getListing_id()); comment.putInt("totalComment", marketPlace.getTotal_comment()); comment.putInt("total_like", marketPlace.getTotal_like()); comment.putBoolean("no_share", false); comment.putBoolean("is_liked", marketPlace.getIs_liked()); comment.putBoolean("can_post_comment", marketPlace.getCan_post_comment()); CommentFragment commentFragment = new CommentFragment(); commentFragment.setArguments(comment); getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit(); }
From source file:com.bellman.bible.android.control.link.LinkControl.java
private void showAllOccurrences(String ref, SearchBibleSection biblesection, String refPrefix) { Book currentBible = getCurrentPageManager().getCurrentBible().getCurrentDocument(); Book strongsBible = null;/*from w ww .j a v a 2 s .com*/ // if current bible has no Strongs refs then try to find one that has if (currentBible.hasFeature(FeatureType.STRONGS_NUMBERS)) { strongsBible = currentBible; } else { strongsBible = SwordDocumentFacade.getInstance().getDefaultBibleWithStrongs(); } // possibly no Strong's bible or it has not been indexed boolean needToDownloadIndex = false; if (strongsBible == null) { Dialogs.getInstance().showErrorMsg(R.string.no_indexed_bible_with_strongs_ref); return; } else if (currentBible.equals(strongsBible) && !checkStrongs(currentBible)) { Log.d(TAG, "Index status is NOT DONE"); needToDownloadIndex = true; } // The below uses ANY_WORDS because that does not add anything to the search string //String noLeadingZeroRef = StringUtils.stripStart(ref, "0"); String searchText = ControlFactory.getInstance().getSearchControl() .decorateSearchString("strong:" + refPrefix + ref, SearchType.ANY_WORDS, biblesection, null); Log.d(TAG, "Search text:" + searchText); Activity activity = CurrentActivityHolder.getInstance().getCurrentActivity(); Bundle searchParams = new Bundle(); searchParams.putString(SearchControl.SEARCH_TEXT, searchText); searchParams.putString(SearchControl.SEARCH_DOCUMENT, strongsBible.getInitials()); searchParams.putString(SearchControl.TARGET_DOCUMENT, currentBible.getInitials()); Intent intent = null; if (needToDownloadIndex) { intent = new Intent(activity, SearchIndex.class); } else { //If an indexed Strong's module is in place then do the search - the normal situation intent = new Intent(activity, SearchResults.class); } intent.putExtras(searchParams); activity.startActivity(intent); return; }
From source file:com.geozen.demo.foursquare.jiramot.Util.java
/** * Connect to an HTTP URL and return the response as a string. * /*from w w w .ja va 2 s . co m*/ * 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 * @throws MalformedURLException * - if the URL format is invalid * @throws IOException * - if a network problem occurs */ 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("Foursquare-Util", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " GeoZen"); 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:de.sourcestream.movieDB.controller.GenresList.java
/** * Callback method to be invoked when an item in this AdapterView has been clicked. * * @param parent The AdapterView where the click happened. * @param view The view within the AdapterView that was clicked (this will be a view provided by the adapter) * @param position The position of the view in the adapter. * @param id The row id of the item that was clicked. *///from w w w .j a v a 2s . c o m @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (movieList.getCurrentList().equals("genre/" + genresList.get(position).getId() + "/movies")) movieList.setBackState(1); else { movieList.setCurrentList("genre/" + genresList.get(position).getId() + "/movies"); movieList.setBackState(0); } movieList.setTitle(genresList.get(position).getName()); FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); Bundle args = new Bundle(); args.putString("currentList", "genresList"); movieList.setArguments(args); transaction.replace(R.id.frame_container, movieList); // add the current transaction to the back stack: transaction.addToBackStack("genresList"); transaction.commit(); backState = 1; }
From source file:com.abel.ooti.boss.DemoActivity.java
public void onClick(final View view) { if (view == findViewById(R.id.send)) { new AsyncTask<Void, Void, String>() { @Override// w w w. ja v a 2 s . co m protected String doInBackground(Void... params) { String msg = ""; try { Bundle data = new Bundle(); data.putString("my_message", "Hello World"); data.putString("my_action", "com.abel.ooti.gcm.ECHO_NOW"); String id = Integer.toString(msgId.incrementAndGet()); gcm.send(SENDER_ID + "@gcm.googleapis.com", id, data); msg = "Sent message"; } catch (IOException ex) { msg = "Error :" + ex.getMessage(); } return msg; } @Override protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } else if (view == findViewById(R.id.clear)) { mDisplay.setText(""); } }