android.app.Activity.getIntent()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(300)

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

Activity.getIntent介绍

暂无

代码示例

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

@Override
public void onAttach(Context context) {
  super.onAttach(context);
  Activity activity = (Activity) context;
  repo = activity.getIntent().getParcelableExtra(EXTRA_REPOSITORY);
}

代码示例来源:origin: MatthiasRobbers/shortbread

private static void callMethodShortcut(@NonNull Activity activity) {
  if (callMethodShortcut == null || !activity.getIntent().hasExtra("shortbread_method")) {
    return;
  }
  //noinspection TryWithIdenticalCatches
  try {
    callMethodShortcut.invoke(generated, activity);
  } catch (IllegalAccessException e) {
    e.printStackTrace();
  } catch (InvocationTargetException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: f2prateek/dart

@Override
 public Object getExtra(Object source, String key) {
  Intent intent = ((Activity) source).getIntent();
  return intent == null ? null : Finder.BUNDLE.getExtra(intent.getExtras(), key);
 }
},

代码示例来源:origin: nickbutcher/plaid

/**
 * Create a {@link FabTransform} from the supplied {@code activity} extras and set as its
 * shared element enter/return transition.
 */
public static boolean setup(@NonNull Activity activity, @Nullable View target) {
  final Intent intent = activity.getIntent();
  if (!intent.hasExtra(EXTRA_FAB_COLOR) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) {
    return false;
  }
  final int color = intent.getIntExtra(EXTRA_FAB_COLOR, Color.TRANSPARENT);
  final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1);
  final FabTransform sharedEnter = new FabTransform(color, icon);
  if (target != null) {
    sharedEnter.addTarget(target);
  }
  activity.getWindow().setSharedElementEnterTransition(sharedEnter);
  return true;
}

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

@Override
public void onAttach(Context context) {
  super.onAttach(context);
  Activity activity = (Activity) context;
  repository = activity.getIntent().getParcelableExtra(EXTRA_REPOSITORY);
  base = getStringExtra(EXTRA_BASE).substring(0, 7);
  head = getStringExtra(EXTRA_HEAD).substring(0, 7);
}

代码示例来源:origin: nickbutcher/plaid

/**
 * Configure {@link MorphTransform}s & set as {@code activity}'s shared element enter and return
 * transitions.
 */
public static void setup(@NonNull Activity activity,
             @Nullable View target,
             @ColorInt int endColor,
             int endCornerRadius) {
  final Intent intent = activity.getIntent();
  if (intent == null
      || !intent.hasExtra(EXTRA_SHARED_ELEMENT_START_COLOR)
      || !intent.hasExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS)) return;
  final int startColor = activity.getIntent().
      getIntExtra(EXTRA_SHARED_ELEMENT_START_COLOR, Color.TRANSPARENT);
  final int startCornerRadius =
      intent.getIntExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, 0);
  final MorphTransform sharedEnter =
      new MorphTransform(startColor, endColor, startCornerRadius, endCornerRadius);
  // Reverse the start/end params for the return transition
  final MorphTransform sharedReturn =
      new MorphTransform(endColor, startColor, endCornerRadius, startCornerRadius);
  if (target != null) {
    sharedEnter.addTarget(target);
    sharedReturn.addTarget(target);
  }
  activity.getWindow().setSharedElementEnterTransition(sharedEnter);
  activity.getWindow().setSharedElementReturnTransition(sharedReturn);
}

代码示例来源:origin: airbnb/DeepLinkDispatch

public DeepLinkResult dispatchFrom(Activity activity) {
 if (activity == null) {
  throw new NullPointerException("activity == null");
 }
 return dispatchFrom(activity, activity.getIntent());
}

代码示例来源:origin: nanchen2251/RxJava2Examples

@Override
public void subscribe() {
  mActivity = mWebView.getWebViewContext();
  Intent intent = mActivity.getIntent();
  mWebView.setGankTitle(intent.getStringExtra(WebViewActivity.GANK_TITLE));
  mWebView.initWebView();
  mGankUrl = intent.getStringExtra(WebViewActivity.GANK_URL);
  mWebView.loadGankUrl(mGankUrl);
}

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

/**
 * Parses out any app link data from the Intent of the Activity passed in.
 * @param activity Activity that was started because of an app link
 * @return AppLinkData if found. null if not.
 */
public static AppLinkData createFromActivity(Activity activity) {
  Validate.notNull(activity, "activity");
  Intent intent = activity.getIntent();
  if (intent == null) {
    return null;
  }
  AppLinkData appLinkData = createFromAlApplinkData(intent);
  if (appLinkData == null) {
    String appLinkArgsJsonString = intent.getStringExtra(BUNDLE_APPLINK_ARGS_KEY);
    appLinkData = createFromJson(appLinkArgsJsonString);
  }
  if (appLinkData == null) {
    // Try regular app linking
    appLinkData = createFromUri(intent.getData());
  }
  return appLinkData;
}

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

