Java Code Examples for android.os.Bundle.remove()

The following are Jave code examples for showing how to use remove() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: springreplugin   File: PluginLibraryInternalProxy.java   View Source Code Vote up 6 votes
/**
 * @hide 内部方法,插件框架使用
 * 插件的Activity的onCreate调用前调用此方法
 * @param activity
 * @param savedInstanceState
 */
public void handleActivityCreateBefore(Activity activity, Bundle savedInstanceState) {
    if (LOG) {
        LogDebug.d(PLUGIN_TAG, "activity create before: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
    }

    // 对FragmentActivity做特殊处理
    if (savedInstanceState != null) {
        //
        savedInstanceState.setClassLoader(activity.getClassLoader());
        //
        try {
            savedInstanceState.remove("android:support:fragments");
        } catch (Throwable e) {
            if (LOGR) {
                LogRelease.e(PLUGIN_TAG, "a.c.b1: " + e.getMessage(), e);
            }
        }
    }

    // 对FragmentActivity做特殊处理
    Intent intent = activity.getIntent();
    if (intent != null) {
        intent.setExtrasClassLoader(activity.getClassLoader());
        activity.setTheme(getThemeId(activity, intent));
    }
}
 
Example 2
Project: SOS-The-Healthcare-Companion   File: ContactBadge.java   View Source Code Vote up 6 votes
@Override
public void onQueryComplete(int token, Uri uri, Bundle extras, boolean trigger, Uri createUri) {
    assignContactUri(uri);
    if (trigger && uri != null) {
        // Found contact, so trigger QuickContact
        ContactsContract.QuickContact.showQuickContact(getContext(),
                ContactBadge.this, uri, ContactsContract.QuickContact.MODE_LARGE, mExcludeMimes);
    } else if (createUri != null) {
        // Prompt user to add this person to contacts
        final Intent intent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, createUri);
        if (extras != null) {
            extras.remove(Constants.EXTRA_URI_CONTENT);
            intent.putExtras(extras);
        }
        getContext().startActivity(intent);
    }

}
 
Example 3
Project: AndroidBackendlessChat   File: ChatSDKAbstractChatActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    setEnableCardToast(true);
    super.onCreate(savedInstanceState);

    enableCheckOnlineOnResumed(true);

    if ( !getThread(savedInstanceState) )
        return;

    chatSDKChatHelper = new ChatSDKChatHelper(this, thread, chatSDKUiHelper);
    chatSDKChatHelper.restoreSavedInstance(savedInstanceState);

    if (savedInstanceState != null)
    {
        listPos = savedInstanceState.getInt(LIST_POS, -1);
        savedInstanceState.remove(LIST_POS);
    }

    initActionBar();
}
 
Example 4
Project: boohee_v5.6   File: NotificationCompatJellybean.java   View Source Code Vote up 6 votes
public Notification build() {
    Notification notif = this.b.build();
    Bundle extras = NotificationCompatJellybean.getExtras(notif);
    Bundle mergeBundle = new Bundle(this.mExtras);
    for (String key : this.mExtras.keySet()) {
        if (extras.containsKey(key)) {
            mergeBundle.remove(key);
        }
    }
    extras.putAll(mergeBundle);
    SparseArray<Bundle> actionExtrasMap = NotificationCompatJellybean.buildActionExtrasMap(this.mActionExtrasList);
    if (actionExtrasMap != null) {
        NotificationCompatJellybean.getExtras(notif).putSparseParcelableArray("android.support.actionExtras", actionExtrasMap);
    }
    return notif;
}
 
Example 5
Project: chat-sdk-android-push-firebase   File: ChatSDKAbstractChatActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    setEnableCardToast(true);
    super.onCreate(savedInstanceState);

    enableCheckOnlineOnResumed(true);

    if ( !getThread(savedInstanceState) )
        return;

    chatSDKChatHelper = new ChatSDKChatHelper(this, thread, chatSDKUiHelper);
    chatSDKChatHelper.restoreSavedInstance(savedInstanceState);

    if (savedInstanceState != null)
    {
        listPos = savedInstanceState.getInt(LIST_POS, -1);
        savedInstanceState.remove(LIST_POS);
    }

    initActionBar();
}
 
