Java Code Examples for android.os.bundle#putBundle()

The following examples show how to use android.os.bundle#putBundle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SampleMediaRouteProvider.java    From media-samples with Apache License 2.0 6 votes vote down vote up
private boolean handleSeek(Intent intent, ControlRequestCallback callback) {
    String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID);
    if (sid == null || !sid.equals(mSessionManager.getSessionId())) {
        return false;
    }

    String iid = intent.getStringExtra(MediaControlIntent.EXTRA_ITEM_ID);
    long pos = intent.getLongExtra(MediaControlIntent.EXTRA_ITEM_CONTENT_POSITION, 0);
    Log.d(TAG, mRouteId + ": Received seek request, pos=" + pos);
    PlaylistItem item = mSessionManager.seek(iid, pos);
    if (callback != null) {
        if (item != null) {
            Bundle result = new Bundle();
            result.putBundle(MediaControlIntent.EXTRA_ITEM_STATUS,
                    item.getStatus().asBundle());
            callback.onResult(result);
        } else {
            callback.onError("Failed to seek" +
                    ", sid=" + sid + ", iid=" + iid + ", pos=" + pos, null);
        }
    }
    return (item != null);
}
 
Example 2
Source File: MainActivity.java    From Lucid-Browser with Apache License 2.0 6 votes vote down vote up
/**
* Saves tabs that are opened to be reopened when app is opened again
*/
void saveState(){
      Log.d("LB","saving state now");
       Bundle mainBundle = new Bundle();
       if (Properties.webpageProp.closetabsonexit && isFinishing()){
           new BundleManager(activity).saveToPreferences(new Bundle());
       } else{
	 CustomWebView WV = webLayout.findViewById(R.id.browser_page);
           int tabNumber = getTabNumber();
           mainBundle.putInt("numtabs",webWindows.size());

	 if (tabNumber==-1)
		 tabNumber = 0;
	 mainBundle.putInt("tabnumber", tabNumber);

	 if (WV!=null)
		 for (int I=0;I<webWindows.size();I++){
			 Bundle bundle = new Bundle();
			 webWindows.get(I).saveState(bundle);
			 mainBundle.putBundle("WV"+I,bundle);
		 }

	 new BundleManager(activity).saveToPreferences(mainBundle);
       }
  }
 
Example 3
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void saveStateParams(Bundle bundle)
{
    String first = firstNameField.getText().toString();
    if (first.length() != 0)
    {
        bundle.putString("registerview_first", first);
    }
    String last = lastNameField.getText().toString();
    if (last.length() != 0)
    {
        bundle.putString("registerview_last", last);
    }
    if (currentTermsOfService != null)
    {
        SerializedData data = new SerializedData(currentTermsOfService.getObjectSize());
        currentTermsOfService.serializeToStream(data);
        String str = Base64.encodeToString(data.toByteArray(), Base64.DEFAULT);
        bundle.putString("terms", str);
        data.cleanup();
    }
    if (currentParams != null)
    {
        bundle.putBundle("registerview_params", currentParams);
    }
}
 
Example 4
Source File: ThreadDetailFragment.java    From mimi-reader with Apache License 2.0 5 votes vote down vote up
@Override
public void onSaveInstanceState(final Bundle outState) {
    outState.putLong(Extras.EXTRAS_THREAD_ID, threadId);
    outState.putString(Extras.EXTRAS_BOARD_NAME, boardName);
    outState.putString(Extras.EXTRAS_BOARD_TITLE, boardTitle);
    outState.putInt(Extras.LOADER_ID, loaderId);
    outState.putBoolean(Extras.EXTRAS_STICKY_AUTO_REFRESH, stickyAutoRefresh);

    if (postState != null) {
        outState.putBundle(Extras.EXTRAS_POST_STATE, postState);
    }

    super.onSaveInstanceState(outState);
}
 
Example 5
Source File: NavigatorLifecycleDelegate.java    From Mortar-architect with MIT License 5 votes vote down vote up
public void onSaveInstanceState(Bundle outState) {
    Preconditions.checkNotNull(outState, "SaveInstanceState bundle may not be null");
    Bundle bundle = navigator.history.toBundle();
    if (bundle != null) {
        outState.putBundle(HISTORY_KEY, bundle);
    }
}
 
Example 6
Source File: CordovaInterfaceImpl.java    From cordova-plugin-app-update-demo with MIT License 5 votes vote down vote up
/**
 * Saves parameters for startActivityForResult().
 */
public void onSaveInstanceState(Bundle outState) {
    if (activityResultCallback != null) {
        String serviceName = activityResultCallback.getServiceName();
        outState.putString("callbackService", serviceName);
    }
    if(pluginManager != null){
        outState.putBundle("plugin", pluginManager.onSaveInstanceState());
    }

}
 
