Example usage for android.os Bundle getStringArrayList

List of usage examples for android.os Bundle getStringArrayList

Introduction

In this page you can find the example usage for android.os Bundle getStringArrayList.

Prototype

@Override
@Nullable
public ArrayList<String> getStringArrayList(@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.tangrainc.inappbilling.InAppBillingHelper.java

public ListenableFuture<JSONObject[]> getPurchases(final String continuationToken) {
    return _executor.submit(new Callable<JSONObject[]>() {
        @Override//from  ww w. ja v a2s  . c  om
        public JSONObject[] call() throws Exception {
            Log.d(TAG, "Getting Purchases...");

            ArrayList<JSONObject> result = new ArrayList<>();
            Bundle ownedItems = _service.getPurchases(3, _context.getPackageName(), "inapp", continuationToken);
            int response = ownedItems.getInt("RESPONSE_CODE");

            if (response == 0) {
                ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
                ArrayList<String> signatureList = ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
                String newContinuationToken = ownedItems.getString("INAPP_CONTINUATION_TOKEN");

                for (int i = 0; i < purchaseDataList.size(); i++) {
                    String purchaseData = purchaseDataList.get(i);
                    String signature = signatureList.get(i);
                    JSONObject resultItem = new JSONObject(purchaseData);

                    resultItem.put("signature", signature);
                    result.add(resultItem);
                }

                if (newContinuationToken != null) {
                    result.addAll(Arrays.asList(getPurchases(newContinuationToken).get()));
                }
            } else {
                throw new Exception("Response from service: " + response);
            }

            return result.toArray(new JSONObject[0]);
        }
    });
}

From source file:com.ct.speech.HintReceiver.java

public void sendBackResults(Bundle results) {
    ArrayList<String> voiceResults = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    speechResults(reqCode, voiceResults);
}

From source file:com.vuze.android.remote.dialog.DialogFragmentMoveData.java

private void setupVars(View view) {
    Bundle args = getArguments();
    String name = args.getString("name");
    torrentId = args.getLong("id");
    String downloadDir = args.getString("downloadDir");
    history = args.getStringArrayList("history");

    ArrayList<String> newHistory = new ArrayList<>();
    if (history != null) {
        newHistory.addAll(history);/* w  w  w. j a  v  a  2  s  . c om*/
    }

    if (downloadDir != null && !newHistory.contains(downloadDir)) {
        if (newHistory.size() > 1) {
            newHistory.add(1, downloadDir);
        } else {
            newHistory.add(downloadDir);
        }
    }

    etLocation = (EditText) view.findViewById(R.id.movedata_editview);
    if (downloadDir != null) {
        etLocation.setText(downloadDir);
    }
    ListView lvHistory = (ListView) view.findViewById(R.id.movedata_historylist);
    cbRememberLocation = (CheckBox) view.findViewById(R.id.movedata_remember);
    TextView tv = (TextView) view.findViewById(R.id.movedata_label);

    tv.setText(getResources().getString(R.string.movedata_label, name));

    ArrayAdapter<String> adapter = new ArrayAdapter<>(view.getContext(), R.layout.list_view_small_font,
            newHistory);
    lvHistory.setAdapter(adapter);

    lvHistory.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
            Object item = parent.getItemAtPosition(position);

            if (item instanceof String) {
                etLocation.setText((String) item);
            }
        }
    });

}

From source file:cn.laojing.smarthome.VoiceActivity.java

@Override
public void onPartialResults(Bundle partialResults) {
    ArrayList<String> nbest = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if (nbest.size() > 0) {
        print("~" + Arrays.toString(nbest.toArray(new String[0])));
    }// w  w w.j ava 2s .  com
}

From source file:com.android.settings.localepicker.LocaleDragAndDropAdapter.java

/**
 * Restores the list of checked locales to preserve status when the list is recreated.
 * (for instance when the device is rotated)
 * @param savedInstanceState Bundle with the data saved by {@link #saveState(Bundle)}
 *///ww w. j a  va  2s.  co  m