Example 6
Project: kognitivo   File: ShareApi.java   View Source Code Vote up 5 votes
private static void handleImagesOnAction(Bundle parameters) {
    // In general, graph objects are passed by reference (ID/URL). But if this is an OG Action,
    // we need to pass the entire values of the contents of the 'image' property, as they
    // contain important metadata beyond just a URL.
    String imageStr = parameters.getString("image");
    if (imageStr != null) {
        try {
            // Check to see if this is an json array. Will throw if not
            JSONArray images = new JSONArray(imageStr);
            for (int i = 0; i < images.length(); ++i) {
                JSONObject jsonImage = images.optJSONObject(i);
                if(jsonImage != null) {
                    putImageInBundleWithArrayFormat(parameters, i, jsonImage);
                } else {
                    // If we don't have jsonImage we probably just have a url
                    String url = images.getString(i);
                    parameters.putString(String.format(Locale.ROOT, "image[%d][url]", i), url);
                }
            }
            parameters.remove("image");
            return;
        } catch (JSONException ex) {
            // We couldn't parse the string as an array
        }

        // If the image is not in an array it might just be an single photo
        try {
            JSONObject image = new JSONObject(imageStr);
            putImageInBundleWithArrayFormat(parameters, 0, image);
            parameters.remove("image");
        } catch (JSONException exception) {
            // The image was not in array format or a json object and can be safely passed
            // without modification
        }
    }
}
 
Example 7
Project: kognitivo   File: Utility.java   View Source Code Vote up 5 votes
public static boolean putJSONValueInBundle(Bundle bundle, String key, Object value) {
    if (value == null) {
        bundle.remove(key);
    } else if (value instanceof Boolean) {
        bundle.putBoolean(key, (boolean) value);
    } else if (value instanceof boolean[]) {
        bundle.putBooleanArray(key, (boolean[]) value);
    } else if (value instanceof Double) {
        bundle.putDouble(key, (double) value);
    } else if (value instanceof double[]) {
        bundle.putDoubleArray(key, (double[]) value);
    } else if (value instanceof Integer) {
        bundle.putInt(key, (int) value);
    } else if (value instanceof int[]) {
        bundle.putIntArray(key, (int[]) value);
    } else if (value instanceof Long) {
        bundle.putLong(key, (long) value);
    } else if (value instanceof long[]) {
        bundle.putLongArray(key, (long[]) value);
    } else if (value instanceof String) {
        bundle.putString(key, (String) value);
    } else if (value instanceof JSONArray) {
        bundle.putString(key, ((JSONArray) value).toString());
    } else if (value instanceof JSONObject) {
        bundle.putString(key, ((JSONObject) value).toString());
    } else {
        return false;
    }
    return true;
}
 
Example 8
Project: Android-Scrapper   File: GridViewPresenterImpl.java   View Source Code Vote up 5 votes
@Override
public void restoreState(Bundle savedState) {
    if (savedState.containsKey(POSITION_PARCELABLE_KEY)) {
        mPositionSavedState = savedState.getParcelable(POSITION_PARCELABLE_KEY);
        changeGrid((Grid) savedState.getParcelable(CURRENT_GRID));
        restorePosition();
        savedState.remove(POSITION_PARCELABLE_KEY);
    }
}
 
Example 9
Project: API-Example-App   File: FragmentDemoCommand.java   View Source Code Vote up 5 votes
/**
 * This example method is exposed to simulate a callback from your Intent Service, once a keyphrase
 * has been detected.
 *
 * @param bundle containing associated keyphrase extras
 */
