android.os.Bundle#putBundle ( )源码实例Demo

下面列出了android.os.Bundle#putBundle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: media-samples   文件: SampleMediaRouteProvider.java
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);
}
 
源代码2 项目: TelePlus-Android   文件: LoginActivity.java
@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);
    }
}
 
源代码3 项目: Lucid-Browser   文件: MainActivity.java
/**
* 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);
       }
  }
 
源代码4 项目: custom-tabs-client   文件: CustomTabsSession.java
/**
 * 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;
    }
}
 
源代码5 项目: TelePlus-Android   文件: LoginActivity.java
@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);
    }
}
 
源代码6 项目: keemob   文件: CordovaInterfaceImpl.java
/**
 * 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());
    }

}
 
源代码7 项目: KlyphMessenger   文件: Session.java
/**
 * 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);
    }
}
 
源代码8 项目: 365browser   文件: ChildProcessLauncherHelper.java
@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;
}
 
源代码9 项目: android-test   文件: BundleMatchersTest.java
@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));
}
 
源代码10 项目: FacebookImageShareIntent   文件: AppLinkData.java
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;
}
 
源代码11 项目: TelePlus-Android   文件: LoginActivity.java
@Override
public void saveStateParams(Bundle bundle)
{
    if (currentParams != null)
    {
        bundle.putBundle("resetview_params", currentParams);
    }
}
 
源代码12 项目: mimi-reader   文件: ThreadDetailFragment.java
@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);
}
 
源代码13 项目: xmall   文件: CordovaInterfaceImpl.java
/**
 * 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());
    }

}
 
源代码14 项目: ticdesign   文件: PreferenceFragmentCompat.java
@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);
    }
}
 
源代码15 项目: AndroidMaterialDialog   文件: PreferenceFragment.java
@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());
}
 
/**
 * 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());
    }

}
 
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);
    }
}
 
源代码18 项目: Telegram   文件: VoIPService.java
@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;
}
 
源代码19 项目: Melophile   文件: MoreMediaEvent.java
public Bundle toBundle(){
    Bundle bundle=new Bundle();
    bundle.putBundle(Constants.EXTRA_DATA,data);
    bundle.putInt(Constants.EXTRA_CODE,code);
    return bundle;
}
 
/**
 * センサー情報に加速度センサー情報を設定します.
 * 
 * @param orientation センサー情報
 * @param acceleration 加速度センサー情報
 */
public static void setAcceleration(final Bundle orientation, final Bundle acceleration) {
    orientation.putBundle(PARAM_ACCELERATION, acceleration);
}