List of usage examples for android.os Bundle putStringArrayList
@Override public void putStringArrayList(@Nullable String key, @Nullable ArrayList<String> value)
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeThreeDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(threeDollars);// www.j ava 2 s . c o m Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(threeDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { // e.printStackTrace(); } catch (JSONException e) { // e.printStackTrace(); } catch (SendIntentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeFourDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(fourDollars);/*from w w w. j ava 2 s .c om*/ Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(fourDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { // e.printStackTrace(); } catch (JSONException e) { // e.printStackTrace(); } catch (SendIntentException e) { // e.printStackTrace(); } } }).start(); }
From source file:com.amaze.filemanager.services.ZipTask.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle b = new Bundle(); zpath = PreferenceManager.getDefaultSharedPreferences(this).getString("zippath", ""); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); String name = intent.getStringExtra("name"); if ((zpath != null && zpath.length() != 0)) { if (zpath.endsWith("/")) name = zpath + new File(name).getName(); else//www .j a va 2 s.c om name = zpath + "/" + new File(name).getName(); } File c = new File(name); if (!c.exists()) { try { c.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } DataPackage intent1 = new DataPackage(); intent1.setName(name); intent1.setTotal(0); intent1.setDone(0); intent1.setId(startId); intent1.setP1(0); intent1.setCompleted(false); hash1.put(startId, intent1); mBuilder = new NotificationCompat.Builder(this); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.putExtra("openprocesses", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.zipping)) .setSmallIcon(R.drawable.ic_doc_compressed); if (foreground) { startForeground(Integer.parseInt("789" + startId), mBuilder.build()); } ArrayList<String> a = intent.getStringArrayListExtra("files"); b.putInt("id", startId); b.putStringArrayList("files", a); b.putString("name", name); hash.put(startId, true); new Doback().execute(b); // If we get killed, after returning from here, restart return START_STICKY; }
From source file:com.filemanager.free.services.ZipTask.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle b = new Bundle(); zpath = PreferenceManager.getDefaultSharedPreferences(this).getString("zippath", ""); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); String name = intent.getStringExtra("name"); if ((zpath != null && zpath.length() != 0)) { if (zpath.endsWith("/")) { name = zpath + new File(name).getName(); } else {// w w w . j a va2 s . com name = zpath + "/" + new File(name).getName(); } } File c = new File(name); if (!c.exists()) { try { c.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } DataPackage intent1 = new DataPackage(); intent1.setName(name); intent1.setTotal(0); intent1.setDone(0); intent1.setId(startId); intent1.setP1(0); intent1.setCompleted(false); hash1.put(startId, intent1); mBuilder = new NotificationCompat.Builder(this); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.putExtra("openprocesses", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.zipping)) .setSmallIcon(R.drawable.ic_doc_compressed); if (foreground) { startForeground(Integer.parseInt("789" + startId), mBuilder.build()); } ArrayList<String> a = intent.getStringArrayListExtra("files"); b.putInt("id", startId); b.putStringArrayList("files", a); b.putString("name", name); hash.put(startId, true); new Doback().execute(b); // If we get killed, after returning from here, restart return START_STICKY; }
From source file:de.sourcestream.movieDB.controller.CastDetails.java
/** * Called to ask the fragment to save its current dynamic state, * so it can later be reconstructed in a new instance of its process is restarted. * * @param outState Bundle in which to place your saved state. *//*from w w w . java2 s .com*/ @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Used to avoid bug where we add item in the back stack // and if we change orientation twice the item from the back stack has null values if (save != null && save.getInt("timeOut") == 1) save = null; if (save != null) { outState.putBundle("save", save); if (addToBackStack) { activity.addCastDetailsBundle(save); addToBackStack = false; } } else { Bundle send = new Bundle(); send.putInt("currentId", currentId); if (request != null && request.getStatus() == AsyncTask.Status.RUNNING) { timeOut = 1; request.cancel(true); } send.putInt("timeOut", timeOut); send.putString("title", title); if (timeOut == 0) { // HomePage send.putInt("homeIconCheck", homeIconCheck); if (homeIconCheck == 0) send.putString("homepage", homeIconUrl); // Gallery icon send.putInt("galleryIconCheck", galleryIconCheck); if (galleryIconCheck == 0) send.putStringArrayList("galleryList", galleryList); // More icon send.putInt("moreIconCheck", moreIconCheck); // Cast details info begins here if (castDetailsInfo != null) { // Name send.putString("name", castDetailsInfo.getName().getText().toString()); // Poster path url if (castDetailsInfo.getProfilePath().getTag() != null) send.putString("profilePathURL", castDetailsInfo.getProfilePath().getTag().toString()); // Birth info send.putString("birthInfo", castDetailsInfo.getBirthInfo().getText().toString()); // Also known as send.putString("alsoKnownAs", castDetailsInfo.getAlsoKnownAs().getText().toString()); // Known list if (castDetailsInfo.getKnownList() != null && castDetailsInfo.getKnownList().size() > 0) send.putParcelableArrayList("knownList", castDetailsInfo.getKnownList()); } // Cast details info ends here // Credits starts here if (castDetailsCredits != null) send.putParcelableArrayList("moviesList", moviesList); // Credits ends here // Overview if (castDetailsBiography != null) send.putString("biography", castDetailsBiography.getBiography().getText().toString()); } outState.putBundle("save", send); save = send; if (addToBackStack) { activity.addCastDetailsBundle(send); addToBackStack = false; } } }
From source file:com.skubit.android.billing.BillingServiceBinder.java
@Override public Bundle getPurchases(int apiVersion, String userId, String packageName, String type, String continuationToken) throws RemoteException { Bundle bundle = new Bundle(); if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(type)) { Log.d(TAG, "Missing required parameter"); bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_DEVELOPER_ERROR); return bundle; }//from www . jav a 2 s .c o m if (apiVersion != 1) { Log.d(TAG, "Unsupported API: " + apiVersion); bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_BILLING_UNAVAILABLE); return bundle; } if (!isValidType(type)) { Log.d(TAG, "Incorrect billing type: " + type); bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_BILLING_UNAVAILABLE); return bundle; } int packValidate = validatePackageIsOwnedByCaller(packageName); if (packValidate != BillingResponseCodes.RESULT_OK) { Log.d(TAG, "Package is not owned by caller"); bundle.putInt("RESPONSE_CODE", packValidate); return bundle; } String account = userId; if (hasAccess(account, packageName)) { Log.d(TAG, "User account not configured"); bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_USER_ACCESS); return bundle; } Utils.changeAccount(mContext, userId); PurchaseRestService service = new PurchaseService(account, mContext).getRestService(); ArrayList<String> ids = new ArrayList<>(); ArrayList<String> data = new ArrayList<>(); ArrayList<String> sigs = new ArrayList<>(); InAppPurchaseDataListDto list = null; try { list = service.getPurchaseDatas(packageName, 500, 0, continuationToken, true, 0); } catch (Exception e) { e.printStackTrace(); } if (list != null) { for (InAppPurchaseDataDto dto : list.getItems()) { ids.add(dto.getId()); data.add(dto.getMessage()); sigs.add(dto.getSignature()); } bundle.putString("INAPP_CONTINUATION_TOKEN", list.getNextLink()); } bundle.putStringArrayList("INAPP_PURCHASE_ITEM_LIST", ids); bundle.putStringArrayList("INAPP_PURCHASE_DATA_LIST", data); bundle.putStringArrayList("INAPP_DATA_SIGNATURE_LIST", sigs); return bundle; }
From source file:de.sourcestream.movieDB.controller.TVDetails.java
/** * Called to ask the fragment to save its current dynamic state, * so it can later be reconstructed in a new instance of its process is restarted. * * @param outState Bundle in which to place your saved state. *///from w w w .j a v a2s. c o m @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Used to avoid bug where we add item in the back stack // and if we change orientation twice the item from the back stack has null values if (save != null && save.getInt("timeOut") == 1) save = null; save = null; if (save != null) { if (tvDetailsCast != null) save.putInt("lastVisitedPerson", tvDetailsCast.getLastVisitedPerson()); outState.putBundle("save", save); if (addToBackStack) { activity.addTvDetailsBundle(save); addToBackStack = false; } } else { Bundle send = new Bundle(); send.putInt("currentId", currentId); if (request != null && request.getStatus() == AsyncTask.Status.RUNNING) { timeOut = 1; request.cancel(true); } send.putInt("timeOut", timeOut); send.putString("title", title); if (timeOut == 0) { // HomePage send.putInt("homeIconCheck", homeIconCheck); if (homeIconCheck == 0) send.putString("homepage", homeIconUrl); // Gallery icon send.putInt("galleryIconCheck", galleryIconCheck); if (galleryIconCheck == 0) send.putStringArrayList("galleryList", galleryList); // More icon send.putInt("moreIconCheck", moreIconCheck); // used to pass the data to the castList view send.putParcelableArrayList("seasonList", seasonList); } // TV details info begins here if (tvDetailsInfo != null) { // Backdrop path send.putInt("backDropCheck", tvDetailsInfo.getBackDropCheck()); if (tvDetailsInfo.getBackDropCheck() == 0 && tvDetailsInfo.getBackDropPath().getTag() != null) send.putString("backDropUrl", tvDetailsInfo.getBackDropPath().getTag().toString()); // Poster path url if (tvDetailsInfo.getPosterPath().getTag() != null) send.putString("posterPathURL", tvDetailsInfo.getPosterPath().getTag().toString()); // Rating send.putFloat("rating", tvDetailsInfo.getRatingBar().getRating()); send.putString("voteCount", tvDetailsInfo.getVoteCount().getText().toString()); // Title send.putString("titleText", tvDetailsInfo.getTitle().getText().toString()); // Status send.putString("status", tvDetailsInfo.getStatusText().getText().toString()); // Type send.putString("typeText", tvDetailsInfo.getTypeText().getText().toString()); // Episode runtime send.putString("episodeRuntime", tvDetailsInfo.getEpisodeRuntime().getText().toString()); // Number of episodes send.putString("numberOfEpisodesText", tvDetailsInfo.getNumberOfEpisodesText().getText().toString()); // Number of seasons send.putString("numberOfSeasonsText", tvDetailsInfo.getNumberOfSeasonsText().getText().toString()); // First air date send.putString("firstAirDateText", tvDetailsInfo.getFirstAirDateText().getText().toString()); // Last air date send.putString("lastAirDateText", tvDetailsInfo.getLastAirDateText().getText().toString()); // Genres send.putString("genres", tvDetailsInfo.getGenres().getText().toString()); // Production countries send.putString("productionCountries", tvDetailsInfo.getCountries().getText().toString()); // Production companies send.putString("productionCompanies", tvDetailsInfo.getCompanies().getText().toString()); // Similar list if (tvDetailsInfo.getSimilarList() != null && tvDetailsInfo.getSimilarList().size() > 0) send.putParcelableArrayList("similarList", tvDetailsInfo.getSimilarList()); } // TV details info ends here // TV details cast starts here if (tvDetailsCast != null) { send.putParcelableArrayList("castList", castList); send.putInt("lastVisitedPerson", tvDetailsCast.getLastVisitedPerson()); } // TV details cast ends here if (tvDetailsOverview != null) send.putString("overview", tvDetailsOverview.getOverview().getText().toString()); outState.putBundle("save", send); save = send; if (addToBackStack) { activity.addTvDetailsBundle(send); addToBackStack = false; } } }
From source file:de.sourcestream.movieDB.controller.MovieDetails.java
/** * Called to ask the fragment to save its current dynamic state, * so it can later be reconstructed in a new instance of its process is restarted. * * @param outState Bundle in which to place your saved state. *///from w ww . j a v a 2s.c o m @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Used to avoid bug where we add item in the back stack // and if we change orientation twice the item from the back stack has null values if (save != null && save.getInt("timeOut") == 1) save = null; if (save != null) { if (movieDetailsCast != null) save.putInt("lastVisitedPerson", movieDetailsCast.getLastVisitedPerson()); outState.putBundle("save", save); if (addToBackStack) { activity.addMovieDetailsBundle(save); addToBackStack = false; } } else { Bundle send = new Bundle(); send.putInt("currentId", currentId); if (request != null && request.getStatus() == AsyncTask.Status.RUNNING) { timeOut = 1; request.cancel(true); } send.putInt("timeOut", timeOut); send.putString("title", title); if (timeOut == 0) { // HomePage send.putInt("homeIconCheck", homeIconCheck); if (homeIconCheck == 0) send.putString("homepage", homeIconUrl); // Gallery icon send.putInt("galleryIconCheck", galleryIconCheck); if (galleryIconCheck == 0) send.putStringArrayList("galleryList", galleryList); // Trailer icon send.putInt("trailerIconCheck", trailerIconCheck); if (trailerIconCheck == 0) send.putStringArrayList("trailerList", trailerList); // More icon send.putInt("moreIconCheck", moreIconCheck); // Movie details info begins here if (movieDetailsInfo != null) { // Backdrop path send.putInt("backDropCheck", movieDetailsInfo.getBackDropCheck()); if (movieDetailsInfo.getBackDropCheck() == 0 && movieDetailsInfo.getBackDropPath().getTag() != null) send.putString("backDropUrl", movieDetailsInfo.getBackDropPath().getTag().toString()); // Poster path url if (movieDetailsInfo.getPosterPath().getTag() != null) send.putString("posterPathURL", movieDetailsInfo.getPosterPath().getTag().toString()); // Rating send.putFloat("rating", movieDetailsInfo.getRatingBar().getRating()); send.putString("voteCount", movieDetailsInfo.getVoteCount().getText().toString()); // Title send.putString("titleText", movieDetailsInfo.getTitleText().getText().toString()); // Release date send.putString("releaseDate", movieDetailsInfo.getReleaseDate().getText().toString()); // Status send.putString("status", movieDetailsInfo.getStatusText().getText().toString()); // Tag line send.putString("tagline", movieDetailsInfo.getTagline().getText().toString()); // RunTime send.putString("runTime", movieDetailsInfo.getRuntime().getText().toString()); // Genres send.putString("genres", movieDetailsInfo.getGenres().getText().toString()); // Production countries send.putString("productionCountries", movieDetailsInfo.getCountries().getText().toString()); // Production companies send.putString("productionCompanies", movieDetailsInfo.getCompanies().getText().toString()); // Similar list if (movieDetailsInfo.getSimilarList() != null && movieDetailsInfo.getSimilarList().size() > 0) send.putParcelableArrayList("similarList", movieDetailsInfo.getSimilarList()); } // Movie details info ends here // Movie details cast starts here if (movieDetailsCast != null) { send.putParcelableArrayList("castList", castList); send.putInt("lastVisitedPerson", movieDetailsCast.getLastVisitedPerson()); } // Movie details cast ends here // Overview if (movieDetailsOverview != null) send.putString("overview", movieDetailsOverview.getOverview().getText().toString()); } outState.putBundle("save", send); save = send; if (addToBackStack) { activity.addMovieDetailsBundle(send); addToBackStack = false; } } }
From source file:me.xiaopan.android.inject.sample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); listView = new ListView(getBaseContext()); setContentView(listView);//from w ww . j av a 2s . c om // SharedPreferences? PreferenceUtils.putBoolean(getBaseContext(), KEY_BOOLEAN, true); PreferenceUtils.putFloat(getBaseContext(), KEY_FLOAT, 10000f); PreferenceUtils.putInt(getBaseContext(), KEY_INT, 2000); PreferenceUtils.putLong(getBaseContext(), KEY_LONG, 50000); PreferenceUtils.putString(getBaseContext(), KEY_STRING, "Preference String"); Set<String> stringSet = new HashSet<String>(); stringSet.add("String Set 1"); stringSet.add("String Set 2"); stringSet.add("String Set 3"); stringSet.add("String Set 4"); PreferenceUtils.putStringSet(getBaseContext(), KEY_STRING_SET, stringSet); MyBean bean2 = new MyBean(); bean2.setEmail("sky@xiaopan.me2"); bean2.setName("?2"); bean2.setSex("2"); PreferenceUtils.putObject(getBaseContext(), KEY_JSON, bean2); PreferenceUtils.putString(getBaseContext(), KEY_ENUM, Sex.WOMAN.name()); // ?? String[] items = new String[] { "", "?", "FragmentDialog", "InjectAdapter", "InjectExpandableListAdapter" }; listView.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, android.R.id.text1, items)); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position <= 2) { Bundle bundle = new Bundle(); bundle.putBoolean(MainActivity.PARAM_BOOLEAN, true); bundle.putBooleanArray(MainActivity.PARAM_BOOLEAN_ARRAY, new boolean[] { true, false, true }); bundle.putByte(MainActivity.PARAM_BYTE, (byte) 110); bundle.putByteArray(MainActivity.PARAM_BYTE_ARRAY, new byte[] { 111, 112, 113 }); bundle.putChar(MainActivity.PARAM_CHAR, 'R'); bundle.putCharArray(MainActivity.PARAM_CHAR_ARRAY, new char[] { 'c', 'h', 'a', 'r' }); bundle.putCharSequence(MainActivity.PARAM_CHAR_SEQUENCE, "CharSequence"); bundle.putCharSequenceArray(MainActivity.PARAM_CHAR_SEQUENCE_ARRAY, new CharSequence[] { "Char", " ", "Sequence" }); bundle.putDouble(MainActivity.PARAM_DOUBLE, 12.00d); bundle.putDoubleArray(MainActivity.PARAM_DOUBLE_ARRAY, new double[] { 12.01d, 12.02d, 12.03d }); bundle.putFloat(MainActivity.PARAM_FLOAT, 13.00f); bundle.putFloatArray(MainActivity.PARAM_FLOAT_ARRAY, new float[] { 13.01f, 13.02f, 13.03f }); bundle.putInt(MainActivity.PARAM_INT, 120); bundle.putIntArray(MainActivity.PARAM_INT_ARRAY, new int[] { 121, 122, 123, }); bundle.putLong(MainActivity.PARAM_LONG, 12345); bundle.putLongArray(MainActivity.PARAM_LONG_ARRAY, new long[] { 12346, 12347, 12348 }); bundle.putShort(MainActivity.PARAM_SHORT, (short) 2); bundle.putShortArray(MainActivity.PARAM_SHORT_ARRAY, new short[] { 3, 4, 5 }); bundle.putString(MainActivity.PARAM_STRING, "String"); bundle.putStringArray(MainActivity.PARAM_STRING_ARRAY, new String[] { "String1", "String2", "String3" }); // ??JSONBundle MyBean bean = new MyBean(); bean.setEmail("sky@xiaopan.me"); bean.setName("?"); bean.setSex(""); bundle.putString(PARAM_STRING_JSON, new Gson().toJson(bean)); bundle.putString(MainActivity.PARAM_STRING_ENUM, Sex.WOMAN.name()); // ArrayList<String> stringList = new ArrayList<String>(); stringList.add("ArrayList String 1"); stringList.add("ArrayList String 2"); stringList.add("ArrayList String 3"); bundle.putStringArrayList(MainActivity.PARAM_STRING_ARRAY_LIST, stringList); switch (position) { case 0: Second.SECOND_CHRONOGRAPH.lap(); Intent intent = new Intent(getBaseContext(), InjectTestActivity.class); intent.putExtras(bundle); startActivity(intent); break; case 1: Second.SECOND_CHRONOGRAPH.lap(); Intent intent2 = new Intent(getBaseContext(), NormalActivity.class); intent2.putExtras(bundle); startActivity(intent2); break; case 2: Second.SECOND_CHRONOGRAPH.lap(); new TestDialogFragment().show(getSupportFragmentManager(), ""); break; } } else { Class<?> targetClass = null; if (position == 3) { targetClass = InjectAdapterActivity.class; } else if (position == 4) { targetClass = InjectExpandableListAdapterActivity.class; } if (targetClass != null) { startActivity(new Intent(getBaseContext(), targetClass)); } } } }); }