public void onExampleCallback(final Bundle bundle) {

    if (getActivity() != null && tvResults != null && bundle != null && !bundle.isEmpty()) {

        appendText(null);

        final ArrayList<String> voiceData = bundle.getStringArrayList(Request.RESULTS_RECOGNITION);
        final float[] confidenceScore = bundle.getFloatArray(Request.CONFIDENCE_SCORES);

        if (confidenceScore != null && voiceData != null && confidenceScore.length == voiceData.size()) {
            for (int i = 0; i < voiceData.size(); i++) {
                Log.i(CLS_NAME, "onSpeechResults: " + voiceData.get(i) + " ~ " + confidenceScore[i]);
                appendText(voiceData.get(i) + " ~ " + confidenceScore[i]);
            }
        } else if (voiceData != null) {
            for (int i = 0; i < voiceData.size(); i++) {
                Log.i(CLS_NAME, "onSpeechResults: " + voiceData.get(i));
                appendText(voiceData.get(i));
            }
        } else {
            Log.w(CLS_NAME, "onSpeechResults: values error");
            appendText("onSpeechResults: values error");
        }

        appendText("\n");

        bundle.remove(Request.RESULTS_RECOGNITION);
        bundle.remove(Request.CONFIDENCE_SCORES);

        final Set<String> keys = bundle.keySet();
        for (final String key : keys) {
            appendText(key + ": " + bundle.get(key));
        }

        if (voiceData != null && !voiceData.isEmpty()) {

            switch (bundle.getInt(SaiyKeyphrase.SAIY_ACTION, 0)) {

                case DO_SOMETHING_1:
                    Log.i(CLS_NAME, "onHandleIntent: DO_SOMETHING_1");
                    appendText("Heard: " + SAUSAGES + "!");
                    break;
                case DO_SOMETHING_2:
                    Log.i(CLS_NAME, "onHandleIntent: DO_SOMETHING_2");
                    appendText("\nStart the playlist: " + voiceData.get(0).toLowerCase(Locale.US)
                            .replaceFirst(SPOTIFY_PLAYLIST, "") + "!");
                    break;
                case DO_SOMETHING_3:
                    Log.i(CLS_NAME, "onHandleIntent: DO_SOMETHING_3");
                    appendText("\nStart the album: " + voiceData.get(0).toLowerCase(Locale.US)
                            .replaceFirst(SPOTIFY_ALBUM, "") + "!");
                    break;
                case DO_NOT_USE_ZERO:
                    Log.e(CLS_NAME, "onHandleIntent: DO_NOT_USE_ZERO");
                    break;
            }
        } else {
            Log.e(CLS_NAME, "onHandleIntent: voice data empty - should not happen");
        }
    }
}
 
Example 10
Project: orgzly-android   File: NoteFragment.java   View Source Code Vote up 5 votes
/**
 * Note -> Bundle
 */
private void updateBundleFromNote(Bundle outState) {
    OrgHead head = mNote.getHead();

    outState.putString(ARG_CURRENT_STATE, head.getState());
    outState.putString(ARG_CURRENT_PRIORITY, head.getPriority());

    outState.putString(ARG_CURRENT_TITLE, head.getTitle());

    outState.putString(ARG_CURRENT_TAGS, TextUtils.join(" ", head.getTags()));

    if (head.getScheduled() != null) {
        outState.putString(ARG_CURRENT_SCHEDULED, head.getScheduled().toString());
    }

    if (head.getDeadline() != null) {
        outState.putString(ARG_CURRENT_DEADLINE, head.getDeadline().toString());
    }

    if (head.getClosed() != null) {
        outState.putString(ARG_CURRENT_CLOSED, head.getClosed().toString());
    }

    /* Store properties as an array of strings: name1 value1 name2 value2 ... */
    if (head.hasProperties()) {
        ArrayList<String> array = new ArrayList<>();
        for (OrgProperty property: head.getProperties()) {
            array.add(property.getName());
            array.add(property.getValue());
        }
        outState.putStringArrayList(ARG_CURRENT_PROPERTIES, array);

    } else {
        outState.remove(ARG_CURRENT_PROPERTIES);
    }

    outState.putString(ARG_CURRENT_CONTENT, head.getContent());
}
 
