android.os.Bundle.putBinder()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(663)

本文整理了Java中android.os.Bundle.putBinder()方法的一些代码示例,展示了Bundle.putBinder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.putBinder()方法的具体详情如下:
包路径:android.os.Bundle
类名称:Bundle
方法名:putBinder

Bundle.putBinder介绍

暂无

代码示例

代码示例来源:origin: ogaclejapan/SmartTabLayout

/**
 * Inserts an {@link android.os.IBinder} value into the mapping of this Bundle, replacing
 * any existing value for the given key.  Either key or value may be null.
 *
 * <p class="note">You should be very careful when using this function.  In many
 * places where Bundles are used (such as inside of Intent objects), the Bundle
 * can live longer inside of another process than the process that had originally
 * created it.  In that case, the IBinder you supply here will become invalid
 * when your process goes away, and no longer usable, even if a new process is
 * created for you later on.</p>
 *
 * @param key   a String, or null
 * @param value an IBinder object, or null
 */
@TargetApi(18)
public Bundler putBinder(String key, IBinder value) {
 bundle.putBinder(key, value);
 return this;
}

代码示例来源:origin: ogaclejapan/SmartTabLayout

/**
 * Inserts an {@link android.os.IBinder} value into the mapping of this Bundle, replacing
 * any existing value for the given key.  Either key or value may be null.
 *
 * <p class="note">You should be very careful when using this function.  In many
 * places where Bundles are used (such as inside of Intent objects), the Bundle
 * can live longer inside of another process than the process that had originally
 * created it.  In that case, the IBinder you supply here will become invalid
 * when your process goes away, and no longer usable, even if a new process is
 * created for you later on.</p>
 *
 * @param key   a String, or null
 * @param value an IBinder object, or null
 */
@TargetApi(18)
public Bundler putBinder(String key, IBinder value) {
 bundle.putBinder(key, value);
 return this;
}

代码示例来源:origin: android-hacker/VirtualXposed

public static void putBinder(Bundle bundle, String key, IBinder value) {
  if (Build.VERSION.SDK_INT >= 18) {
    bundle.putBinder(key, value);
  } else {
    mirror.android.os.Bundle.putIBinder.call(bundle, key, value);
  }
}

代码示例来源:origin: stackoverflow.com

final Object objSent = new Object();
 final Bundle bundle = new Bundle();
 bundle.putBinder("object_value", new ObjectWrapperForBinder(objSent));
 startActivity(new Intent(this, SecondActivity.class).putExtras(bundle));        
 Log.d(TAG, "original object=" + objSent);

代码示例来源:origin: stackoverflow.com

final IDataContract objSent = new IDataContract.Stub() {
   @Override
   public int func2(String arg1) throws RemoteException {
     // TODO Auto-generated method stub
     Log.d(TAG, "func2:: arg1=" + arg1);
     return 102;
   }
   @Override
   public int func1(String arg1) throws RemoteException {
     // TODO Auto-generated method stub
     Log.d(TAG, "func1:: arg1=" + arg1);
     return 101;
   }
 };
 final Bundle bundle = new Bundle();
 bundle.putBinder("object_value", objSent.asBinder());
 startActivity(new Intent(this, SecondActivity.class).putExtras(bundle));
 Log.d(TAG, "original object=" + objSent);

代码示例来源:origin: kayoSun/Tack