Intent openIntent = activity.getIntent();
if (openIntent != null
  && !openIntent.getBooleanExtra(

代码示例来源:origin: JackyAndroid/AndroidTVLauncher

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  mContext = getActivity();
  mMediaModel = getActivity().getIntent().getParcelableExtra(MediaDetailsActivity.MEDIA);
  prepareBackgroundManager();
  buildDetails();
}

代码示例来源:origin: JessYanCoding/MVPArms

@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
  //如果 intent 包含了此字段,并且为 true 说明不加入到 list 进行统一管理
  boolean isNotAdd = false;
  if (activity.getIntent() != null)
    isNotAdd = activity.getIntent().getBooleanExtra(AppManager.IS_NOT_ADD_ACTIVITY_LIST, false);
  if (!isNotAdd)
    mAppManager.addActivity(activity);
  //配置ActivityDelegate
  if (activity instanceof IActivity) {
    ActivityDelegate activityDelegate = fetchActivityDelegate(activity);
    if (activityDelegate == null) {
      Cache<String, Object> cache = getCacheFromActivity((IActivity) activity);
      activityDelegate = new ActivityDelegateImpl(activity);
      //使用 IntelligentCache.KEY_KEEP 作为 key 的前缀, 可以使储存的数据永久存储在内存中
      //否则存储在 LRU 算法的存储空间中, 前提是 Activity 使用的是 IntelligentCache (框架默认使用)
      cache.put(IntelligentCache.getKeyOfKeep(ActivityDelegate.ACTIVITY_DELEGATE), activityDelegate);
    }
    activityDelegate.onCreate(savedInstanceState);
  }
  registerFragmentCallbacks(activity);
}

代码示例来源:origin: MatthiasRobbers/shortbread

@Before
public void setUp() {
  Shortbread.shortcutsSet = false;
  Shortbread.activityLifecycleCallbacksSet = false;
  MockitoAnnotations.initMocks(this);
  when(activity.getApplicationContext()).thenReturn(application);
  when(application.getApplicationContext()).thenReturn(application);
  when(application.getSystemService(ShortcutManager.class)).thenReturn(shortcutManager);
  when(activity.getIntent()).thenReturn(intent);
}

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

Intent intent = activity.getIntent();
ApplicationInfo applicationInfo = baseContext.getApplicationInfo();
PackageManager pm = activity.getPackageManager();

代码示例来源: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: robolectric/robolectric

@Test
public void withIntent() {
 final LoginFragment fragment = new LoginFragment();
 Intent intent = new Intent("test_action");
 intent.putExtra("test_key", "test_value");
 FragmentController<LoginFragment> controller = FragmentController.of(fragment, LoginActivity.class, intent).create();
 Intent intentInFragment = controller.get().getActivity().getIntent();
 assertThat(intentInFragment.getAction()).isEqualTo("test_action");
 assertThat(intentInFragment.getExtras().getString("test_key")).isEqualTo("test_value");
}

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

@Test
public void testFinishShareToMessengerWithUnexpectedIntent() throws Exception {
 // Simulate an intent that Messenger would send.
 Intent originalIntent = new Intent();
 when(mMockActivity.getIntent()).thenReturn(originalIntent);
 // Setup the data the app will send back to messenger.
 Uri uri = Uri.parse("file:///foo.jpeg");
 Uri externalUri = Uri.parse("http://example.com/foo.jpeg");
 ShareToMessengerParams params = ShareToMessengerParams
   .newBuilder(uri, "image/jpeg")
   .setMetaData("{}")
   .setExternalUri(externalUri)
   .build();
 // Call finishShareToMessenger and verify the results.
 MessengerUtils.finishShareToMessenger(mMockActivity, params);
 verify(mMockActivity).setResult(Activity.RESULT_CANCELED, null);
 verify(mMockActivity).finish();
}

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

@Override
public void callActivityOnResume(Activity activity) {
  VirtualCore.get().getComponentDelegate().beforeActivityResume(activity);
  VActivityManager.get().onActivityResumed(activity);
  super.callActivityOnResume(activity);
  VirtualCore.get().getComponentDelegate().afterActivityResume(activity);
  Intent intent = activity.getIntent();
  callUiCallback(intent, true);
}

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

extrasBundle.putString("com.facebook.orca.extra.METADATA", "{}");
extrasBundle.putString("com.facebook.orca.extra.PARTICIPANTS", "100,400,500");
when(mMockActivity.getIntent()).thenReturn(originalIntent);

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

VLog.e(TAG, "activity crashed when call onCreate, clearing", e);
Intent intent = activity.getIntent();
callUiCallback(intent, false);

相关文章

Activity类方法