Example 11
Project: orgzly-android   File: Selection.java   View Source Code Vote up 5 votes
/**
 * Save selected items.
 * Restored with {@link Selection#restoreIds(android.os.Bundle)}.
 */
public void saveIds(Bundle bundle) {
    if (getCount() > 0) {
        long[] idsArray = new long[mSelectedIds.size()];
        int i = 0;
        for (long id: mSelectedIds) {
            idsArray[i++] = id;
        }
        bundle.putLongArray(SAVED_BUNDLE_KEY, idsArray);
    } else {
        bundle.remove(SAVED_BUNDLE_KEY);
    }
}
 
Example 12
Project: XinFramework   File: TransactionDelegate.java   View Source Code Vote up 5 votes
private void handleNewBundle(ISupportFragment toFragment, ISupportFragment stackToFragment) {
    Bundle argsNewBundle = toFragment.getSupportDelegate().mNewBundle;

    Bundle args = getArguments((Fragment) toFragment);
    if (args.containsKey(FRAGMENTATION_ARG_CONTAINER)) {
        args.remove(FRAGMENTATION_ARG_CONTAINER);
    }

    if (argsNewBundle != null) {
        args.putAll(argsNewBundle);
    }

    stackToFragment.onNewBundle(args);
}
 
Example 13
Project: chat-sdk-android-push-firebase   File: CatchImageClickListener.java   View Source Code Vote up 5 votes
public void restoreSavedInstance(Bundle savedInstanceState){
    if (savedInstanceState == null)
        return;

    selectedFilePath = savedInstanceState.getString(SELECTED_FILE_PATH);
    savedInstanceState.remove(SELECTED_FILE_PATH);
}
 
Example 14
Project: Android-Scrapper   File: GridCalendarPresenterImpl.java   View Source Code Vote up 5 votes
@Override
public void restoreState(Bundle savedState) {
    if (savedState.containsKey(POSITION_PARCELABLE_KEY)) {
        mPositionSavedState = savedState.getParcelable(POSITION_PARCELABLE_KEY);
        mYear = savedState.getInt(CURRENT_YEAR);
        mMonth = savedState.getInt(CURRENT_MONTH);
        savedState.remove(POSITION_PARCELABLE_KEY);
    }
}
 