public static void putToBundle(@NonNull Bundle bundle, String key, @Nullable IBinder value) {
  bundle.putBinder(key, value);
}
public static void putSparseParcelableArrayToBundle(@NonNull Bundle bundle, String key,@Nullable  SparseArray<? extends Parcelable> value) {

代码示例来源:origin: 80945540/FreeBook

/**
 * Inserts an {@link android.os.IBinder} value into the mapping of this Bundle, replacing
 * any existing value for the given key.  Either key or value may be null.
 *
 * <p class="note">You should be very careful when using this function.  In many
 * places where Bundles are used (such as inside of Intent objects), the Bundle
 * can live longer inside of another process than the process that had originally
 * created it.  In that case, the IBinder you supply here will become invalid
 * when your process goes away, and no longer usable, even if a new process is
 * created for you later on.</p>
 *
 * @param key   a String, or null
 * @param value an IBinder object, or null
 */
@TargetApi(18)
public Bundler putBinder(String key, IBinder value) {
 bundle.putBinder(key, value);
 return this;
}

代码示例来源:origin: 80945540/LCRapidDevelop

/**
 * Inserts an {@link android.os.IBinder} value into the mapping of this Bundle, replacing
 * any existing value for the given key.  Either key or value may be null.
 *
 * <p class="note">You should be very careful when using this function.  In many
 * places where Bundles are used (such as inside of Intent objects), the Bundle
 * can live longer inside of another process than the process that had originally
 * created it.  In that case, the IBinder you supply here will become invalid
 * when your process goes away, and no longer usable, even if a new process is
 * created for you later on.</p>
 *
 * @param key   a String, or null
 * @param value an IBinder object, or null
 */
@TargetApi(18)
public Bundler putBinder(String key, IBinder value) {
 bundle.putBinder(key, value);
 return this;
}

代码示例来源:origin: stackoverflow.com

public static final String EXTRA_EXIT_ANIMATION_BUNDLE =
    "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";

public static final String EXTRA_SESSION = "android.support.customtabs.extra.SESSION";

public void openCustomTab() {
  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));

  Bundle bundle = ActivityOptions
      .makeCustomAnimation(
          this, android.R.anim.slide_in_left, android.R.anim.slide_out_right)
      .toBundle();

  Bundle extrasBundle = new Bundle();
  extrasBundle.putBinder(EXTRA_SESSION, null);
  intent.putExtras(extrasBundle);

  intent.putExtra(EXTRA_EXIT_ANIMATION_BUNDLE, bundle);
  startActivity(intent);
}

代码示例来源:origin: limpoxe/Android-ServiceManager

public static void putBinder(Bundle bundle, String key, IBinder iBinder) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    bundle.putBinder(key, iBinder);
  } else {
    RefIectUtil.invokeMethod(bundle, Bundle.class, "putIBinder", new Class[]{String.class, IBinder.class}, new Object[]{key, iBinder});
  }
}

代码示例来源:origin: bzsome/VirtualApp-x326

public static void putBinder(Bundle bundle, String key, IBinder value) {
  if (Build.VERSION.SDK_INT >= 18) {
    bundle.putBinder(key, value);
  } else {
    mirror.android.os.Bundle.putIBinder.call(bundle, key, value);
  }
}

代码示例来源:origin: LuckyJayce/EventBus-Apt

public static void putBinder(Bundle bundle, String key, IBinder binder) {
  if (Build.VERSION.SDK_INT >= 18) {
    bundle.putBinder(key, binder);
  } else {
    BundleCompatBaseImpl.putBinder(bundle, key, binder);
  }
}

代码示例来源:origin: darkskygit/VirtualApp

public static void putBinder(Bundle bundle, String key, IBinder value) {
  if (Build.VERSION.SDK_INT >= 18) {
    bundle.putBinder(key, value);
  } else {
    mirror.android.os.Bundle.putIBinder.call(bundle, key, value);
  }
}

代码示例来源:origin: crazyhitty/Munch

public void loadCustomChromeTabs(String url) {
  //ANDROID CHROME CUSTOM TABS IMPLEMENTATION
  // Using a VIEW intent for compatibility with any other browsers on device.
  // Caller should not be setting FLAG_ACTIVITY_NEW_TASK or
  // FLAG_ACTIVITY_NEW_DOCUMENT.
  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
  //  Must have. Extra used to match the session. Its value is an IBinder passed
  //  whilst creating a news session. See newSession() below. Even if the service is not
  //  used and there is no valid session id to be provided, this extra has to be present
  //  with a null value to launch a custom tab.
  //CustomTabsClient
  Bundle extras = new Bundle();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    extras.putBinder(EXTRA_CUSTOM_TABS_SESSION, null);
  }
  intent.putExtra(EXTRA_CUSTOM_TABS_TOOLBAR_COLOR, R.color.colorPrimary);
  intent.putExtras(extras);
  mContext.startActivity(intent);
}

