List of usage examples for android.os Bundle putStringArrayList
@Override public void putStringArrayList(@Nullable String key, @Nullable ArrayList<String> value)
From source file:com.gamethrive.TrackGooglePurchase.java
private void sendPurchases(final ArrayList<String> skusToAdd, final ArrayList<String> newPurchaseTokens) { try {/*from www . ja v a2 s . com*/ if (getSkuDetailsMethod == null) getSkuDetailsMethod = IInAppBillingServiceClass.getMethod("getSkuDetails", int.class, String.class, String.class, Bundle.class); Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skusToAdd); Bundle skuDetails = (Bundle) getSkuDetailsMethod.invoke(mIInAppBillingService, 3, appContext.getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); Map<String, JSONObject> currentSkus = new HashMap<String, JSONObject>(); JSONObject jsonItem; for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); BigDecimal price = new BigDecimal(object.getString("price_amount_micros")); price = price.divide(new BigDecimal(1000000)); jsonItem = new JSONObject(); jsonItem.put("sku", sku); jsonItem.put("iso", object.getString("price_currency_code")); jsonItem.put("amount", price.toString()); currentSkus.put(sku, jsonItem); } JSONArray purchasesToReport = new JSONArray(); for (String sku : skusToAdd) { if (!currentSkus.containsKey(sku)) continue; purchasesToReport.put(currentSkus.get(sku)); } // New purchases to report. // Wait until we have a playerID then send purchases to server. If successful then mark them as tracked. if (purchasesToReport.length() > 0) { final JSONArray finalPurchasesToReport = purchasesToReport; gameThrive.idsAvailable(new IdsAvailableHandler() { public void idsAvailable(String playerId, String registrationId) { gameThrive.sendPurchases(finalPurchasesToReport, newAsExisting, new JsonHttpResponseHandler() { public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { Log.i(GameThrive.TAG, "JSON sendPurchases Failed"); throwable.printStackTrace(); isWaitingForPurchasesRequest = false; } public void onSuccess(int statusCode, Header[] headers, JSONObject response) { purchaseTokens.addAll(newPurchaseTokens); prefsEditor.putString("purchaseTokens", purchaseTokens.toString()); prefsEditor.remove("ExistingPurchases"); prefsEditor.commit(); newAsExisting = false; isWaitingForPurchasesRequest = false; } }); } }); } } } catch (Throwable t) { t.printStackTrace(); } }
From source file:com.kyleszombathy.sms_scheduler.MessageAlarmReceiver.java
/** Method to set a new alarm * @param context The app context//from w ww.java 2 s .com * @param timeToSend The Time to send the message (in Calendar format) * @param phoneNumberList String Arraylist of phone numbers * @param messageContent The content of the message you want to send * @param alarmNumber Provide an identifier for the alarm * @param nameList The list of names, corresponding with the phone numbers*/ public void createAlarm(Context context, Calendar timeToSend, ArrayList<String> phoneNumberList, String messageContent, int alarmNumber, ArrayList<String> nameList) { this.context = context; // Creates new alarm alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intentAlarm = new Intent(context, MessageAlarmReceiver.class); // Add extras Bundle extras = new Bundle(); extras.putStringArrayList("pNum", phoneNumberList); extras.putString("message", messageContent); extras.putInt("alarmNumber", alarmNumber); extras.putStringArrayList("nameList", nameList); intentAlarm.putExtras(extras); // Set alarm pendingIntent = PendingIntent.getBroadcast(context, alarmNumber, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT); alarm.set(AlarmManager.RTC_WAKEUP, timeToSend.getTimeInMillis(), pendingIntent); // Enable {@code MessageBootReceiver} to automatically restart the alarm when the // device is rebooted. ComponentName receiver = new ComponentName(context, MessageBootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); Log.i(TAG, "createAlarm: Alarm Created. alarmNumber: " + alarmNumber); }
From source file:com.zd.vpn.fragments.AboutFragment.java
private void initGMSDonateOptions() { try {// ww w . j a va 2 s.co m int billingSupported = mService.isBillingSupported(3, getActivity().getPackageName(), INAPPITEM_TYPE_INAPP); if (billingSupported != BILLING_RESPONSE_RESULT_OK) { Log.i("OpenVPN", "Play store billing not supported"); return; } ArrayList skuList = new ArrayList(); Collections.addAll(skuList, donationSkus); Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); Bundle ownedItems = mService.getPurchases(3, getActivity().getPackageName(), INAPPITEM_TYPE_INAPP, null); if (ownedItems.getInt(RESPONSE_CODE) != BILLING_RESPONSE_RESULT_OK) return; final ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); Bundle skuDetails = mService.getSkuDetails(3, getActivity().getPackageName(), INAPPITEM_TYPE_INAPP, querySkus); if (skuDetails.getInt(RESPONSE_CODE) != BILLING_RESPONSE_RESULT_OK) return; final ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { createPlayBuyOptions(ownedSkus, responseList); } }); } } catch (RemoteException e) { VpnStatus.logException(e); } }
From source file:com.secbro.qark.exportedcomponent.exportedactivity.IntentSenderActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_exploit_exported_result); mResultText = (TextView) findViewById(R.id.activity_exploit_exported_result_text); intentKeys = new ArrayList<String>(); if (getIntent() != null) { exportedActivityId = getIntent().getStringExtra(ExportedActivityListFragment.EXPORTED_ACTIVITY_ID); exportedActivityName = getIntent().getStringExtra(ExportedActivityListFragment.EXPORTED_ACTIVITY_NAME); if (getResources().getIdentifier(exportedActivityId, "array", this.getPackageName()) != 0) { intentKeys.addAll(Arrays.asList(getResources().getStringArray( getResources().getIdentifier(exportedActivityId, "array", this.getPackageName())))); }/* ww w . j a v a 2 s. c o m*/ } if (!intentKeys.isEmpty()) { //If the exported activity needs intent params to be passed, then pass in the params from UI. Bundle keys = new Bundle(); keys.putString(ExportedActivityListFragment.EXPORTED_ACTIVITY_NAME, exportedActivityName); keys.putString(ExportedActivityListFragment.EXPORTED_ACTIVITY_ID, exportedActivityId); keys.putStringArrayList(INTENT_KEYS, intentKeys); IntentParamsFragment exploitExportedActivityParamsFragment = new IntentParamsFragment(); exploitExportedActivityParamsFragment.setArguments(keys); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, exploitExportedActivityParamsFragment).commit(); } } else { Log.d("INFO", "Exported activity needs no params"); //Start activity Intent intent = new Intent(); intent.setComponent( new ComponentName(getResources().getString(R.string.packageName), exportedActivityName)); startActivityForResult(intent, REQUEST_CODE); } }
From source file:com.google.cloud.android.speech.MainActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mAdapter != null) { outState.putStringArrayList(STATE_RESULTS, mAdapter.getResults()); }/*from w w w . ja va 2 s. co m*/ }
From source file:io.imoji.sdk.editor.fragment.TagImojiFragment.java
@Override public void onSaveInstanceState(Bundle outState) { outState.putStringArrayList(TAGS_BUNDLE_ARG_KEY, getTags()); outState.putBoolean(IS_PROCESSING_BUNDLE_ARG_KEY, mIsProcessing); super.onSaveInstanceState(outState); }
From source file:com.kyleszombathy.sms_scheduler.MessageAlarmReceiver.java
/** Posts a notification indicating recipients * @param context Application Context//from ww w .j a v a 2 s . c om * @param notificationMessage * @param messageContent Message content to show * @param sendSuccessful Was the message sent succesfully*/ private void sendNotification(Context context, String notificationMessage, String messageContent, boolean sendSuccessful, ArrayList<String> recipients) { mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Check if notification access is granted if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (mNotificationManager.isNotificationPolicyAccessGranted()) { // Bundle Extras Bundle bundle = new Bundle(); bundle.putStringArrayList("recipients", recipients); bundle.putBoolean("sendSuccessful", sendSuccessful); // Create base notification PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, Home.class), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_done_black_24dp).setAutoCancel(true).setExtras(bundle); /* // If notification isn't present if (notification == null) { // Construct notification mBuilder.setStyle(new NotificationCompat.BigTextStyle() .bigText(notificationMessage + ": " + messageContent)); if (sendSuccessful) { postSimpleNotification(); mBuilder.setContentTitle(context.getString(R.string.message_success)); mBuilder.setContentText(notificationMessage); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } else { // If !sendSuccessful mBuilder.setContentTitle(context.getString(R.string.message_failure)); mBuilder.setContentText(notificationMessage); } } else { // If notification is present }*/ } } }
From source file:com.vuze.android.remote.dialog.DialogFragmentMoveData.java
@SuppressWarnings("rawtypes") public static void openMoveDataDialog(Map mapTorrent, SessionInfo sessionInfo, FragmentManager fm) { DialogFragmentMoveData dlg = new DialogFragmentMoveData(); Bundle bundle = new Bundle(); if (mapTorrent == null) { return;/* w w w . j a v a 2s . c om*/ } bundle.putLong("id", MapUtils.getMapLong(mapTorrent, "id", -1)); bundle.putString("name", "" + mapTorrent.get("name")); bundle.putString(SessionInfoManager.BUNDLE_KEY, sessionInfo.getRemoteProfile().getID()); SessionSettings sessionSettings = sessionInfo.getSessionSettings(); String defaultDownloadDir = sessionSettings == null ? null : sessionSettings.getDownloadDir(); String downloadDir = TorrentUtils.getSaveLocation(sessionInfo, mapTorrent); if (downloadDir == null) { downloadDir = defaultDownloadDir; } bundle.putString("downloadDir", downloadDir); ArrayList<String> history = new ArrayList<>(); if (defaultDownloadDir != null) { history.add(defaultDownloadDir); } List<String> saveHistory = sessionInfo.getRemoteProfile().getSavePathHistory(); for (String s : saveHistory) { if (!history.contains(s)) { history.add(s); } } bundle.putStringArrayList("history", history); dlg.setArguments(bundle); AndroidUtils.showDialog(dlg, fm, "MoveDataDialog"); }
From source file:com.onesignal.TrackGooglePurchase.java
private void sendPurchases(final ArrayList<String> skusToAdd, final ArrayList<String> newPurchaseTokens) { try {/*ww w . j ava2 s .c om*/ if (getSkuDetailsMethod == null) { getSkuDetailsMethod = getGetSkuDetailsMethod(IInAppBillingServiceClass); getSkuDetailsMethod.setAccessible(true); } Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skusToAdd); Bundle skuDetails = (Bundle) getSkuDetailsMethod.invoke(mIInAppBillingService, 3, appContext.getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); Map<String, JSONObject> currentSkus = new HashMap<String, JSONObject>(); JSONObject jsonItem; for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); BigDecimal price = new BigDecimal(object.getString("price_amount_micros")); price = price.divide(new BigDecimal(1000000)); jsonItem = new JSONObject(); jsonItem.put("sku", sku); jsonItem.put("iso", object.getString("price_currency_code")); jsonItem.put("amount", price.toString()); currentSkus.put(sku, jsonItem); } JSONArray purchasesToReport = new JSONArray(); for (String sku : skusToAdd) { if (!currentSkus.containsKey(sku)) continue; purchasesToReport.put(currentSkus.get(sku)); } // New purchases to report. // Wait until we have a userID then send purchases to server. If successful then mark them as tracked. if (purchasesToReport.length() > 0) { final JSONArray finalPurchasesToReport = purchasesToReport; OneSignal.idsAvailable(new IdsAvailableHandler() { public void idsAvailable(String userId, String registrationId) { OneSignal.sendPurchases(finalPurchasesToReport, newAsExisting, new OneSignalRestClient.ResponseHandler() { public void onFailure(int statusCode, JSONObject response, Throwable throwable) { OneSignal.Log(OneSignal.LOG_LEVEL.WARN, "HTTP sendPurchases failed to send.", throwable); isWaitingForPurchasesRequest = false; } public void onSuccess(String response) { purchaseTokens.addAll(newPurchaseTokens); prefsEditor.putString("purchaseTokens", purchaseTokens.toString()); prefsEditor.remove("ExistingPurchases"); prefsEditor.commit(); newAsExisting = false; isWaitingForPurchasesRequest = false; } }); } }); } } } catch (Throwable t) { OneSignal.Log(OneSignal.LOG_LEVEL.WARN, "Failed to track IAP purchases", t); } }
From source file:com.nokia.example.paymentoneapk.PaymentOneAPKActivity.java
private void queryProductDetails() { Log.d(TAG, "PaymentOneAPKActivity.queryProductDetails"); final Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", productSkus); new Thread(new Runnable() { @SuppressWarnings("CollectionDeclaredAsConcreteClass") @Override/* w w w . j a v a 2s . c o m*/ public void run() { final Bundle skuDetails; try { skuDetails = mService.getSkuDetails(API_VERSION, getPackageName(), "inapp", querySkus); } catch (final RemoteException e) { Log.e(TAG, "query error", e); return; } final int response = skuDetails.getInt("RESPONSE_CODE"); Log.d(TAG, String.format("response = %d", response)); if (response != PaymentOneAPKUtils.RESULT_OK) { toastMessage( String.format("Got invalid response while doing query: %s", getErrorMessage(response))); return; } final ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (final String resp : responseList) { Log.d(TAG, String.format("resp = %s", resp)); } toastMessage("Item query done"); } }).start(); }