Example 15
Project: letv   File: Util.java   View Source Code Vote up 5 votes
public static Statistic upload(Context context, String str, Bundle bundle) throws MalformedURLException, IOException, NetworkUnavailableException, HttpStatusException {
    int size;
    int i;
    byte[] byteArray;
    if (context != null) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
        if (connectivityManager != null) {
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            if (activeNetworkInfo == null || !activeNetworkInfo.isAvailable()) {
                throw new NetworkUnavailableException(NetworkUnavailableException.ERROR_INFO);
            }
        }
    }
    Bundle bundle2 = new Bundle(bundle);
    String str2 = "";
    str2 = bundle2.getString("appid_for_getting_config");
    bundle2.remove("appid_for_getting_config");
    HttpClient httpClient = HttpUtils.getHttpClient(context, str2, str);
    HttpUriRequest httpPost = new HttpPost(str);
    Bundle bundle3 = new Bundle();
    for (String str22 : bundle2.keySet()) {
        Object obj = bundle2.get(str22);
        if (obj instanceof byte[]) {
            bundle3.putByteArray(str22, (byte[]) obj);
        }
    }
    httpPost.setHeader(HttpRequest.HEADER_CONTENT_TYPE, "multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f");
    httpPost.setHeader("Connection", "Keep-Alive");
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    byteArrayOutputStream.write(getBytesUTF8("--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
    byteArrayOutputStream.write(getBytesUTF8(encodePostBody(bundle2, "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f")));
    if (!bundle3.isEmpty()) {
        size = bundle3.size();
        byteArrayOutputStream.write(getBytesUTF8("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
        i = -1;
        for (String str222 : bundle3.keySet()) {
            i++;
            byteArrayOutputStream.write(getBytesUTF8("Content-Disposition: form-data; name=\"" + str222 + "\"; filename=\"" + "value.file" + "\"" + "\r\n"));
            byteArrayOutputStream.write(getBytesUTF8("Content-Type: application/octet-stream\r\n\r\n"));
            byteArray = bundle3.getByteArray(str222);
            if (byteArray != null) {
                byteArrayOutputStream.write(byteArray);
            }
            if (i < size - 1) {
                byteArrayOutputStream.write(getBytesUTF8("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
            }
        }
    }
    byteArrayOutputStream.write(getBytesUTF8("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f--\r\n"));
    byteArray = byteArrayOutputStream.toByteArray();
    i = byteArray.length + 0;
    byteArrayOutputStream.close();
    httpPost.setEntity(new ByteArrayEntity(byteArray));
    HttpResponse execute = httpClient.execute(httpPost);
    size = execute.getStatusLine().getStatusCode();
    if (size == 200) {
        return new Statistic(a(execute), i);
    }
    throw new HttpStatusException(HttpStatusException.ERROR_INFO + size);
}
 
Example 16
Project: aarLibrary   File: FragmentationDelegate.java   View Source Code Vote up 5 votes
private void handleNewBundle(SupportFragment toFragment, Fragment stackToFragment) {
    Bundle argsNewBundle = toFragment.getNewBundle();

    Bundle args = toFragment.getArguments();
    if (args.containsKey(FRAGMENTATION_ARG_CONTAINER)) {
        args.remove(FRAGMENTATION_ARG_CONTAINER);
    }

    if (argsNewBundle != null) {
        args.putAll(argsNewBundle);
    }

    ((SupportFragment) stackToFragment).onNewBundle(args);
}
 
Example 17
Project: Android-Scrapper   File: LeaguePresenterImpl.java   View Source Code Vote up 5 votes
@Override
    public void restoreState(Bundle savedState) {
        if (savedState.containsKey(POSITION_PARCELABLE_KEY)) {
//            Parcelable mPositionSavedState = savedState.getParcelable(POSITION_PARCELABLE_KEY);

            savedState.remove(POSITION_PARCELABLE_KEY);
        }
    }
 
Example 18
Project: Android-Scrapper   File: GridPagePresenterImpl.java   View Source Code Vote up 5 votes
@Override
public void restoreState(Bundle savedState) {
    if (savedState.containsKey(POSITION_PARCELABLE_KEY)) {
        mPositionSavedState = savedState.getParcelable(POSITION_PARCELABLE_KEY);

        savedState.remove(POSITION_PARCELABLE_KEY);
    }
}
 
Example 19
Project: chat-sdk-android-push-firebase   File: ChatSDKChatHelper.java   View Source Code Vote up 4 votes
public void restoreSavedInstance(Bundle savedInstanceState){
    if (savedInstanceState == null)
        return;
    
    if (!hasActivity())
        return;

    selectedFilePath = savedInstanceState.getString(SELECTED_FILE_PATH);
    savedInstanceState.remove(SELECTED_FILE_PATH);


    shared = savedInstanceState.getBoolean(SHARED);

    loadedMessagesAmount = savedInstanceState.getInt(LOADED_MESSAGES_AMOUNT, 0);

    readCount = savedInstanceState.getInt(READ_COUNT);

    mFileName = savedInstanceState.getString(FILE_NAME);
    SuperCardToast.onRestoreState(savedInstanceState, activity.get());
}
 
Example 20
Project: Android-Scrapper   File: GridSettingPresenterImpl.java   View Source Code Vote up 4 votes
@Override
public void restoreState(Bundle savedState) {
    changeGrid((Grid) savedState.getParcelable(CURRENT_GRID));
    savedState.remove(POSITION_PARCELABLE_KEY);
}