Example usage for android.os Bundle putStringArray

List of usage examples for android.os Bundle putStringArray

Introduction

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

Prototype

public void putStringArray(@Nullable String key, @Nullable String[] value) 

Source Link

Document

Inserts a String array value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.github.jksiezni.permissive.fragments.RationaleFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    Log.i(getClass().getSimpleName(), "onSaveInstanceState(): this=" + this);
    super.onSaveInstanceState(outState);
    outState.putStringArray("permissions", allowablePermissions);
    outState.putParcelable("messenger", permissiveMessenger);
}

From source file:com.github.jksiezni.permissive.fragments.RationaleDialogFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    if (DEBUG) {/*from ww  w . j a  v  a2s.  c  om*/
        Log.d(getClass().getSimpleName(), "onSaveInstanceState(): this=" + this);
    }
    super.onSaveInstanceState(outState);
    outState.putStringArray("permissions", allowablePermissions);
    outState.putParcelable("messenger", permissiveMessenger);
}

From source file:com.dm.wallpaper.board.fragments.dialogs.InAppBillingFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putString(Extras.EXTRA_KEY, mKey);
    outState.putStringArray(Extras.EXTRA_PRODUCT_ID, mProductsId);
    super.onSaveInstanceState(outState);
}

From source file:com.android.messaging.datamodel.BugleNotifications.java

private static void processAndSend(final NotificationState state, final boolean silent,
        final boolean softSound) {
    final Context context = Factory.get().getApplicationContext();
    final NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context);
    notifBuilder.setCategory(Notification.CATEGORY_MESSAGE);
    // TODO: Need to fix this for multi conversation notifications to rate limit dings.
    final String conversationId = state.mConversationIds.first();

    final Uri ringtoneUri = RingtoneUtil.getNotificationRingtoneUri(state.getRingtoneUri());
    // If the notification's conversation is currently observable (focused or in the
    // conversation list),  then play a notification beep at a low volume and don't display an
    // actual notification.
    if (softSound) {
        if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
            LogUtil.v(TAG,// w w w  .ja  va 2  s  .com
                    "processAndSend: fromConversationId == "
                            + "sCurrentlyDisplayedConversationId so NOT showing notification,"
                            + " but playing soft sound. conversationId: " + conversationId);
        }
        playObservableConversationNotificationSound(ringtoneUri);
        return;
    }
    state.mBaseRequestCode = state.mType;

    // Set the delete intent (except for bundled wearable notifications, which are dismissed
    // as a group, either from the wearable or when the summary notification is dismissed from
    // the host device).
    if (!(state instanceof BundledMessageNotificationState)) {
        final PendingIntent clearIntent = state.getClearIntent();
        notifBuilder.setDeleteIntent(clearIntent);
    }

    updateBuilderAudioVibrate(state, notifBuilder, silent, ringtoneUri, conversationId);

    // Set the content intent
    PendingIntent destinationIntent;
    if (state.mConversationIds.size() > 1) {
        // We have notifications for multiple conversation, go to the conversation list.
        destinationIntent = UIIntents.get().getPendingIntentForConversationListActivity(context);
    } else {
        // We have a single conversation, go directly to that conversation.
        destinationIntent = UIIntents.get().getPendingIntentForConversationActivity(context,
                state.mConversationIds.first(), null /*draft*/);
    }
    notifBuilder.setContentIntent(destinationIntent);

    // TODO: set based on contact coming from a favorite.
    notifBuilder.setPriority(state.getPriority());

    // Save the state of the notification in-progress so when the avatar is loaded,
    // we can continue building the notification.
    final NotificationCompat.Style notifStyle = state.build(notifBuilder);
    state.mNotificationBuilder = notifBuilder;
    state.mNotificationStyle = notifStyle;
    if (!state.mPeople.isEmpty()) {
        final Bundle people = new Bundle();
        people.putStringArray(NotificationCompat.EXTRA_PEOPLE,
                state.mPeople.toArray(new String[state.mPeople.size()]));
        notifBuilder.addExtras(people);
    }

    if (state.mParticipantAvatarsUris != null) {
        final Uri avatarUri = state.mParticipantAvatarsUris.get(0);
        final AvatarRequestDescriptor descriptor = new AvatarRequestDescriptor(avatarUri, sIconWidth,
                sIconHeight, OsUtil.isAtLeastL());
        final MediaRequest<ImageResource> imageRequest = descriptor.buildSyncMediaRequest(context);

        synchronized (sPendingNotifications) {
            sPendingNotifications.add(state);
        }

        // Synchronously load the avatar.
        final ImageResource avatarImage = MediaResourceManager.get().requestMediaResourceSync(imageRequest);
        if (avatarImage != null) {
            ImageResource avatarHiRes = null;
            try {
                if (isWearCompanionAppInstalled()) {
                    // For Wear users, we need to request a high-res avatar image to use as the
                    // notification card background. If the sender has a contact photo, we'll
                    // request the display photo from the Contacts provider. Otherwise, we ask
                    // the local content provider for a hi-res version of the generic avatar
                    // (e.g. letter with colored background).
                    avatarHiRes = requestContactDisplayPhoto(context, getDisplayPhotoUri(avatarUri));
                    if (avatarHiRes == null) {
                        final AvatarRequestDescriptor hiResDesc = new AvatarRequestDescriptor(avatarUri,
                                sWearableImageWidth, sWearableImageHeight, false /* cropToCircle */,
                                true /* isWearBackground */);
                        avatarHiRes = MediaResourceManager.get()
                                .requestMediaResourceSync(hiResDesc.buildSyncMediaRequest(context));
                    }
                }

                // We have to make copies of the bitmaps to hand to the NotificationManager
                // because the bitmap in the ImageResource is managed and will automatically
                // get released.
                Bitmap avatarBitmap = Bitmap.createBitmap(avatarImage.getBitmap());
                Bitmap avatarHiResBitmap = (avatarHiRes != null) ? Bitmap.createBitmap(avatarHiRes.getBitmap())
                        : null;
                sendNotification(state, avatarBitmap, avatarHiResBitmap);
                return;
            } finally {
                avatarImage.release();
                if (avatarHiRes != null) {
                    avatarHiRes.release();
                }
            }
        }
    }
    // We have no avatar. Post the notification anyway.
    sendNotification(state, null, null);
}

