Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I launch an activity from a location on the screen, like on the home screen or in recent apps?

I want to create a "maximizing" effect from a dialog into my full activity, so I want the opening animation to show the activity expanding from a box to full size.

The stock launcher has done this this since Jelly Bean (pressing an app shortcut will zoom into the application from that icon's location and the Recent Apps menu has done this since ICS.

like image 616
Steven Schoen Avatar asked Oct 02 '13 07:10

Steven Schoen


People also ask

How do I start an activity in another application?

If both application have the same signature (meaning that both APPS are yours and signed with the same key), you can call your other app activity as follows: Intent LaunchIntent = getActivity(). getPackageManager(). getLaunchIntentForPackage(CALC_PACKAGE_NAME); startActivity(LaunchIntent);

What is recents screen?

The Recents screen (also referred to as the Overview screen, recent task list, or recent apps) is a system-level UI that lists recently accessed activities and tasks. The user can navigate through the list and select a task to resume, or the user can remove a task from the list by swiping it away.


1 Answers

Figured it out!

Bundle options = ActivityOptionsCompat.makeScaleUpAnimation(
    findViewById(android.R.id.content),
    findViewById(android.R.id.content).getLeft(),
    findViewById(android.R.id.content).getTop(),
    findViewById(android.R.id.content).getWidth(),
    findViewById(android.R.id.content).getHeight()).toBundle();
    startActivity(intent, options);

It only works on API 16 and above, so put a check for it and use the plain old startActivity for older versions.

like image 153
Steven Schoen Avatar answered Oct 03 '22 22:10

Steven Schoen