@Override public void onAttach(Context context) { super.onAttach(context); Activity activity = (Activity) context; repo = activity.getIntent().getParcelableExtra(EXTRA_REPOSITORY); }
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(); } }
@Override public Object getExtra(Object source, String key) { Intent intent = ((Activity) source).getIntent(); return intent == null ? null : Finder.BUNDLE.getExtra(intent.getExtras(), key); } },
/** * 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; }
@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); }
/** * 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); }
public DeepLinkResult dispatchFrom(Activity activity) { if (activity == null) { throw new NullPointerException("activity == null"); } return dispatchFrom(activity, activity.getIntent()); }
@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); }
/** * 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; }
Intent openIntent = activity.getIntent(); if (openIntent != null && !openIntent.getBooleanExtra(
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = getActivity(); mMediaModel = getActivity().getIntent().getParcelableExtra(MediaDetailsActivity.MEDIA); prepareBackgroundManager(); buildDetails(); }
@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); }
@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); }
Intent intent = activity.getIntent(); ApplicationInfo applicationInfo = baseContext.getApplicationInfo(); PackageManager pm = activity.getPackageManager();
@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); } } }
@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"); }
@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(); }
@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); }
extrasBundle.putString("com.facebook.orca.extra.METADATA", "{}"); extrasBundle.putString("com.facebook.orca.extra.PARTICIPANTS", "100,400,500"); when(mMockActivity.getIntent()).thenReturn(originalIntent);
VLog.e(TAG, "activity crashed when call onCreate, clearing", e); Intent intent = activity.getIntent(); callUiCallback(intent, false);