简体   繁体   中英

How to detect if user touch device widget on Home screen?

See screenshot below from my android emulator:

http://imageshack.us/photo/my-images/190/image1zqu.png/

It's a screenshot from the home screen. Watch the object inside the red box. That's the device's widget.

Description:
I created a live wallpaper application that has object on the screen and user can move the object by touching any area on the screen as the destination. The problem is if user touched the device widget, ie. browser button, the object will move to the button widget as well as opening the browser. So I want to know how to detect if user is touching device's widget or not?

My intention is to prevent the object moving when user touching device's widget on screen.

Note: I developed the application using AndEngine library, but android openGL ES or any other solution is welcomed too.

You can register a pending intent for parent layout of your widget that it broadcasts your AppWidgetManager and put specified extra to it's intent,so when user touch your widget, onReceive method of AppWidgetManager will be invoked.In onReceive method you can get extra from received intent and detect that it is invoked for touch or no.

For more details you can see these pages:
Detect in android widget a touch event from down to up (or the inverse)
developing-android-home-screenwidgets

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM