public static void handleActivityStack(ActivityInfo info, Intent intent) { // Handle launchMode with singleTop, and flag with FLAG_ACTIVITY_SINGLE_TOP int launchMode = info.launchMode; int flag = intent.getFlags(); String launchActivityName = info.name; String prevActivityName = null; List<WeakReference<Activity>> activityList = ActivityTaskMgr.getInstance().getActivityList(); if (activityList.size() > 0) { Activity lastActivity = activityList.get(activityList.size() - 1).get(); prevActivityName = lastActivity.getClass().getName(); } if (StringUtils.equals(prevActivityName, launchActivityName) && (launchMode == ActivityInfo.LAUNCH_SINGLE_TOP || (flag & Intent.FLAG_ACTIVITY_SINGLE_TOP) == Intent.FLAG_ACTIVITY_SINGLE_TOP)) { intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); } else if (launchMode == ActivityInfo.LAUNCH_SINGLE_TASK || launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE || (flag & Intent.FLAG_ACTIVITY_CLEAR_TOP) == Intent.FLAG_ACTIVITY_CLEAR_TOP) { int i; boolean isExist = false; for (i = 0; i < activityList.size(); i++) { WeakReference<Activity> ref = activityList.get(i); if (ref!=null && ref.get()!=null && ref.get().getClass().getName().equals(launchActivityName)) { isExist = true; break; } } if (isExist) { for (WeakReference<Activity> act : activityList.subList(i + 1, activityList.size())) { if(act!=null && act.get()!=null) { act.get().finish(); } } activityList.subList(i + 1, activityList.size()).clear(); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); } } }
public void exitFullscreen(){ if(fullscreenPlayer!=null) { this.showHeaderBar(); this.seekTo(fullscreenPlayer.getCurrentPosition()); if(this.isPlaying){ Log.d("xxxxxx","fullscreen played"+fullscreenPlayer.getCurrentPosition()); this.start(); } maskLayout.removeView(fullscreenPlayer); viewGroup.removeView(maskLayout.findViewById(R.id.maskLayer)); // maskLayout.setBackgroundColor(0xffffffff); // LayoutInflater.from(mThemedReactContext).inflate(lastLayout,viewGroup); fullscreenPlayer = null; maskLayout = null; mThemedReactContext.getCurrentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } }
@Override public void perform(UiController uiController, View view) { uiController.loopMainThreadUntilIdle(); int orientation = getActivityOrientation(view); boolean checkOrientation = false; switch (orientationType) { case PORTRAIT: checkOrientation = orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT; break; case LANDSCAPE: checkOrientation = orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE; break; } if (checkOrientation) { isOrientation[0] = true; } }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); //如果旋转了就全屏 if (mIsPlay && !mIsPause) { if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_USER) { if (!mPlayer.isIfCurrentIsFullscreen()) { mPlayer.startWindowFullscreen(MovieDetailActivity.this, true, true); } } else { //新版本isIfCurrentIsFullscreen的标志位内部提前设置了,所以不会和手动点击冲突 if (mPlayer.isIfCurrentIsFullscreen()) { StandardGSYVideoPlayer.backFromWindowFull(this); } if (mOrientationUtils != null) { mOrientationUtils.setEnable(true); } } } }
public static void processActivityIntentIfNeed(Object activityclientrecord) { try { Class ActivityClientRecord_Class = Class.forName("android.app.ActivityThread$ActivityClientRecord"); Field intent_Field = ActivityClientRecord_Class.getDeclaredField("intent"); intent_Field.setAccessible(true); Intent intent = (Intent) intent_Field.get(activityclientrecord); if (intent.getComponent() != null && intent.getComponent().getClassName().startsWith(String.format("%s%s",BridgeUtil.COMPONENT_PACKAGE,BridgeUtil.PROXY_PREFIX))){ Field activityInfo_Field = ActivityClientRecord_Class.getDeclaredField("activityInfo"); activityInfo_Field.setAccessible(true); Intent originalIntent = unWrapperOriginalIntent(intent); ActivityInfo info = AdditionalPackageManager.getInstance().getNewComponentInfo(originalIntent.getComponent(),ActivityInfo.class); activityInfo_Field.set(activityclientrecord, info); intent_Field.set(activityclientrecord,originalIntent); } } catch (Throwable e) { e.printStackTrace(); } }
/** * Initialize activity, set up layout and UI. * @param savedInstanceState If activity is re-initialized then this contains data it supplied to onSaveInstanceState, otherwise null. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_result); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); ImageButton imageBtn = (ImageButton) findViewById(R.id.launchCameraButton); imageBtn.setImageResource(R.drawable.camera_button); // because of activity lifecycles... if (savedInstanceState == null) { // FIXME: Doesn't seem to be able to update UI in this state sendRequestFromIntent(getIntent()); } TextView view = (TextView) findViewById(R.id.resultTextView); view.setText("Waiting for data..."); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.view_login); _logger = new Logger(TAG); _logger.Debug("onCreate"); _context = this; _bCrypter = new BCrypter(); _navigationController = new NavigationController(_context); _sharedPrefController = new SharedPrefController(_context, SharedPref.NAME); initializeViews(); if (!_sharedPrefController.LoadBooleanValueFromSharedPreferences(SharedPref.ENTERED_APPLICATION_PASSWORD)) { new PasswordSafeDialogController(_context).ShowDialogFirstLogin(new SavePasswordRunnable(_sharedPrefController)); } }
/** * Obtain an {@link Intent} that will launch an explicit target activity specified by * this activity's logical parent. The logical parent is named in the application's manifest * by the {@link android.R.attr#parentActivityName parentActivityName} attribute. * Activity subclasses may override this method to modify the Intent returned by * super.getParentActivityIntent() or to implement a different mechanism of retrieving * the parent intent entirely. * * @return a new Intent targeting the defined parent of this activity or null if * there is no valid parent. */ @Nullable public Intent getParentActivityIntent() { final String parentName = mActivityInfo.parentActivityName; if (TextUtils.isEmpty(parentName)) { return null; } // If the parent itself has no parent, generate a main activity intent. final ComponentName target = new ComponentName(this, parentName); try { final ActivityInfo parentInfo = getPackageManager().getActivityInfo(target, 0); final String parentActivity = parentInfo.parentActivityName; final Intent parentIntent = parentActivity == null ? Intent.makeMainActivity(target) : new Intent().setComponent(target); return parentIntent; } catch (NameNotFoundException e) { Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName + "' in manifest"); return null; } }
@Override public void onVerticalClickFullScreen() { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Display display = getWindow().getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); int heightPixels = metrics.heightPixels; int widthPixels = metrics.widthPixels; ViewGroup.LayoutParams params = mSurfaceView.getLayoutParams(); int height = params.height; int width = params.width; getWindow().getDecorView().setSystemUiVisibility(View.INVISIBLE); mPortWidth = width; mPortHeight = height; params.width = widthPixels; params.height = heightPixels; mSurfaceView.setLayoutParams(params); }
public AppAdapter(Context context, ActivityInfo[] infoArray, ActivityInfo store) { final List<App> apps = new ArrayList<>(infoArray.length); for (ActivityInfo info : infoArray) { apps.add(new App(context, info)); } Collections.sort(apps, new Comparator<App>() { @Override public int compare(App app1, App app2) { return app1.getLabel().compareTo(app2.getLabel()); } }); this.apps = apps; this.store = store != null ? new App(context, store) : null; }
public void lockOrientation(Activity activity, String orientation, ModuleResultListener listener){ if (activity == null || listener == null) return; if (orientation.equals(ANY)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } else if (orientation.equals(LANDSCAPE_PRIMARY)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (orientation.equals(PORTRAIT_PRIMARY)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientation.equals(LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else if (orientation.equals(PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } else if (orientation.equals(LANDSCAPE_SECONDARY)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else if (orientation.equals(PORTRAIT_SECONDARY)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } getOrientation(listener); }
@Override public void onHideCustomView() { LogUtils.i("Info", "onHideCustomView:" + moiveView); if (moiveView == null) return; if (mActivity!=null&&mActivity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); moiveView.setVisibility(View.GONE); if (moiveParentView != null && moiveView != null) { moiveParentView.removeView(moiveView); } if (moiveParentView != null) moiveParentView.setVisibility(View.GONE); if(this.mCallback!=null) mCallback.onCustomViewHidden(); this.moiveView = null; if (mWebView != null) mWebView.setVisibility(View.VISIBLE); }
public ActivityInfo resolveActivityInfo(Intent intent, int flags) throws RemoteException { try { if (this.mApkManager == null) { return null; } if (intent.getComponent() != null) { return this.mApkManager.getActivityInfo(intent.getComponent(), flags); } ResolveInfo resolveInfo = this.mApkManager.resolveIntent(intent, intent.resolveTypeIfNeeded(this.mHostContext.getContentResolver()), flags); if (resolveInfo == null || resolveInfo.activityInfo == null) { return null; } return resolveInfo.activityInfo; } catch (RemoteException e) { JLog.log("wuxinrong", "获取ActivityInfo 失败 e=" + e.getMessage()); throw e; } catch (Exception e2) { JLog.log("wuxinrong", "获取ActivityInfo 失败 e=" + e2.getMessage()); return null; } }
/** * 通过知乎Matisse类库 打开相册 * * @param fragment */ public void openGalleryByMatisse(Fragment fragment) { if (fragment == null) { return; } int count = mPhotoLimitCount - mSelectPhotoAdapter.getBodyCount(); Matisse.from(fragment) .choose(MimeType.allOf()) .theme(R.style.Matisse_Zhihu) .capture(true) .captureStrategy(new CaptureStrategy(true, AUTHORITY)) .countable(true) .maxSelectable(count) .gridExpectedSize(dip2px(120)) .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) .thumbnailScale(0.85f) .imageEngine(new PicassoEngine()) .forResult(mRequestCode); }
@Test public void fullscreen_disabledOnPortrait() throws Throwable { rule.runOnUiThread(new Runnable() { @Override public void run() { rule.getActivity() .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } }); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); rule.runOnUiThread(new Runnable() { @Override public void run() { final View decorView = rule.getActivity().getWindow().getDecorView(); assertThat(decorView.getSystemUiVisibility(), not(hasFlag(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN))); } }); }
@SuppressWarnings("WrongConstant") private void installApp(@NonNull String packageName, int versionCode, @NonNull Signature signature) { final ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.activityInfo = new ActivityInfo(); resolveInfo.activityInfo.packageName = packageName; banklinkActivities.add(resolveInfo); final PackageInfo packageInfo = new PackageInfo(); packageInfo.versionCode = versionCode; packageInfo.packageName = packageName; packageInfo.signatures = new Signature[1]; packageInfo.signatures[0] = signature; try { when(context.getPackageManager().getPackageInfo(eq(packageName), anyInt())) .thenReturn(packageInfo); } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException(e); } }
/** * Set a fixed orientation for the app * * @param orientation Fixed screen orientation */ public void setActivityOrientationFixed(ScreenOrientation orientation) { switch (orientation) { case LANDSCAPE: default: setActivityOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case PORTRAIT: setActivityOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; case LANDSCAPE_REVERSE: setActivityOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); break; case PORTRAIT_REVERSE: setActivityOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); break; } }
/** * Called by the {@link android.app.Activity#onPostCreate(Bundle)} to update * the state of the container screen. */ public void syncScreenState() { int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; int navigationBarColor = -1; if (currentFragment instanceof FlowrFragment) { screenOrientation = ((FlowrFragment) currentFragment).getScreenOrientation(); navigationBarColor = ((FlowrFragment) currentFragment).getNavigationBarColor(); } if (screen != null) { screen.onCurrentFragmentChanged(getCurrentFragment()); screen.setScreenOrientation(screenOrientation); screen.setNavigationBarColor(navigationBarColor); } syncToolbarState(); syncDrawerState(); }
public void onActivityCreated(ActivityInfo stubInfo, ActivityInfo targetInfo) throws RemoteException { try { if (this.mApkManager != null) { this.mApkManager.onActivityCreated(stubInfo, targetInfo); } } catch (RemoteException e) { JLog.log("wuxinrong", "activity启动回调ActivityManagerService.onActivityCreated 失败 e=" + e.getMessage()); throw e; } catch (Exception e2) { JLog.log("wuxinrong", "activity启动回调ActivityManagerService.onActivityCreated 失败 e=" + e2.getMessage()); } }
/** * Change the desired orientation of this activity. If the activity * is currently in the foreground or otherwise impacting the screen * orientation, the screen will immediately be changed (possibly causing * the activity to be restarted). Otherwise, this will be used the next * time the activity is visible. * * @param requestedOrientation An orientation constant as used in * {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}. */ public void setRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation) { if (mParent == null) { try { ActivityManagerNative.getDefault().setRequestedOrientation( mToken, requestedOrientation); } catch (RemoteException e) { // Empty } } else { mParent.setRequestedOrientation(requestedOrientation); } }
private void updateFullScreenButton() { if (getScreenOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { $.id(R.id.app_video_fullscreen).image(R.drawable.ic_fullscreen_exit_white_36dp); } else { $.id(R.id.app_video_fullscreen).image(R.drawable.ic_fullscreen_white_24dp); } }
private void performScheduleReceiver(IVClient client, int vuid, ActivityInfo info, Intent intent, PendingResultData result) { ComponentName componentName = ComponentUtils.toComponentName(info); BroadcastSystem.get().broadcastSent(vuid, info, result); try { client.scheduleReceiver(info.processName, componentName, intent, result); } catch (Throwable e) { if (result != null) { result.finish(); } } }
private static ComponentName selectProxyActivity(Intent intent) { if (intent != null) { try { ActivityInfo proxyInfo = ApkManager.getInstance().selectStubActivityInfo(intent); if (proxyInfo != null) { return new ComponentName(proxyInfo.packageName, proxyInfo.name); } } catch (Exception e) { e.printStackTrace(); } } return null; }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) public void lockScreenOrientation() { if (mRotationEnabled) { if (Utilities.ATLEAST_JB_MR2) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); } else { setRequestedOrientation(mapConfigurationOriActivityInfoOri(getResources() .getConfiguration().orientation)); } } }
@Override public void onResume() { super.onResume(); if (getResources().getConfiguration().orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) { Log.d(LOG_TAG, "Orientations is reverse portrait"); } Log.d(LOG_TAG, "Current orientation: " + getResources().getConfiguration().orientation); }
@Override protected void onResume() { if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } super.onResume(); }
public boolean isActivityEnabledForProfile(ComponentName component, UserHandleCompat user) { try { ActivityInfo info = mPm.getActivityInfo(component, 0); return info != null && info.isEnabled(); } catch (NameNotFoundException e) { return false; } }
@Override protected Boolean doInBackground(Void... voids) { ActivityInfo info = getReceiverName(mPackageName, getActivity().getPackageManager()); if (info == null) return false; return ShellUtils.exec("pm enable " + info.packageName + "/" + info.name); }
/** * 竖屏 */ protected void onOrientationPortrait(Activity activity) { if (isLockFullScreen || !mAutoRotate || currentOrientation == PORTRAIT) return; if ((currentOrientation == LANDSCAPE || currentOrientation == REVERSE_LANDSCAPE) && !isFullScreen()) { currentOrientation = PORTRAIT; return; } currentOrientation = PORTRAIT; activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); stopFullScreen(); }
@Override protected void onResume() { super.onResume(); webView.onResume(); // 支付宝网页版在打开文章详情之后,无法点击按钮下一步 webView.resumeTimers(); // 设置为横屏 if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } }
private void fullSreeen(){ isFull = true; fullListener.setFull(); log.i("lock4", isFull + "," + isShowing); $.id(R.id.app_video_box).heightandwidth(mWidthPixels, mHeightPixels, false); if (mIsLock){ orientationEventListener.disable(); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } if (isShowing) { handler.sendEmptyMessage(MESSAGE_SHOW_BOX); } }
@Override public void onHideCustomView() { if (mXCustomView == null)// 不是全屏播放状态 return; mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); mXCustomView.setVisibility(View.GONE); if (mActivity.getVideoFullView() != null) { mActivity.getVideoFullView().removeView(mXCustomView); } mXCustomView = null; mIWebPageView.hindVideoFullView(); mXCustomViewCallback.onCustomViewHidden(); mIWebPageView.showWebView(); }
/** * Puts the activity in picture-in-picture mode if the activity supports. * @see android.R.attr#supportsPictureInPicture * @hide */ @Override public void enterPictureInPictureModeIfPossible() { if (mActivityInfo.resizeMode == ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE) { enterPictureInPictureMode(); } }
private static void modifyActivityInfo(Activity target, ApkLoaded loaded) { ActivityInfo activityInfo = loaded.getActivityInfo(target.getClass().getName()); if (activityInfo != null) { applyActivityInfo(target, activityInfo); applyTheme(target, activityInfo); applyRequestedOrientation(target, activityInfo); applyTaskDescription(target, loaded); } else { ApkLogger.get().debug("getActivityInfo fail : " + target.getClass().getName(), null); } }
public RTCVideoView(RelativeLayout videoView, Context ctx, EglBase eglBase) { mAutoLayout = false; mContext = ctx; mVideoView = videoView; mRootEglBase = eglBase; mLocalRender = null; mRemoteRenders = new HashMap<>(); mRTCVideoLayout = AnyRTCMeetEngine.Inst().getAnyRTCMeetOption().getmVideoLayout(); if (mRTCVideoLayout == AnyRTCVideoLayout.AnyRTC_V_3X3_auto) { ((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } mScreenWidth = ScreenUtils.getScreenWidth(mContext); mScreenHeight = ScreenUtils.getScreenHeight(mContext) - ScreenUtils.getStatusHeight(mContext); }
private boolean handleUserBroadcast(int vuid, ActivityInfo info, ComponentName component, Intent realIntent, PendingResultData result) { if (component != null && !ComponentUtils.toComponentName(info).equals(component)) { // Verify the component. return false; } String originAction = SpecialComponentList.unprotectAction(realIntent.getAction()); if (originAction != null) { // restore to origin action. realIntent.setAction(originAction); } handleStaticBroadcastAsUser(vuid, info, realIntent, result); return true; }
@Override protected void onResume() { super.onResume(); if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } }
@Override public ActivityInfo getActivityInfo(ComponentName component, int flags, int userId) { checkUserId(userId); synchronized (mPackages) { PackageParser.Activity a = mActivities.mActivities.get(component); if (a != null) { ActivityInfo activityInfo = PackageParserCompat.generateActivityInfo(a, flags); PackageParser.Package p = mPackages.get(activityInfo.packageName); AppSetting settings = (AppSetting) p.mExtras; ComponentFixer.fixComponentInfo(settings, activityInfo, userId); return activityInfo; } } return null; }
public static int getActivityTitleResId(final Context context, final Class<? extends Activity> cls) { final ComponentName cn = new ComponentName(context, cls); try { final ActivityInfo ai = context.getPackageManager().getActivityInfo(cn, 0); if (ai != null) { return ai.labelRes; } } catch (final NameNotFoundException e) { Log.e(TAG, "Failed to get settings activity title res id.", e); } return 0; }