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:th.in.ffc.app.form.EditFormActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        mEditList = savedInstanceState.getStringArrayList("edit");
        mDeleteList = savedInstanceState.getStringArrayList("delete");

        for (String tag : mEditList) {
            EditFragment f = (EditFragment) getSupportFragmentManager().findFragmentByTag(tag);
            if (f != null)
                f.setRemoveRequestListener(this.mRemoveListener);
        }/*from  www.  j  a  v a2s  .c o  m*/
    }
}

From source file:com.nextgis.libngui.dialog.LocalResourceSelectDialog.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setKeepInstance(true);//from   w  ww  . j a  v a  2s.  c  om
    setThemeDark(ThemeUtil.isDarkTheme(getActivity()));

    super.onCreate(savedInstanceState);

    if (null != savedInstanceState) {
        mPath = (File) savedInstanceState.getSerializable(KEY_PATH);
        mTypeMask = savedInstanceState.getInt(KEY_MASK);
        mCanSelectMulti = savedInstanceState.getBoolean(KEY_CAN_SEL_MULTI);
        mCanWrite = savedInstanceState.getBoolean(KEY_WRITABLE);
        mSavedPathList = savedInstanceState.getStringArrayList(KEY_SELECTED_ITEMS);
    }

    mAdapter = new LocalResourceListAdapter();
    mAdapter.setSingleSelectable(!mCanSelectMulti);
    mAdapter.setOnChangePathListener(this);
    mAdapter.addOnSelectionChangedListener(this);

    runLoader();
}

From source file:com.todoroo.astrid.tags.TagsControlSet.java

@Nullable
@Override// ww w .j  a  v a  2s  .  c  o  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    ArrayList<String> newTags;
    if (savedInstanceState != null) {
        selectedTags = savedInstanceState.getParcelableArrayList(EXTRA_SELECTED_TAGS);
        newTags = savedInstanceState.getStringArrayList(EXTRA_NEW_TAGS);
    } else {
        selectedTags = tagService.getTagDataForTask(taskId);
        newTags = newArrayList();
    }
    allTags = tagService.getTagList();
    dialogView = inflater.inflate(R.layout.control_set_tag_list, null);
    newTagLayout = (LinearLayout) dialogView.findViewById(R.id.newTags);
    tagListView = (ListView) dialogView.findViewById(R.id.existingTags);
    tagListView.setAdapter(new ArrayAdapter<TagData>(getActivity(),
            R.layout.simple_list_item_multiple_choice_themed, allTags) {
        @NonNull
        @SuppressLint("NewApi")
        @Override
        public View getView(int position, View convertView, @NonNull ViewGroup parent) {
            CheckedTextView view = (CheckedTextView) super.getView(position, convertView, parent);
            TagData tagData = allTags.get(position);
            ThemeColor themeColor = themeCache.getThemeColor(tagData.getColor() >= 0 ? tagData.getColor() : 19);
            view.setText(tagData.getName());
            Drawable original = ContextCompat.getDrawable(getContext(), R.drawable.ic_label_24dp);
            Drawable wrapped = DrawableCompat.wrap(original.mutate());
            DrawableCompat.setTint(wrapped, themeColor.getPrimaryColor());
            if (atLeastJellybeanMR1()) {
                view.setCompoundDrawablesRelativeWithIntrinsicBounds(wrapped, null, null, null);
            } else {
                view.setCompoundDrawablesWithIntrinsicBounds(wrapped, null, null, null);
            }
            return view;
        }
    });
    for (String newTag : newTags) {
        addTag(newTag);
    }
    addTag("");
    for (TagData tag : selectedTags) {
        setTagSelected(tag);
    }
    refreshDisplayView();
    return view;
}