public void restoreState(Bundle savedInstanceState) {
    if (savedInstanceState != null && mRemoveMode) {
        final ArrayList<String> selectedLocales = savedInstanceState
                .getStringArrayList(CFGKEY_SELECTED_LOCALES);
        if (selectedLocales == null || selectedLocales.isEmpty()) {
            return;
        }
        for (LocaleStore.LocaleInfo li : mFeedItemList) {
            li.setChecked(selectedLocales.contains(li.getId()));
        }
        notifyItemRangeChanged(0, mFeedItemList.size());
    }
}

From source file:com.facebook.login.GetTokenLoginMethodHandler.java

void getTokenCompleted(LoginClient.Request request, Bundle result) {
    if (getTokenClient != null) {
        getTokenClient.setCompletedListener(null);
    }//from www  .j  a  va 2s .  co m
    getTokenClient = null;

    loginClient.notifyBackgroundProcessingStop();

    if (result != null) {
        ArrayList<String> currentPermissions = result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
        Set<String> permissions = request.getPermissions();
        if ((currentPermissions != null)
                && ((permissions == null) || currentPermissions.containsAll(permissions))) {
            // We got all the permissions we needed, so we can complete the auth now.
            complete(request, result);
            return;
        }

        // We didn't get all the permissions we wanted, so update the request with just the
        // permissions we still need.
        Set<String> newPermissions = new HashSet<String>();
        for (String permission : permissions) {
            if (!currentPermissions.contains(permission)) {
                newPermissions.add(permission);
            }
        }
        if (!newPermissions.isEmpty()) {
            addLoggingExtra(LoginLogger.EVENT_EXTRAS_NEW_PERMISSIONS, TextUtils.join(",", newPermissions));
        }

        request.setPermissions(newPermissions);
    }

    loginClient.tryNextHandler();
}

From source file:nl.hnogames.domoticz.SpeechSettingsActivity.java

private void showSpeechResults(Bundle results) {
    ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    //Toast.makeText(this, matches.get(0), Toast.LENGTH_LONG).show();
    processResult(matches.get(0).toLowerCase());
}

From source file:com.example.com.benasque2014.mercurio.AddRecorridoActivity.java

private void guardarRuta() {
    boolean[] periodicidad = new boolean[7];
    for (int i = 0; i < 7; i++) {
        periodicidad[i] = false;/* w w w  .  ja va 2  s. c  om*/
    }
    String strPeriodicidad = "0:0:0:0:0:0:0";
    if (mWizardModel.findByKey("Periodicidad").getData().getString(SingleFixedBooleanPage.SIMPLE_DATA_KEY, "No")
            .equalsIgnoreCase("Si")) {
        BranchPage mPage = (BranchPage) mWizardModel.findByKey("Periodicidad");
        Bundle a = mPage.findByKey("Si:Cada cuanto").getData();
        List<String> datosPer = a.getStringArrayList(Page.SIMPLE_DATA_KEY);
        /*
        strPeriodicidad="{\"L\": "+datosPer.get(0)+", "
         + "\"M\": "+datosPer.get(1)+", "
         + "\"X\": "+datosPer.get(2)+", "
         + "\"J\": "+datosPer.get(3)+", "
         + "\"V\": "+datosPer.get(4)+", "
         + "\"S\": "+datosPer.get(5)+", "
         + "\"D\": "+datosPer.get(6)+"}";
         */

        if (strPeriodicidad != null) {
            strPeriodicidad = (datosPer.contains("Lunes") ? "1" : "0") + ":"
                    + (datosPer.contains("Martes") ? "1" : "0") + ":"
                    + (datosPer.contains("Mircoles") ? "1" : "0") + ":"
                    + (datosPer.contains("Jueves") ? "1" : "0") + ":"
                    + (datosPer.contains("Viernes") ? "1" : "0") + ":"
                    + (datosPer.contains("Sbado") ? "1" : "0") + ":"
                    + (datosPer.contains("Domingo") ? "1" : "0");
        }

    }
    String strParadas = "[";
    Iterator<LatLng> it = PuntosInfoFragment.points.iterator();
    while (it.hasNext()) {
        LatLng ll = it.next();
        strParadas += "{";
        strParadas += "\"lat\":" + ll.latitude + ",";
        strParadas += "\"lon\":" + ll.longitude;
        strParadas += "},";
    }
    if (strParadas.length() > 0 && strParadas.charAt(strParadas.length() - 1) == ',') {
        strParadas = strParadas.substring(0, strParadas.length() - 1);
    }
    strParadas += "]";
    CCPClient.guardarRuta(
            mWizardModel.findByKey("Informacin bsica").getData()
                    .getString(RecorridoBasicInfoPage.NAME_DATA_KEY),
            mWizardModel.findByKey("Informacin bsica").getData()
                    .getString(RecorridoBasicInfoPage.CODIGO_DATA_KEY),
            mWizardModel.findByKey("Informacin bsica").getData()
                    .getString(RecorridoBasicInfoPage.CLASE_DATA_KEY),
            mWizardModel.findByKey("Horas").getData().getString(HorasInfoPage.HORA_INICIO_DATA_KEY),
            mWizardModel.findByKey("Horas").getData().getString(HorasInfoPage.HORA_FIN_DATA_KEY),
            mWizardModel.findByKey("Horas").getData().getString(HorasInfoPage.FRECUENCIA_DATA_KEY),
            strPeriodicidad, strParadas, "", new CCPClientHandle() {

                @Override
                public void result(boolean error, JsonArray data) {
                    finish();
                }
            });
}

