android.content.Intent.getBundleExtra()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(365)

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

Intent.getBundleExtra介绍

暂无

代码示例

代码示例来源:origin: Naoki2015/CircleDemo

public RecordResult(Intent intent) {
  _Bundle = intent.getBundleExtra(RESULT_KEY);
}

代码示例来源:origin: facebook/facebook-android-sdk

public static Bundle getMethodArgumentsFromIntent(Intent intent) {
  int version = getProtocolVersionFromIntent(intent);
  if (!isVersionCompatibleWithBucketedIntent(version)) {
    return intent.getExtras();
  }
  return intent.getBundleExtra(EXTRA_PROTOCOL_METHOD_ARGS);
}

代码示例来源:origin: facebook/facebook-android-sdk

@Override
  public void onReceive(Context context, Intent intent) {
    AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context);
    String eventName = BOLTS_MEASUREMENT_EVENT_PREFIX +
        intent.getStringExtra(MEASUREMENT_EVENT_NAME_KEY);
    Bundle eventArgs = intent.getBundleExtra(MEASUREMENT_EVENT_ARGS_KEY);
    Bundle logData = new Bundle();
    for(String key : eventArgs.keySet()) {
      String safeKey = key.replaceAll(
          "[^0-9a-zA-Z _-]", "-").replaceAll("^[ -]*", "").replaceAll("[ -]*$", "");
      logData.putString(safeKey, (String) eventArgs.get(key));
    }
    appEventsLogger.logEvent(eventName, logData);
  }
}

代码示例来源:origin: evernote/android-job

@Override
  public void onReceive(Context context, Intent intent) {
    if (intent != null && intent.hasExtra(EXTRA_JOB_ID) && intent.hasExtra(EXTRA_JOB_EXACT)) {
      int jobId = intent.getIntExtra(EXTRA_JOB_ID, -1);
      Bundle transientExtras = intent.getBundleExtra(EXTRA_TRANSIENT_EXTRAS);

      if (intent.getBooleanExtra(EXTRA_JOB_EXACT, false)) {
        Intent serviceIntent = PlatformAlarmServiceExact.createIntent(context, jobId, transientExtras);
        JobProxy.Common.startWakefulService(context, serviceIntent);
      } else {
        PlatformAlarmService.start(context, jobId, transientExtras);
      }
    }
  }
}

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

public static IUiCallback getUiCallback(Intent intent) {
  if (intent == null) {
    return null;
  }
  // only for launch intent.
  if (!Intent.ACTION_MAIN.equals(intent.getAction())) {
    return null;
  }
  try {
    Bundle bundle = intent.getBundleExtra("_VA_|_sender_");
    if (bundle != null) {
      IBinder uicallbackToken = BundleCompat.getBinder(bundle, "_VA_|_ui_callback_");
      return IUiCallback.Stub.asInterface(uicallbackToken);
    }
  } catch (Throwable ignored) {
  }
  return null;
}

代码示例来源:origin: pockethub/PocketHub

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Bundle appData = getActivity().getIntent().getBundleExtra(APP_DATA);
  if (appData != null) {
    repository = appData.getParcelable(EXTRA_REPOSITORY);
  }
}

代码示例来源:origin: facebook/facebook-android-sdk

public static Bundle getBridgeArgumentsFromIntent(Intent intent) {
  int version = getProtocolVersionFromIntent(intent);
  if (!isVersionCompatibleWithBucketedIntent(version)) {
    return null;
  }
  return intent.getBundleExtra(EXTRA_PROTOCOL_BRIDGE_ARGS);
}

代码示例来源:origin: facebook/facebook-android-sdk