From source file:com.otaupdater.OTAUpdaterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Context context = getApplicationContext();
    cfg = Config.getInstance(context);/*from w w w.  j a va 2  s  .  c  om*/

    if (!cfg.hasProKey()) {
        bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
                billingSrvConn = new ServiceConnection() {
                    @Override
                    public void onServiceDisconnected(ComponentName name) {
                        billingSrvConn = null;
                    }

                    @Override
                    public void onServiceConnected(ComponentName name, IBinder binder) {
                        IInAppBillingService service = IInAppBillingService.Stub.asInterface(binder);

                        try {
                            Bundle owned = service.getPurchases(3, getPackageName(), "inapp", null);
                            ArrayList<String> ownedItems = owned.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                            ArrayList<String> ownedItemData = owned
                                    .getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                            if (ownedItems != null && ownedItemData != null) {
                                for (int q = 0; q < ownedItems.size(); q++) {
                                    if (ownedItems.get(q).equals(Config.PROKEY_SKU)) {
                                        JSONObject itemData = new JSONObject(ownedItemData.get(q));
                                        cfg.setKeyPurchaseToken(itemData.getString("purchaseToken"));
                                        break;
                                    }
                                }
                            }
                        } catch (RemoteException ignored) {
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        unbindService(this);
                        billingSrvConn = null;
                    }
                }, Context.BIND_AUTO_CREATE);
    }

    boolean data = Utils.dataAvailable(this);
    boolean wifi = Utils.wifiConnected(this);

    if (!data || !wifi) {
        final boolean nodata = !data && !wifi;

        if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title);
            builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message);
            builder.setCancelable(false);
            builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
            builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS);
                    startActivity(i);
                }
            });
            builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (nodata) {
                        cfg.setIgnoredDataWarn(true);
                    } else {
                        cfg.setIgnoredWifiWarn(true);
                    }
                    dialog.dismiss();
                }
            });

            final AlertDialog dlg = builder.create();

            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();
        }
    }

    Utils.updateDeviceRegistration(this);
    CheckinReceiver.setDailyAlarm(this);

    if (!PropUtils.isRomOtaEnabled() && !PropUtils.isKernelOtaEnabled() && !cfg.getIgnoredUnsupportedWarn()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.alert_unsupported_title);
        builder.setMessage(R.string.alert_unsupported_message);
        builder.setCancelable(false);
        builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });
        builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                cfg.setIgnoredUnsupportedWarn(true);
                dialog.dismiss();
            }
        });

        final AlertDialog dlg = builder.create();

        dlg.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                onDialogShown(dlg);
            }
        });
        dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                onDialogClosed(dlg);
            }
        });
        dlg.show();
    }

    setContentView(R.layout.main);

    Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads);
    if (adFragment != null)
        getFragmentManager().beginTransaction().hide(adFragment).commit();

    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);

    bar = getActionBar();
    assert bar != null;

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setTitle(R.string.app_name);

    TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class);

    ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom);
    if (cfg.hasStoredRomUpdate())
        romTab.setIcon(R.drawable.ic_action_warning);
    romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class);

    ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel);
    if (cfg.hasStoredKernelUpdate())
        kernelTab.setIcon(R.drawable.ic_action_warning);
    kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class);

    if (!handleNotifAction(getIntent())) {
        if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) {
            cfg.getStoredRomUpdate().showUpdateNotif(this);
        }

        if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) {
            cfg.getStoredKernelUpdate().showUpdateNotif(this);
        }

        if (savedInstanceState != null) {
            bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0));
        }
    }
}

From source file:com.onesignal.TrackGooglePurchase.java

private void QueryBoughtItems() {
    if (isWaitingForPurchasesRequest)
        return;/*from  www  .  j av a  2 s  .c  o m*/

    new Thread(new Runnable() {
        public void run() {
            isWaitingForPurchasesRequest = true;
            try {
                if (getPurchasesMethod == null) {
                    getPurchasesMethod = getGetPurchasesMethod(IInAppBillingServiceClass);
                    getPurchasesMethod.setAccessible(true);
                }

                Bundle ownedItems = (Bundle) getPurchasesMethod.invoke(mIInAppBillingService, 3,
                        appContext.getPackageName(), "inapp", null);
                if (ownedItems.getInt("RESPONSE_CODE") == 0) {
                    ArrayList<String> skusToAdd = new ArrayList<String>();
                    ArrayList<String> newPurchaseTokens = new ArrayList<String>();

                    ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                    ArrayList<String> purchaseDataList = ownedItems
                            .getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                    for (int i = 0; i < purchaseDataList.size(); i++) {
                        String purchaseData = purchaseDataList.get(i);
                        String sku = ownedSkus.get(i);
                        JSONObject itemPurchased = new JSONObject(purchaseData);
                        String purchaseToken = itemPurchased.getString("purchaseToken");

                        if (!purchaseTokens.contains(purchaseToken)
                                && !newPurchaseTokens.contains(purchaseToken)) {
                            newPurchaseTokens.add(purchaseToken);
                            skusToAdd.add(sku);
                        }
                    }

                    if (skusToAdd.size() > 0)
                        sendPurchases(skusToAdd, newPurchaseTokens);
                    else if (purchaseDataList.size() == 0) {
                        newAsExisting = false;
                        prefsEditor.putBoolean("ExistingPurchases", false);
                        prefsEditor.commit();
                    }

                    // TODO: Handle very large list. Test for continuationToken != null then call getPurchases again
                }
            } catch (Throwable e) {
                e.printStackTrace();
            }
            isWaitingForPurchasesRequest = false;
        }
    }).start();
}