From source file:de.aw.awlib.fragments.AWFragmentCalendar.java

@Override
protected void setInternalArguments(Bundle args) {
    super.setInternalArguments(args);
    args.putInt(LAYOUT, layout);//from w w  w  .j  av  a  2s. com
    args.putInt(VIEWHOLDERLAYOUT, viewHolderLayout);
    args.putParcelable(DBDEFINITION, tbd);
    args.putStringArray(PROJECTION, projection);
    args.putString(SELECTION, selection);
}

From source file:de.uulm.graphicalpasswords.opentapi.TAPICreatePasswordActivity.java

public void submit(View view) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor edit = sharedPref.edit();
    edit.putString("tapi_pw", arrayToString(input));
    edit.commit();/*ww w. j  av a 2  s  . c  om*/

    Bundle bundle = new Bundle();
    bundle.putStringArray("input", input);
    DialogFragment dialog = new RememberPasswordDialogFragment();
    dialog.setArguments(bundle);
    dialog.show(getFragmentManager(), "remember");
}

From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.activities.SensorSettingsActivity.java

private void openSelectDeviceDialog() {
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBluetoothAdapter != null) {
        BluetoothDevice[] mAllBondedDevices = (BluetoothDevice[]) mBluetoothAdapter.getBondedDevices()
                .toArray(new BluetoothDevice[0]);

        int mDeviceIndex = 0;
        if (mAllBondedDevices.length > 0) {
            int deviceCount = mAllBondedDevices.length;
            String[] deviceNames = new String[deviceCount];
            for (int i = 0; i < deviceCount; i++) {
                BluetoothDevice device = mAllBondedDevices[i];
                deviceNames[i] = device.getName() + "\n|" + device.getAddress();
                if (deviceMacAdd.equals(device.getAddress())) {
                    mDeviceIndex = i;//www.  j a v a 2  s  .c om
                }
            }
            DialogFragment deviceDialog = new SelectDeviceDialogFragment();
            Bundle args = new Bundle();
            args.putStringArray("names", deviceNames);
            args.putInt("position", mDeviceIndex);
            args.putBoolean("device", true);
            deviceDialog.setArguments(args);
            getFragmentManager().beginTransaction();
            deviceDialog.show(getSupportFragmentManager().beginTransaction(), "deviceDialog");
        }
    }
}

From source file:de.aw.monma.reports.FragmentSelectionListCat.java

@Override
protected void setInternalArguments(Bundle args) {
    super.setInternalArguments(args);
    args.putParcelable(DBDEFINITION, tbd);
    args.putStringArray(PROJECTION, projection);
    args.putInt(VIEWHOLDERLAYOUT, viewHolderLayout);
}

From source file:com.facebook.internal.BundleJSONConverterTests.java