Example 7
Source File: PreferenceFragment.java    From AndroidMaterialDialog with Apache License 2.0 5 votes vote down vote up
@Override
public final void onSaveInstanceState(final Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBundle(ALERT_DIALOG_STATE_EXTRA, alertDialog.onSaveInstanceState());
    outState.putBundle(LIST_DIALOG_STATE_EXTRA, listDialog.onSaveInstanceState());
    outState.putBundle(SINGLE_CHOICE_LIST_DIALOG_STATE_EXTRA,
            singleChoiceListDialog.onSaveInstanceState());
    outState.putBundle(MULTIPLE_CHOICE_LIST_DIALOG_STATE_EXTRA,
            multipleChoiceListDialog.onSaveInstanceState());
    outState.putBundle(CUSTOM_DIALOG_STATE_EXTRA, customDialog.onSaveInstanceState());
    outState.putBundle(PROGRESS_DIALOG_STATE_EXTRA, progressDialog.onSaveInstanceState());
    outState.putBundle(EDIT_TEXT_DIALOG_STATE_EXTRA, editTextDialog.onSaveInstanceState());
}
 
Example 8
Source File: PreferenceFragmentCompat.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    if (preferenceScreen != null) {
        Bundle container = new Bundle();
        preferenceScreen.saveHierarchyState(container);
        outState.putBundle(PREFERENCES_TAG, container);
    }
}
 
Example 9
Source File: CordovaInterfaceImpl.java    From xmall with MIT License 5 votes vote down vote up
/**
 * Saves parameters for startActivityForResult().
 */
public void onSaveInstanceState(Bundle outState) {
    if (activityResultCallback != null) {
        String serviceName = activityResultCallback.getServiceName();
        outState.putString("callbackService", serviceName);
    }
    if(pluginManager != null){
        outState.putBundle("plugin", pluginManager.onSaveInstanceState());
    }

}
 
Example 10
Source File: CustomTabsSession.java    From custom-tabs-client with Apache License 2.0 5 votes vote down vote up
/**
 * This sets the action button on the toolbar with ID
 * {@link CustomTabsIntent#TOOLBAR_ACTION_BUTTON_ID}.
 *
 * @param icon          The new icon of the action button.
 * @param description   Content description of the action button.
 *
 * @see CustomTabsSession#setToolbarItem(int, Bitmap, String)
 */
public boolean setActionButton(@NonNull Bitmap icon, @NonNull String description) {
    Bundle bundle = new Bundle();
    bundle.putParcelable(CustomTabsIntent.KEY_ICON, icon);
    bundle.putString(CustomTabsIntent.KEY_DESCRIPTION, description);

    Bundle metaBundle = new Bundle();
    metaBundle.putBundle(CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE, bundle);
    addIdToBundle(bundle);
    try {
        return mService.updateVisuals(mCallback, metaBundle);
    } catch (RemoteException e) {
        return false;
    }
}
 
Example 11
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void saveStateParams(Bundle bundle)
{
    if (currentParams != null)
    {
        bundle.putBundle("resetview_params", currentParams);
    }
}
 
Example 12
Source File: AppLinkData.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
private static Bundle toBundle(JSONObject node) throws JSONException {
    Bundle bundle = new Bundle();
    @SuppressWarnings("unchecked")
    Iterator<String> fields = node.keys();
    while (fields.hasNext()) {
        String key = fields.next();
        Object value;
        value = node.get(key);

        if (value instanceof JSONObject) {
            bundle.putBundle(key, toBundle((JSONObject) value));
        } else if (value instanceof JSONArray) {
            JSONArray valueArr = (JSONArray) value;
            if (valueArr.length() == 0) {
                bundle.putStringArray(key, new String[0]);
            } else {
                Object firstNode = valueArr.get(0);
                if (firstNode instanceof JSONObject) {
                    Bundle[] bundles = new Bundle[valueArr.length()];
                    for (int i = 0; i < valueArr.length(); i++) {
                        bundles[i] = toBundle(valueArr.getJSONObject(i));
                    }
                    bundle.putParcelableArray(key, bundles);
                } else if (firstNode instanceof JSONArray) {
                    // we don't support nested arrays
                    throw new FacebookException("Nested arrays are not supported.");
                } else { // just use the string value
                    String[] arrValues = new String[valueArr.length()];
                    for (int i = 0; i < valueArr.length(); i++) {
                        arrValues[i] = valueArr.get(i).toString();
                    }
                    bundle.putStringArray(key, arrValues);
                }
            }
        } else {
            bundle.putString(key, value.toString());
        }
    }
    return bundle;
}
 
Example 13
Source File: BundleMatchersTest.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Test
public void hasKeyWithMultipleEntries() {
  Bundle bundle = new Bundle();
  bundle.putDouble("key", 10000000);
  bundle.putDouble("key1", 10000001);
  bundle.putBundle("key2", new Bundle());

  assertTrue(hasKey("key2").matches(bundle));
  assertTrue(hasKey(equalTo("key2")).matches(bundle));
}
 