From source file:com.nicolatesser.geofencedemo.LocationActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    // getIntent() should always return the most recent
    setIntent(intent);//from   ww  w . java2s .c o  m

    boolean receiverStarted = intent.getBooleanExtra("RECEIVER_STARTED", false);

    if (!receiverStarted) {
        return;
    }

    Bundle bundle = intent.getParcelableExtra("geo_fences");
    ArrayList<String> requestIds = bundle.getStringArrayList("request_ids");

    if (requestIds == null) {
        Log.v(LocationActivity.TAG, "request_ids == null");
        return;
    }

    int transition = intent.getIntExtra("transition", -2);

    for (String requestId : requestIds) {
        Log.v(LocationActivity.TAG, "Triggering Geo Fence requestId " + requestId);
        if (transition == Geofence.GEOFENCE_TRANSITION_ENTER) {
            Circle circle = mGeoFences.get(requestId);
            if (circle == null) {
                continue;
            }
            Log.v(LocationActivity.TAG, "triggering_geo_fences enter == " + requestId);

            // Add a superimposed red circle when a geofence is entered and
            // put the corresponding object in triggering_fences.
            CircleOptions circleOptions = new CircleOptions();
            circleOptions.center(circle.getCenter()).radius(circle.getRadius())
                    .fillColor(Color.argb(100, 100, 0, 0));
            Circle newCircle = mMap.addCircle(circleOptions);
            mTriggeringFences.put(requestId, newCircle);

            // LocationLoggerService.getInstance().writeActivity(
            // DemoConstant.NAME, "Entered in Geofence");

        } else if (transition == Geofence.GEOFENCE_TRANSITION_EXIT) {
            Log.v(LocationActivity.TAG, "triggering_geo_fences exit == " + requestId);
            Circle circle = mTriggeringFences.get(requestId);
            if (circle == null) {
                continue;
            }
            // Remove the superimposed red circle from the map and the
            // corresponding Circle object from triggering_fences hash_map.
            circle.remove();
            mTriggeringFences.remove(requestId);

            // LocationLoggerService.getInstance().writeActivity(
            // DemoConstant.NAME, "Exited from Geofence");
        }
    }
    return;
}

From source file:com.google.android.apps.forscience.whistlepunk.metadata.TriggerListFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSensorId = getArguments().getString(ARG_SENSOR_ID);
    mExperimentId = getArguments().getString(ARG_EXPERIMENT_ID);
    mLayoutPosition = getArguments().getInt(ARG_LAYOUT_POSITION);
    if (savedInstanceState != null) {
        mTriggerOrder = savedInstanceState.getStringArrayList(KEY_TRIGGER_ORDER);
    } else {/*from w  w w.jav  a 2  s .  c o m*/
        mTriggerOrder = getArguments().getStringArrayList(ARG_TRIGGER_ORDER);
    }
    setHasOptionsMenu(true);
}

From source file:com.nokia.example.pepperfarm.iap.Payment.java

/**
 * Fetches the prices asynchronously//from w  ww  .  ja va  2 s. c om
 */