代码示例来源:origin: PeterCxy/Shelter

private void startKiller() {
  // Start the sticky KillerService to kill the ShelterService
  // for us when we are removed from tasks
  // This is a dirty hack because no lifecycle events will be
  // called when task is removed from recents
  Intent intent = new Intent(this, KillerService.class);
  Bundle bundle = new Bundle();
  bundle.putBinder("main", mServiceMain.asBinder());
  bundle.putBinder("work", mServiceWork.asBinder());
  intent.putExtra("extra", bundle);
  startService(intent);
}

代码示例来源:origin: PeterCxy/Shelter

@Override
public void onServiceConnected(ComponentName name, IBinder service) {
  Intent data = new Intent();
  Bundle bundle = new Bundle();
  bundle.putBinder("service", service);
  data.putExtra("extra", bundle);
  setResult(RESULT_OK, data);
  finish();
}

代码示例来源:origin: PeterCxy/Shelter

static AppListFragment newInstance(IShelterService service, boolean isRemote) {
  AppListFragment fragment = new AppListFragment();
  Bundle args = new Bundle();
  args.putBinder("service", service.asBinder());
  args.putBoolean("is_remote", isRemote);
  fragment.setArguments(args);
  return fragment;
}

代码示例来源:origin: PeterCxy/Shelter

@Override
public void installApk(UriForwardProxy uriForwarder, IAppInstallCallback callback) {
  // Directly install an APK through a given Fd
  // instead of installing an existing one
  Intent intent = new Intent(DummyActivity.INSTALL_PACKAGE);
  intent.setComponent(new ComponentName(ShelterService.this, DummyActivity.class));
  // Generate a content Uri pointing to the Fd
  // DummyActivity is expected to release the Fd after finishing
  Uri uri = FileProviderProxy.setUriForwardProxy(uriForwarder, "apk");
  intent.putExtra("direct_install_apk", uri);
  // Send the callback to the DummyActivity
  Bundle callbackExtra = new Bundle();
  callbackExtra.putBinder("callback", callback.asBinder());
  intent.putExtra("callback", callbackExtra);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  DummyActivity.registerSameProcessRequest(intent);
  startActivity(intent);
}

代码示例来源:origin: PeterCxy/Shelter

@Override
public void uninstallApp(ApplicationInfoWrapper app, IAppInstallCallback callback) throws RemoteException {
  if (!app.isSystem()) {
    // Similarly, fire up DummyActivity to do uninstallation for us
    Intent intent = new Intent(DummyActivity.UNINSTALL_PACKAGE);
    intent.setComponent(new ComponentName(ShelterService.this, DummyActivity.class));
    intent.putExtra("package", app.getPackageName());
    // Send the callback to the DummyActivity
    Bundle callbackExtra = new Bundle();
    callbackExtra.putBinder("callback", callback.asBinder());
    intent.putExtra("callback", callbackExtra);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    DummyActivity.registerSameProcessRequest(intent);
    startActivity(intent);
  } else {
    if (mIsProfileOwner) {
      // This is essentially the same as disabling the system app
      // There is no way to reverse the "enableSystemApp" operation here
      mPolicyManager.setApplicationHidden(
          mAdminComponent,
          app.getPackageName(), true);
      callback.callback(Activity.RESULT_OK);
    } else {
      callback.callback(RESULT_CANNOT_INSTALL_SYSTEM_APP);
    }
  }
}

代码示例来源:origin: PeterCxy/Shelter

callbackExtra.putBinder("callback", callback.asBinder());
intent.putExtra("callback", callbackExtra);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

相关文章

Bundle类方法