Example 14
Source File: ChildProcessLauncherHelper.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
public static Bundle createConnectionBundle(
        String[] commandLine, FileDescriptorInfo[] filesToBeMapped) {
    assert sLinkerInitialized;

    Bundle bundle = new Bundle();
    bundle.putStringArray(ChildProcessConstants.EXTRA_COMMAND_LINE, commandLine);
    bundle.putParcelableArray(ChildProcessConstants.EXTRA_FILES, filesToBeMapped);
    // content specific parameters.
    bundle.putInt(ChildProcessConstants.EXTRA_CPU_COUNT, CpuFeatures.getCount());
    bundle.putLong(ChildProcessConstants.EXTRA_CPU_FEATURES, CpuFeatures.getMask());
    bundle.putBundle(Linker.EXTRA_LINKER_SHARED_RELROS, Linker.getInstance().getSharedRelros());
    return bundle;
}
 
Example 15
Source File: Session.java    From KlyphMessenger with MIT License 5 votes vote down vote up
/**
 * Save the Session object into the supplied Bundle. This method is intended to be called from an
 * Activity or Fragment's onSaveInstanceState method in order to preserve Sessions across Activity lifecycle events.
 *
 * @param session the Session to save
 * @param bundle  the Bundle to save the Session to
 */
public static final void saveSession(Session session, Bundle bundle) {
    if (bundle != null && session != null && !bundle.containsKey(SESSION_BUNDLE_SAVE_KEY)) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        try {
            new ObjectOutputStream(outputStream).writeObject(session);
        } catch (IOException e) {
            throw new FacebookException("Unable to save session.", e);
        }
        bundle.putByteArray(SESSION_BUNDLE_SAVE_KEY, outputStream.toByteArray());
        bundle.putBundle(AUTH_BUNDLE_SAVE_KEY, session.authorizationBundle);
    }
}
 
Example 16
Source File: CordovaInterfaceImpl.java    From keemob with MIT License 5 votes vote down vote up
/**
 * Saves parameters for startActivityForResult().
 */
public void onSaveInstanceState(Bundle outState) {
    if (activityResultCallback != null) {
        String serviceName = activityResultCallback.getServiceName();
        outState.putString("callbackService", serviceName);
    }
    if(pluginManager != null){
        outState.putBundle("plugin", pluginManager.onSaveInstanceState());
    }

}
 
Example 17
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void saveStateParams(Bundle bundle)
{
    String code = codeField.getText().toString();
    if (code.length() != 0)
    {
        bundle.putString("passview_code", code);
    }
    if (currentParams != null)
    {
        bundle.putBundle("passview_params", currentParams);
    }
}
 
Example 18
Source File: MoreMediaEvent.java    From Melophile with Apache License 2.0 4 votes vote down vote up
public Bundle toBundle(){
    Bundle bundle=new Bundle();
    bundle.putBundle(Constants.EXTRA_DATA,data);
    bundle.putInt(Constants.EXTRA_CODE,code);
    return bundle;
}
 
Example 19
Source File: VoIPService.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@SuppressLint("MissingPermission")
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
	if(sharedInstance!=null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.e("Tried to start the VoIP service when it's already started");
           }
		return START_NOT_STICKY;
	}

	currentAccount=intent.getIntExtra("account", -1);
	if(currentAccount==-1)
		throw new IllegalStateException("No account specified when starting VoIP service");
	int userID=intent.getIntExtra("user_id", 0);
	isOutgoing = intent.getBooleanExtra("is_outgoing", false);
	user = MessagesController.getInstance(currentAccount).getUser(userID);

	if(user==null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.w("VoIPService: user==null");
           }
		stopSelf();
		return START_NOT_STICKY;
	}
	sharedInstance = this;

	if (isOutgoing) {
		dispatchStateChanged(STATE_REQUESTING);
		if(USE_CONNECTION_SERVICE){
			TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
			Bundle extras=new Bundle();
			Bundle myExtras=new Bundle();
			extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, addAccountToTelecomManager());
			myExtras.putInt("call_type", 1);
			extras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, myExtras);
			ContactsController.getInstance(currentAccount).createOrUpdateConnectionServiceContact(user.id, user.first_name, user.last_name);
			tm.placeCall(Uri.fromParts("tel", "+99084"+user.id, null), extras);
		}else{
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		if (intent.getBooleanExtra("start_incall_activity", false)) {
			startActivity(new Intent(this, VoIPActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
		}
	} else {
		NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeInCallActivity);
		call = callIShouldHavePutIntoIntent;
		callIShouldHavePutIntoIntent = null;
		if(USE_CONNECTION_SERVICE){
			acknowledgeCall(false);
			showNotification();
		}else{
			acknowledgeCall(true);
		}
	}
	initializeAccountRelatedThings();

	return START_NOT_STICKY;
}
 
Example 20
Source File: DeviceOrientationProfile.java    From DeviceConnect-Android with MIT License 2 votes vote down vote up
/**
 * センサー情報に加速度センサー情報を設定します.
 * 
 * @param orientation センサー情報
 * @param acceleration 加速度センサー情報
 */
public static void setAcceleration(final Bundle orientation, final Bundle acceleration) {
    orientation.putBundle(PARAM_ACCELERATION, acceleration);
}