public void fetchPrices() {

    if (!isBillingAvailable())
        return;

    for (Product p : Content.ITEMS) {
        if (p.getPrice() != "") {
            Log.i("fetchPrices", "Prices already available. Not fetching.");
            return;
        }
    }

    AsyncTask<Void, String, Void> pricesTask = new AsyncTask<Void, String, Void>() {

        @Override
        protected Void doInBackground(Void... params) {

            ArrayList<String> productIdArray = new ArrayList<String>(Content.ITEM_MAP.keySet());
            Bundle productBundle = new Bundle();
            productBundle.putStringArrayList("ITEM_ID_LIST", productIdArray);

            try {
                Bundle priceInfo = npay.getProductDetails(API_VERSION, activity.getPackageName(),
                        ITEM_TYPE_INAPP, productBundle);

                if (priceInfo.getInt("RESPONSE_CODE", RESULT_ERR) == RESULT_OK) {
                    ArrayList<String> productDetailsList = priceInfo.getStringArrayList("DETAILS_LIST");

                    for (String productDetails : productDetailsList) {
                        parseProductDetails(productDetails);
                    }

                } else {
                    Log.e("fetchPrices", "PRICE - priceInfo was not ok: Result was: "
                            + priceInfo.getInt("RESPONSE_CODE", -100));
                }

            } catch (JSONException e) {
                Log.e("fetchPrices", "PRODUCT DETAILS PARSING EXCEPTION: " + e.getMessage(), e);
            } catch (RemoteException e) {
                Log.e("fetchPrices", "PRICE EXCEPTION: " + e.getMessage(), e);
            }
            return null;
        }

        private void parseProductDetails(String productDetails) throws JSONException {

            ProductDetails details = new ProductDetails(productDetails);

            Log.i("fetchPrices", productDetails);

            Product p = Content.ITEM_MAP.get(details.getProductId());

            if (p != null) {
                p.setPrice(details.getPriceFormatted());
                Log.i("fetchPrices", "PRICE RECEIVED - " + details.getPrice() + " " + details.getCurrency());
            } else {
                Log.i("fetchPrices",
                        "Unable to set price for product " + details.getProductId() + ". Product not found.");
            }
        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            if (ProductListFragment.purchaseListAdapter != null) {
                ProductListFragment.purchaseListAdapter.notifyDataSetChanged();
            }
            if (MainScreenPepperListFragment.reference.adapter != null) {
                MainScreenPepperListFragment.reference.adapter.notifyDataSetChanged();
            }
        }

    };
    pricesTask.execute();
}

From source file:com.annuletconsulting.homecommand.node.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    speechRecognizer = SpeechRecognizer.createSpeechRecognizer(getActivity());
    speechRecognizer.setRecognitionListener(new RecognitionListener() {
        @Override/*from   w w w.  j av  a  2  s  .  c  o m*/
        public void onReadyForSpeech(Bundle params) {
            for (String key : params.keySet())
                Log.d(TAG, (String) params.get(key));
        }

        @Override
        public void onBeginningOfSpeech() {
            Log.d(TAG, "Begin");
            ignore = false;
        }

        @Override
        public void onRmsChanged(float rmsdB) {
            // Log.d(TAG, "Rms changed: "+rmsdB);
        }

        @Override
        public void onBufferReceived(byte[] buffer) {
            Log.d(TAG, "Buffer Received: " + buffer.toString());
        }

        @Override
        public void onEndOfSpeech() {
            Log.d(TAG, "Endofspeech()");
        }

        @Override
        public void onError(int error) {
            Log.d(TAG, "error: " + error);
        }

        @Override
        public void onResults(Bundle results) {
            Log.d(TAG, "onResults()");
            for (String key : results.keySet()) {
                Log.d(TAG, key + ": " + results.get(key).toString());
                // Iterator<String> it = ((ArrayList<String>)
                // results.get(key)).listIterator();
                // while (it.hasNext())
                // Log.d(TAG, it.next());
            }
            if (!ignore)
                sendToServer(results.getStringArrayList(RESULTS_KEY).get(0));
        }

        @Override
        public void onPartialResults(Bundle partialResults) {
            //            Log.d(TAG, "onPartialResults()");
            //            String firstWord = partialResults.getStringArrayList(RESULTS_KEY).get(0).split(" ")[0];
            //            Log.d(TAG, firstWord);
            //            if (firstWord.length() > 0 && !firstWord.equalsIgnoreCase("computer") && !firstWord.equalsIgnoreCase("android")) {
            //               Log.d(TAG, "Killing this Recognition.");
            //               ignore = true;
            //               stopRecognizing();
            //               startListening();
            //            }
        }

        @Override
        public void onEvent(int eventType, Bundle params) {
            Log.d(TAG, "onEvent() type: " + eventType);
            for (String key : params.keySet())
                Log.d(TAG, (String) params.get(key));
        }
    });
    View v = inflater.inflate(R.layout.main_fragment, null);
    button = (Button) v.findViewById(R.id.listen_button);
    button.setBackgroundResource(R.drawable.stopped);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            toggleListenMode();
        }
    });
    instance = this;
    return v;
}

From source file:link.kjr.file_manager.MainActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    Log.i(BuildConfig.APPLICATION_ID, " onRestoreInstance called");

    ArrayList<String> s = savedInstanceState.getStringArrayList("selectedFiles");
    if (s != null) {
        selectedFiles = s;/*  ww  w . j  a  v a  2s.  co m*/
    }
    String new_currentPath = savedInstanceState.getString("currentPath");
    if (new_currentPath != null) {
        currentPath = new_currentPath;
    }
    setDirectoryView(currentPath);

}