public static UUID getCallIdFromIntent(Intent intent) {
  if (intent == null) {
    return null;
  }
  int version = getProtocolVersionFromIntent(intent);
  String callIdString = null;
  if (isVersionCompatibleWithBucketedIntent(version)) {
    Bundle bridgeArgs = intent.getBundleExtra(EXTRA_PROTOCOL_BRIDGE_ARGS);
    if (bridgeArgs != null) {
      callIdString = bridgeArgs.getString(BRIDGE_ARG_ACTION_ID_STRING);
    }
  } else {
    callIdString = intent.getStringExtra(EXTRA_PROTOCOL_CALL_ID);
  }
  UUID callId = null;
  if (callIdString != null) {
    try {
      callId = UUID.fromString(callIdString);
    } catch (IllegalArgumentException exception) {
    }
  }
  return callId;
}

代码示例来源:origin: evernote/android-job

/*package*/ static void runJob(@Nullable Intent intent, @NonNull Service service, @NonNull JobCat cat) {
    if (intent == null) {
      cat.i("Delivered intent is null");
      return;
    }

    int jobId = intent.getIntExtra(PlatformAlarmReceiver.EXTRA_JOB_ID, -1);
    Bundle transientExtras = intent.getBundleExtra(PlatformAlarmReceiver.EXTRA_TRANSIENT_EXTRAS);
    final JobProxy.Common common = new JobProxy.Common(service, cat, jobId);

    // create the JobManager. Seeing sometimes exceptions, that it wasn't created, yet.
    final JobRequest request = common.getPendingRequest(true, true);
    if (request != null) {
      common.executeJobRequest(request, transientExtras);
    }
  }
}

代码示例来源:origin: seven332/EhViewer

/**
 * @return {@code true} for start scene
 */
private boolean startSceneFromIntent(Intent intent) {
  String clazzStr = intent.getStringExtra(KEY_SCENE_NAME);
  if (null == clazzStr) {
    return false;
  }
  Class clazz;
  try {
    clazz = Class.forName(clazzStr);
  } catch (ClassNotFoundException e) {
    Log.e(TAG, "Can't find class " + clazzStr, e);
    return false;
  }
  Bundle args = intent.getBundleExtra(KEY_SCENE_ARGS);
  Announcer announcer = onStartSceneFromIntent(clazz, args);
  if (announcer == null) {
    return false;
  }
  startScene(announcer);
  return true;
}

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

private void startChooseAccountTypeActivity() {
  VLog.v(TAG, "ChooseAccountTypeActivity.startChooseAccountTypeActivity()");
  final Intent intent = new Intent(this, ChooseAccountTypeActivity.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
  intent.putExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY,
      getIntent().getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY));
  intent.putExtra(EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE,
      getIntent().getBundleExtra(EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE));
  intent.putExtra(EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY,
      getIntent().getStringArrayExtra(EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY));
  intent.putExtra(EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING,
      getIntent().getStringExtra(EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING));
  startActivityForResult(intent, REQUEST_CHOOSE_TYPE);
  mPendingRequest = REQUEST_CHOOSE_TYPE;
}

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

protected void runAddAccountForAuthenticator(String type) {
  if (Log.isLoggable(TAG, Log.VERBOSE)) {
    Log.v(TAG, "runAddAccountForAuthenticator: " + type);
  }
  final Bundle options = getIntent().getBundleExtra(
      ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE);
  final String[] requiredFeatures = getIntent().getStringArrayExtra(
      ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY);
  final String authTokenType = getIntent().getStringExtra(
      ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING);
  VAccountManager.get().addAccount(mCallingUserId, type, authTokenType, requiredFeatures,
      options, null /* activity */, this /* callback */, null /* Handler */);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testBundleExtra() throws Exception {
 Intent intent = new Intent();
 Bundle bundle = new Bundle();
 bundle.putInt("bar", 5);
 assertSame(intent, intent.putExtra("foo", bundle));
 assertEquals(5, intent.getBundleExtra("foo").getInt("bar"));
}

代码示例来源:origin: iMeiji/Toutiao

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_settings);
  String initFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
  Bundle initArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
  String initTitle = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE);
  if (TextUtils.isEmpty(initFragment)) {
    setupFragment(GeneralPreferenceFragment.class.getName(), initArguments);
  } else {
    setupFragment(initFragment, initArguments);
  }
  Toolbar toolbar = findViewById(R.id.toolbar);
  initToolBar(toolbar, true, TextUtils.isEmpty(initTitle) ? getString(R.string.title_settings) : initTitle);
}