From source file:com.mhennessy.mapfly.MainActivity.java

public void setMapLocationBasedOnSpeech() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.mhennessy.mapfly");

    SpeechRecognizer recognizer = SpeechRecognizer.createSpeechRecognizer(this.getApplicationContext());

    // Stop flying so that messages can be displayed to the user without
    // being overwritten by pitch/roll info.
    setFlyingEnabled(false);/*  ww w  .j ava  2s  . c  om*/
    RecognitionListener listener = new RecognitionListener() {
        @Override
        public void onResults(Bundle results) {
            ArrayList<String> voiceResults = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
            if (voiceResults == null) {
                Log.e(TAG, "No voice results");
            } else {
                Log.d(TAG, "Printing matches: ");
                for (String match : voiceResults) {
                    Log.d(TAG, match);
                }
                String bestMatch = voiceResults.get(0);
                setMapLocation(bestMatch);
            }
        }

        @Override
        public void onReadyForSpeech(Bundle params) {
            setTitle("Say something!");
            Log.d(TAG, "Ready for speech");
        }

        @Override
        public void onError(int error) {
            setTitle("Speach Error");
            Log.d(TAG, "Error listening for speech: " + error);
        }

        @Override
        public void onBeginningOfSpeech() {
            Log.d(TAG, "Speech starting");
        }

        @Override
        public void onBufferReceived(byte[] buffer) {
            // no-op
        }

        @Override
        public void onEndOfSpeech() {
            // no-op
        }

        @Override
        public void onEvent(int eventType, Bundle params) {
            // no-op
        }

        @Override
        public void onPartialResults(Bundle partialResults) {
            // no-op
        }

        @Override
        public void onRmsChanged(float rmsdB) {
            // no-op
        }
    };
    recognizer.setRecognitionListener(listener);
    recognizer.startListening(intent);
}

From source file:com.skubit.android.example.MainActivity.java

public void fetchPurchases(final ListView view) {
    Thread t = new Thread(new Runnable() {

        @Override//  ww  w.  ja v  a 2s . c  om
        public void run() {
            try {
                Bundle purchases = mService.getPurchases(1, getApplicationContext().getPackageName(), "inapp",
                        null);

                String nextToken = purchases.getString("INAPP_CONTINUATION_TOKEN");
                final ArrayList<String> purchaseData = purchases.getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                final PurchasesFragment purchasesFragment = (PurchasesFragment) mAdapter.getItem(1);

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            purchasesFragment.displayPurchases(MainActivity.this, view, purchaseData);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                });

                // TODO: validate signatures

            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    });
    t.start();
}