When a user presses a shortcut on the screen and that shortcut starts up an activity, how can I get the location of where the shortcut is on the screen?
I have the same question for a widget. When a user has a widget on the screen and pressing it fires off the setOnClickPendingIntent how can I know the location on the screen where the widget is?
In both scenarios there is no View to run View.getLocationOnScreen.
You can’t, sorry.You can’t, sorry.The only way to get any of that would be to write your own home screen, where you are handling the shortcut presses and app widget taps.
EDIT: The way the
QuickContactActivityachieves the effect described in the comments is viagetSourceBounds(), a method onIntent. ThisRectmay or may not be available on any givenIntent, and therefore any code looking to use it should be able to cleanly react to anIntentthat has no such value. I can see whereRemoteViews, the basis for app widgets, use it. I am having a bit more difficulty seeing under what other circumstances the Launcher application uses it. Bear in mind that not all home screens may elect to use it. I apologize for my erroneous original answer.