代码示例来源:origin: facebook/facebook-android-sdk

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if (savedInstanceState != null) {
    loginClient = savedInstanceState.getParcelable(SAVED_LOGIN_CLIENT);
    loginClient.setFragment(this);
  } else {
    loginClient = createLoginClient();
  }
  loginClient.setOnCompletedListener(new LoginClient.OnCompletedListener() {
    @Override
    public void onCompleted(LoginClient.Result outcome) {
      onLoginClientCompleted(outcome);
    }
  });
  Activity activity = getActivity();
  if (activity == null) {
    return;
  }
  initializeCallingPackage(activity);
  Intent intent = activity.getIntent();
  if (intent != null) {
    Bundle bundle = intent.getBundleExtra(REQUEST_KEY);
    if (bundle != null) {
      request = bundle.getParcelable(EXTRA_REQUEST);
    }
  }
}

代码示例来源:origin: zhihu/Matisse

Bundle resultBundle = data.getBundleExtra(BasePreviewActivity.EXTRA_RESULT_BUNDLE);
ArrayList<Item> selected = resultBundle.getParcelableArrayList(SelectedItemCollection.STATE_SELECTION);
mOriginalEnable = data.getBooleanExtra(BasePreviewActivity.EXTRA_RESULT_ORIGINAL_ENABLE, false);

代码示例来源:origin: facebook/facebook-android-sdk

Bundle parameters = getIntent().getBundleExtra(EXTRA_PARAMS);
String chromePackage = getIntent().getStringExtra(EXTRA_CHROME_PACKAGE);

代码示例来源:origin: pockethub/PocketHub

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_issue_search);
  ActionBar actionBar = getSupportActionBar();
  Bundle appData = getIntent().getBundleExtra(APP_DATA);
  if (appData != null) {
    repository = appData.getParcelable(EXTRA_REPOSITORY);
    if (repository != null) {
      actionBar.setSubtitle(InfoUtils.createRepoId(repository));
      actionBar.setDisplayHomeAsUpEnabled(true);
      avatars.bind(actionBar, repository.owner());
    }
  }
  issueFragment = (SearchIssueListFragment) getSupportFragmentManager()
    .findFragmentById(android.R.id.list);
  handleIntent(getIntent());
}

代码示例来源:origin: zhihu/Matisse

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if (!SelectionSpec.getInstance().hasInited) {
    setResult(RESULT_CANCELED);
    finish();
    return;
  }
  Bundle bundle = getIntent().getBundleExtra(EXTRA_DEFAULT_BUNDLE);
  List<Item> selected = bundle.getParcelableArrayList(SelectedItemCollection.STATE_SELECTION);
  mAdapter.addAll(selected);
  mAdapter.notifyDataSetChanged();
  if (mSpec.countable) {
    mCheckView.setCheckedNum(1);
  } else {
    mCheckView.setChecked(true);
  }
  mPreviousPos = 0;
  updateSize(selected.get(0));
}

代码示例来源:origin: facebook/facebook-android-sdk

@Override
  public boolean matches(Object argument) {
    Intent orig = (Intent)argument;
    Bundle bundle = orig.getBundleExtra(LoginFragment.REQUEST_KEY);
    LoginClient.Request request =
        (LoginClient.Request)bundle.getParcelable(LoginFragment.EXTRA_REQUEST);
    assertEquals(MOCK_APP_ID, request.getApplicationId());
    assertEquals(LoginBehavior.NATIVE_ONLY, request.getLoginBehavior());
    assertEquals(DefaultAudience.EVERYONE, request.getDefaultAudience());
    Set<String> permissions = request.getPermissions();
    for (String permission : expectedPermissions) {
      assertTrue(permissions.contains(permission));
    }
    return true;
  }
};

相关文章

Intent类方法