开发者

How to getLocationOnScreen from a Shortcut or Widget?

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开发者_C百科 View.getLocationOnScreen.


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?

You can't, sorry.

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?

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 QuickContactActivity achieves the effect described in the comments is via getSourceBounds(), a method on Intent. This Rect may or may not be available on any given Intent, and therefore any code looking to use it should be able to cleanly react to an Intent that has no such value. I can see where RemoteViews, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