@SmallTest
public void testSimpleValues() throws JSONException {
    ArrayList<String> arrayList = new ArrayList<String>();
    arrayList.add("1st");
    arrayList.add("2nd");
    arrayList.add("third");

    Bundle innerBundle1 = new Bundle();
    innerBundle1.putInt("inner", 1);

    Bundle innerBundle2 = new Bundle();
    innerBundle2.putString("inner", "2");
    innerBundle2.putStringArray("deep list", new String[] { "7", "8" });

    innerBundle1.putBundle("nested bundle", innerBundle2);

    Bundle b = new Bundle();
    b.putBoolean("boolValue", true);
    b.putInt("intValue", 7);
    b.putLong("longValue", 5000000000l);
    b.putDouble("doubleValue", 3.14);
    b.putString("stringValue", "hello world");
    b.putStringArray("stringArrayValue", new String[] { "first", "second" });
    b.putStringArrayList("stringArrayListValue", arrayList);
    b.putBundle("nested", innerBundle1);

    JSONObject json = BundleJSONConverter.convertToJSON(b);
    assertNotNull(json);//from ww w .  j a v  a2s . c  o  m

    assertEquals(true, json.getBoolean("boolValue"));
    assertEquals(7, json.getInt("intValue"));
    assertEquals(5000000000l, json.getLong("longValue"));
    assertEquals(3.14, json.getDouble("doubleValue"));
    assertEquals("hello world", json.getString("stringValue"));

    JSONArray jsonArray = json.getJSONArray("stringArrayValue");
    assertEquals(2, jsonArray.length());
    assertEquals("first", jsonArray.getString(0));
    assertEquals("second", jsonArray.getString(1));

    jsonArray = json.getJSONArray("stringArrayListValue");
    assertEquals(3, jsonArray.length());
    assertEquals("1st", jsonArray.getString(0));
    assertEquals("2nd", jsonArray.getString(1));
    assertEquals("third", jsonArray.getString(2));

    JSONObject innerJson = json.getJSONObject("nested");
    assertEquals(1, innerJson.getInt("inner"));
    innerJson = innerJson.getJSONObject("nested bundle");
    assertEquals("2", innerJson.getString("inner"));

    jsonArray = innerJson.getJSONArray("deep list");
    assertEquals(2, jsonArray.length());
    assertEquals("7", jsonArray.getString(0));
    assertEquals("8", jsonArray.getString(1));

    Bundle finalBundle = BundleJSONConverter.convertToBundle(json);
    assertNotNull(finalBundle);

    assertEquals(true, finalBundle.getBoolean("boolValue"));
    assertEquals(7, finalBundle.getInt("intValue"));
    assertEquals(5000000000l, finalBundle.getLong("longValue"));
    assertEquals(3.14, finalBundle.getDouble("doubleValue"));
    assertEquals("hello world", finalBundle.getString("stringValue"));

    List<String> stringList = finalBundle.getStringArrayList("stringArrayValue");
    assertEquals(2, stringList.size());
    assertEquals("first", stringList.get(0));
    assertEquals("second", stringList.get(1));

    stringList = finalBundle.getStringArrayList("stringArrayListValue");
    assertEquals(3, stringList.size());
    assertEquals("1st", stringList.get(0));
    assertEquals("2nd", stringList.get(1));
    assertEquals("third", stringList.get(2));

    Bundle finalInnerBundle = finalBundle.getBundle("nested");
    assertEquals(1, finalInnerBundle.getInt("inner"));
    finalBundle = finalInnerBundle.getBundle("nested bundle");
    assertEquals("2", finalBundle.getString("inner"));

    stringList = finalBundle.getStringArrayList("deep list");
    assertEquals(2, stringList.size());
    assertEquals("7", stringList.get(0));
    assertEquals("8", stringList.get(1));
}

From source file:org.mariotaku.twidere.activity.FileSelectorActivity.java

private void showPickFileDialog() {
    final Intent intent = getIntent();
    final Uri data = intent.getData();
    final String action = intent.getAction();
    File initialDirectory = data != null ? new File(data.getPath()) : getExternalStorageDirectory();
    if (initialDirectory == null) {
        initialDirectory = new File("/");
    }//from   w w w.j  a  v a  2s .co m
    final FileSelectorDialogFragment f = new FileSelectorDialogFragment();
    final Bundle args = new Bundle();
    args.putString(EXTRA_ACTION, action);
    args.putString(EXTRA_PATH, initialDirectory.getAbsolutePath());
    args.putStringArray(EXTRA_FILE_EXTENSIONS, intent.getStringArrayExtra(EXTRA_FILE_EXTENSIONS));
    f.setArguments(args);
    f.show(getSupportFragmentManager(), "select_file");
}