@Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_SPAM: { boolean fg = msg.arg1 != 0; Intent intent = new Intent(ActivityTestMain.this, SpamActivity.class); Bundle options = null; if (fg) { ActivityOptions opts = ActivityOptions.makeTaskLaunchBehind(); options = opts.toBundle(); } startActivity(intent, options); scheduleSpam(!fg); } break; case MSG_SPAM_ALARM: { long when = SystemClock.elapsedRealtime(); Intent intent = new Intent(ActivityTestMain.this, AlarmSpamReceiver.class); intent.setAction("com.example.SPAM_ALARM=" + when); PendingIntent pi = PendingIntent.getBroadcast(ActivityTestMain.this, 0, intent, 0); mAlarm.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME, when + (30 * 1000), pi); scheduleSpamAlarm(30 * 1000); } break; } super.handleMessage(msg); }
/** * Launch activity using custom animations. Uses ActivityOptions if on JellyBean, otherwise * overrides transition * * @param parent parent activity * @param intent intent to launch * @param animIn In animation * @param animOut Out animation */ public static void launchActivity(Activity parent, Intent intent, int animIn, int animOut) { if (isJellyBean()) parent.startActivity( intent, ActivityOptions.makeCustomAnimation(parent, animIn, animOut).toBundle()); else { parent.startActivity(intent); parent.overridePendingTransition(animIn, animOut); } }
public void openRecipeDetail(View view, int position) { try { // Image imageItem = adapter.GetItemAt(position); Intent intent = new Intent(this, RecipeActivity.class); intent.putExtra( Constants.exRecipeTitle, String.valueOf(BrewSharedPrefs.getCurrentContentTitle())); intent.putExtra( Constants.exContentItemPk, String.valueOf(BrewSharedPrefs.getNextContentItemId())); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this); ActivityCompat.startActivity(this, intent, options.toBundle()); } else { this.startActivity(intent); this.overridePendingTransition(R.anim.slide_in_from_right, R.anim.slide_out_to_left); } } catch (Exception e) { if (BuildConfig.DEBUG) { Log.e(Constants.LOG, e.getMessage()); } } }
public void scaleupAnimation(View view) { // Create a scale-up animation that originates at the button // being pressed. ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight()); // Request the activity be started, using the custom animation options. startActivity(new Intent(MainActivity.this, AnimationActivity.class), opts.toBundle()); }
public void moveToViewUsers(View view) { Intent intent = new Intent(this, TestUserList.class); ActivityOptions options = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent, options.toBundle()); }
public void startActivityWithTransition( Intent intent, final View clickedView, final String transitionName) { ActivityOptions options = null; if (hasL() && clickedView != null && !TextUtils.isEmpty(transitionName)) { // options = ActivityOptions.makeSceneTransitionAnimation( // mActivity, clickedView, transitionName); } mActivity.startActivity(intent, (options != null) ? options.toBundle() : null); }
public void thumbNailScaleAnimation(View view) { view.setDrawingCacheEnabled(true); view.setPressed(false); view.refreshDrawableState(); Bitmap bitmap = view.getDrawingCache(); ActivityOptions opts = ActivityOptions.makeThumbnailScaleUpAnimation(view, bitmap, 0, 0); // Request the activity be started, using the custom animation options. startActivity(new Intent(MainActivity.this, AnimationActivity.class), opts.toBundle()); view.setDrawingCacheEnabled(false); }
@SuppressLint("NewApi") public void changeToLoginActivity(View view, boolean ani) { Intent intent = new Intent(context, UserLoginActivity.class); if (android.os.Build.VERSION.SDK_INT >= 16 && ani) { ActivityOptions options = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight()); startActivity(intent, options.toBundle()); } else { startActivity(intent); } }
private void showQrCodeDialog() { Intent qrCodeIntent = new Intent(getActivity(), QrCodeViewActivity.class); // create the transition animation - the images in the layouts // of both activities are defined with android:transitionName="qr_code" Bundle opts = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getActivity(), mQrCodeLayout, "qr_code"); opts = options.toBundle(); } qrCodeIntent.setData(mDataUri); ActivityCompat.startActivity(getActivity(), qrCodeIntent, opts); }
@Override public void enterImageDetails( String sharedImageTransitionName, File imageFile, ImageView image, Image imageModel) { // ActivityOptions options = // ActivityOptions.makeSceneTransitionAnimation(this,image,sharedImageTransitionName); int[] los = new int[2]; image.getLocationOnScreen(los); ActivityOptions options1 = ActivityOptions.makeScaleUpAnimation( image, image.getWidth() / 2, image.getHeight() / 2, 0, 0); getWindow().setSharedElementEnterTransition(new ChangeImageTransform(this, null)); Intent intent = ImageDetailActivity.getStartIntent(this, sharedImageTransitionName, imageFile); startActivity(intent, options1.toBundle()); }
/** Starts the recents activity */ void startAlternateRecentsActivity( ActivityManager.RunningTaskInfo topTask, ActivityOptions opts, boolean fromHome, boolean fromSearchHome, boolean fromThumbnail, TaskStackViewLayoutAlgorithm.VisibilityReport vr) { // Update the configuration based on the launch options mConfig.launchedFromHome = fromSearchHome || fromHome; mConfig.launchedFromSearchHome = fromSearchHome; mConfig.launchedFromAppWithThumbnail = fromThumbnail; mConfig.launchedToTaskId = (topTask != null) ? topTask.id : -1; mConfig.launchedWithAltTab = mTriggeredFromAltTab; mConfig.launchedReuseTaskStackViews = mCanReuseTaskStackViews; mConfig.launchedNumVisibleTasks = vr.numVisibleTasks; mConfig.launchedNumVisibleThumbnails = vr.numVisibleThumbnails; mConfig.launchedHasConfigurationChanged = false; Intent intent = new Intent(sToggleRecentsAction); intent.setClassName(sRecentsPackage, sRecentsActivity); intent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_TASK_ON_HOME); if (opts != null) { mContext.startActivityAsUser(intent, opts.toBundle(), UserHandle.CURRENT); } else { mContext.startActivityAsUser(intent, UserHandle.CURRENT); } mCanReuseTaskStackViews = true; }
/** Creates the activity options for an app->recents transition. */ ActivityOptions getThumbnailTransitionActivityOptions( ActivityManager.RunningTaskInfo topTask, TaskStack stack, TaskStackView stackView) { // Update the destination rect Task toTask = new Task(); TaskViewTransform toTransform = getThumbnailTransitionTransform(stack, stackView, topTask.id, toTask); Rect toTaskRect = toTransform.rect; Bitmap thumbnail; if (mThumbnailTransitionBitmapCacheKey != null && mThumbnailTransitionBitmapCacheKey.key != null && mThumbnailTransitionBitmapCacheKey.key.equals(toTask.key)) { thumbnail = mThumbnailTransitionBitmapCache; mThumbnailTransitionBitmapCacheKey = null; mThumbnailTransitionBitmapCache = null; } else { preloadIcon(topTask); thumbnail = drawThumbnailTransitionBitmap(toTask, toTransform); } if (thumbnail != null) { mStartAnimationTriggered = false; return ActivityOptions.makeThumbnailAspectScaleDownAnimation( mDummyStackView, thumbnail, toTaskRect.left, toTaskRect.top, toTaskRect.width(), toTaskRect.height(), mHandler, this); } // If both the screenshot and thumbnail fails, then just fall back to the default transition return getUnknownTransitionActivityOptions(); }
private void conferma() { if (dataInizio.after(dataFine)) { new MioToast(Statistiche.this, getString(R.string.statistiche_periodoSbagliato)) .visualizza(Toast.LENGTH_SHORT); return; } Intent intGrafico = new Intent(Statistiche.this, StatisticheGrafico.class); intGrafico.putExtra("spese", spese); intGrafico.putExtra("grafico", spGrafico.getSelectedItemPosition()); if ((spGrafico.getSelectedItemPosition() == CostantiGrafici.GRAFICO_TEMPORALE_TAG || spGrafico.getSelectedItemPosition() == CostantiGrafici.GRAFICO_DIAL) && spese) { intGrafico.putExtra("voce", arrVociSpese[spVoci.getSelectedItemPosition()]); } else if ((spGrafico.getSelectedItemPosition() == CostantiGrafici.GRAFICO_TEMPORALE_TAG || spGrafico.getSelectedItemPosition() == CostantiGrafici.GRAFICO_DIAL) && !spese) { intGrafico.putExtra("voce", arrVociEntrate[spVoci.getSelectedItemPosition()]); } intGrafico.putExtra("data_inizio", dataInizio.getTimeInMillis()); intGrafico.putExtra("data_fine", dataFine.getTimeInMillis()); if (spGrafico.getSelectedItemPosition() == CostantiGrafici.GRAFICO_DOUGHNUT) { intGrafico.putExtra("data_inizio2", dataInizio2.getTimeInMillis()); intGrafico.putExtra("data_fine2", dataFine2.getTimeInMillis()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { startActivity( intGrafico, ActivityOptions.makeSceneTransitionAnimation(Statistiche.this).toBundle()); } else { startActivity(intGrafico); } }
@Override public boolean doPreviousAction() { Intent intent = new Intent(ACTION_EMERGENCY_DIAL); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); ActivityOptions options = ActivityOptions.makeCustomAnimation( mContext, android.R.anim.fade_in, android.R.anim.fade_out); SetupStats.addEvent(SetupStats.Categories.BUTTON_CLICK, SetupStats.Label.EMERGENCY_CALL); SetupStats.addEvent( SetupStats.Categories.EXTERNAL_PAGE_LOAD, SetupStats.Action.EXTERNAL_PAGE_LAUNCH, SetupStats.Label.PAGE, SetupStats.Label.EMERGENCY_CALL); mContext.startActivity(intent, options.toBundle()); return true; }
@SuppressLint("NewApi") private void initialiseTabHost() { mTabHost.setup(); // TODO Put here your Tabs AddTab( getActivity(), mTabHost, mTabHost.newTabSpec("All Categories").setIndicator("All Categories")); try { for (int i = 0; i < categories.size(); i++) { final CategoriesBean lb = categories.get(i); category_id.add(lb.categoryId); AddTab( getActivity(), mTabHost, mTabHost.newTabSpec(lb.categoryName).setIndicator(lb.categoryName)); } } catch (Exception e) { e.printStackTrace(); Intent intent = new Intent(new Intent(getActivity(), SplashActivity.class)); if (Build.VERSION.SDK_INT > 11) { Bundle bundle = ActivityOptions.makeCustomAnimation( getActivity(), R.anim.trans_left_in, R.anim.trans_left_out) .toBundle(); getActivity().startActivity(intent, bundle); } else { startActivity(intent); } } mTabHost.setOnTabChangedListener(this); }
@SuppressLint("NewApi") private List<Fragment> getFragments() { List<Fragment> fList = new ArrayList<Fragment>(); AllEventsFragment f1 = AllEventsFragment.newInstance(""); fList.add(f1); try { for (int i = 0; i < categories.size(); i++) { final CategoriesBean lb = categories.get(i); ArtTheatreFragment categoryName = ArtTheatreFragment.newInstance("" + lb.categoryId); fList.add(categoryName); } } catch (Exception e) { e.printStackTrace(); Intent intent = new Intent(new Intent(getActivity(), SplashActivity.class)); if (Build.VERSION.SDK_INT > 11) { Bundle bundle = ActivityOptions.makeCustomAnimation( getActivity(), R.anim.trans_left_in, R.anim.trans_left_out) .toBundle(); getActivity().startActivity(intent, bundle); } else { startActivity(intent); } } return fList; }
/** Creates the activity options for a home->recents transition. */ ActivityOptions getHomeTransitionActivityOptions(boolean fromSearchHome) { mStartAnimationTriggered = false; if (fromSearchHome) { return ActivityOptions.makeCustomAnimation( mContext, R.anim.recents_from_search_launcher_enter, R.anim.recents_from_search_launcher_exit, mHandler, this); } return ActivityOptions.makeCustomAnimation( mContext, R.anim.recents_from_launcher_enter, R.anim.recents_from_launcher_exit, mHandler, this); }
private void startAssistActivity() { // Close Recent Apps if needed mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL); // Launch Assist Intent intent = SearchManager.getAssistIntent(mContext); if (intent == null) return; try { ActivityOptions opts = ActivityOptions.makeCustomAnimation( mContext, R.anim.search_launch_enter, R.anim.search_launch_exit, getHandler(), this); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent, opts.toBundle()); } catch (ActivityNotFoundException e) { Slog.w(TAG, "Activity not found for " + intent.getAction()); onAnimationStarted(); } }
/** Creates the activity options for a unknown state->recents transition. */ ActivityOptions getUnknownTransitionActivityOptions() { mStartAnimationTriggered = false; return ActivityOptions.makeCustomAnimation( mContext, R.anim.recents_from_unknown_enter, R.anim.recents_from_unknown_exit, mHandler, this); }
@Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_SPAM: { boolean fg = msg.arg1 != 0; Intent intent = new Intent(ActivityTestMain.this, SpamActivity.class); Bundle options = null; if (fg) { ActivityOptions opts = ActivityOptions.makeTaskLaunchBehind(); options = opts.toBundle(); } startActivity(intent, options); scheduleSpam(!fg); } break; } super.handleMessage(msg); }
public static ActivityOptionsCompat21 makeSceneTransitionAnimation( Activity paramActivity, View[] paramArrayOfView, String[] paramArrayOfString) { Pair[] arrayOfPair = null; if (paramArrayOfView != null) { arrayOfPair = new Pair[paramArrayOfView.length]; for (int i = 0; i < arrayOfPair.length; i++) arrayOfPair[i] = Pair.create(paramArrayOfView[i], paramArrayOfString[i]); } return new ActivityOptionsCompat21( ActivityOptions.makeSceneTransitionAnimation(paramActivity, arrayOfPair)); }
@Override public void onClick(View view) { switch (view.getId()) { case R.id.btn_next: Intent intent = new Intent(StartUpActivity.this, LoginActivity.class); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle()); } else { startActivity(intent); } } }
/** * Launches the said intent for the current foreground user. * * @param intent * @param showsWhileLocked true if the activity can be run on top of keyguard. See {@link * WindowManager#FLAG_SHOW_WHEN_LOCKED} * @param useDefaultAnimations true if default transitions should be used, else suppressed. * @param worker if supplied along with onStarted, used to launch the blocking activity call. * @param onStarted if supplied along with worker, called after activity is started. */ public void launchActivity( final Intent intent, boolean showsWhileLocked, boolean useDefaultAnimations, final Handler worker, final Runnable onStarted) { final Context context = getContext(); final Bundle animation = useDefaultAnimations ? null : ActivityOptions.makeCustomAnimation(context, 0, 0).toBundle(); launchActivityWithAnimation(intent, showsWhileLocked, animation, worker, onStarted); }
@Test public void shouldUseAnimationOverride() { Activity activity = buildActivity(Activity.class).create().get(); Intent intent = new Intent(activity, OptionsMenuActivity.class); Bundle animationBundle = ActivityOptions.makeCustomAnimation(activity, R.anim.test_anim_1, R.anim.test_anim_1) .toBundle(); activity.startActivity(intent, animationBundle); assertThat(shadowOf(activity).getNextStartedActivityForResult().options) .isSameAs(animationBundle); }
@SuppressLint("NewApi") public void onActivityAnim(View view) { if (Build.VERSION.SDK_INT >= 21) { getWindow().setSharedElementEnterTransition(new Explode()); Intent intent = new Intent(this, ShareActivityB.class); // 一个共有元素 // ActivityOptions options = // ActivityOptions.makeSceneTransitionAnimation( // this, mViewImage, "image"); // 多个共有元素 Pair[] pairs = new Pair[2]; pairs[0] = Pair.create(mViewContent, "text"); pairs[1] = Pair.create(mViewImage, "image"); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(ShareActivityA.this, pairs); startActivity(intent, options.toBundle()); } else { Toast.makeText(this, "sorry~", Toast.LENGTH_SHORT).show(); } }
@OnItemClick(com.appcutt.demo.R.id.grid_view) void onItemClick(AdapterView<?> parent, View v, int position, long id) { Photo photo = (Photo) adapter.getItem(position); // PhotoDetailActivity.start(getActivity(), view, photo); /** 图片浏览 */ Intent intent = new Intent(); intent.setClass(getContext(), ImagePreviewActivity.class); intent.putStringArrayListExtra("imgs", adapter.getAllImages()); intent.putExtra("index", position); if (android.os.Build.VERSION.SDK_INT > 15) { // Create a scale-up animation that originates at the button // being pressed. ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()); // Request the activity be started, using the custom animation options. getActivity().startActivity(intent, opts.toBundle()); } else { getActivity().startActivity(intent); } }
private static boolean switchToLastAppInternal(Context context, int userId) throws RemoteException { ActivityManager.RecentTaskInfo lastTask = getLastTask(context, userId); if (lastTask == null || lastTask.id < 0) { return false; } final String packageName = lastTask.baseIntent.getComponent().getPackageName(); final IActivityManager am = ActivityManagerNative.getDefault(); final ActivityOptions opts = ActivityOptions.makeCustomAnimation( context, com.android.internal.R.anim.last_app_in, com.android.internal.R.anim.last_app_out); if (DEBUG) Log.d(TAG, "switching to " + packageName); sendCloseSystemWindows(context, null); am.moveTaskToFront(lastTask.id, ActivityManager.MOVE_TASK_NO_USER_ACTION, opts.toBundle()); return true; }
private void startAssistActivity(Bundle args) { if (!mBar.isDeviceProvisioned()) { return; } // Close Recent Apps if needed mBar.animateCollapsePanels( CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL); boolean structureEnabled = Settings.Secure.getIntForUser( mContext.getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1, UserHandle.USER_CURRENT) != 0; final Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) .getAssistIntent(structureEnabled); if (intent == null) { return; } if (mAssistComponent != null) { intent.setComponent(mAssistComponent); } intent.putExtras(args); if (structureEnabled) { showDisclosure(); } try { final ActivityOptions opts = ActivityOptions.makeCustomAnimation( mContext, R.anim.search_launch_enter, R.anim.search_launch_exit); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); AsyncTask.execute( new Runnable() { @Override public void run() { mContext.startActivityAsUser( intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT)); } }); } catch (ActivityNotFoundException e) { Log.w(TAG, "Activity not found for " + intent.getAction()); } }
@TargetApi(16) @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Movie movie = (Movie) parent.getItemAtPosition(position); if (movie != null && movie.id != null) { // display details about this movie in a new activity Intent i = new Intent(getActivity(), MovieDetailsActivity.class); i.putExtra(MovieDetailsFragment.InitBundle.TMDBID, movie.id); if (AndroidUtils.isJellyBeanOrHigher()) { Bundle options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle(); getActivity().startActivity(i, options); } else { startActivity(i); } } }
protected void startActivityIfNeed() { /** if alarm boot , do not start activity */ boolean isKeyguardShow = mViewMediatorCallback.isShowingAndNotOccluded(); boolean isAlarmBoot = AmigoKeyguardUtils.isAlarmBoot(); boolean isAlarmOrIncallTop = AmigoKeyguardUtils.isAlarmOrInCallActivityTop(mContext); if (isKeyguardShow && !isAlarmBoot && !isAlarmOrIncallTop) { if (mActivitys.size() == 0) { Intent intent = new Intent(mContext, SkylightActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Bundle opts = ActivityOptions.makeCustomAnimation(mContext, 0, 0).toBundle(); mContext.startActivity(intent, opts); } else { mContext.startActivity(intent); } } } }