Android :: Detect OnTouch For Widget?
Oct 2, 2009I'm trying to make widget gallery at homescreen. I'm currently stuck because didn't find any example how to detect on touch in widget. Could someone help me?
View 5 RepliesI'm trying to make widget gallery at homescreen. I'm currently stuck because didn't find any example how to detect on touch in widget. Could someone help me?
View 5 RepliesI'm writing a customized view similar to Grid which will be used to hold a large amount of images. I'm using ImageButton to display the images, and I only want to load images onto the buttons once they are on the screen (and just display a static background image when they are not). The reason for it is that I'm fetching images from some back-end service and I only want to fetch them when the buttons are on the screen.To do that, I'd like to know if the widget is on the screen. Is it possible to detect if a widget like button is on/off screen? If not, any suggestions on how to achieve what I'm trying to do?
View 1 Replies View Relatedhow can I detect Fling action in my own widget? I have implemented my widget as OnGestureListener.
And like in Gallery, I have a "GestureDetector mGestureDetector = new GestureDetector(this);"
For my onTouchEvent(), I have @Override public boolean onTouchEvent(MotionEvent event) {
// Give everything to the gesture detector boolean retValue = mGestureDetector.onTouchEvent(event); return retValue;
But my public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) is never get claeed.
What's the best way to detect when a Home Screen Widget has gained or lost focus? An example of losing focus is if the user navigates to another screen or if another screen popped up in front of the Widget.
View 1 Replies View Relatedhow to detect the Widget in home screen is active in the current panel? As you know, some device has many panel i.e (HTC Hero has 7 panel), each panel can put some widgets on the home screen, then the widget will run and refresh the data automatically, we want to let the widget disable the refresh data feature while it is not under current panel. and enable it while it is put to current panel again.
View 7 Replies View RelatedIt would appear on a G1 (with the latest software update) that onUpdate () runs even when the widget is not visible. Is there a way of sensing that the widget is or is not visible or is otherwise in foreground? That is, running the code below shows a logcat message at whatever interval the Widget is scheduled to update, whether it's in foreground or not, whether even the screen is dim or otherwise in deep sleep. It would seem onUpdate should only be scheduled to run when the Widget is in the foreground or visible. Is this a defect in the G1, or is there some other API call to detect if the Widget is visible?
public class HomeScreenWidget extends AppWidgetProvider { ...
I am writing a home screen widget and want to update (modify) the home screen widget when the device orientation changes from portrait to landscape or the other way. How can I make it? Currently, I tried to register to CONFIGURATION_CHANGED action like the code below ...
View 3 Replies View RelatedI have a problem with one of my app. I try to make a paint application but nothing is draw on the screen (except the first circle which is draw on the launch).The log Cat seems to be correct and i get the right x/y coordinates.I think i do something wrong on the ondraw.do you see my problem?
View 3 Replies View RelatedI'm trying to start activity by sweeping across the screen, it works fine for all the other screens, just this screen that doesn't fire the onTouch at all? Would you mind helping me? I've tried debugging it and still have no idea at all. Below are the codes, sorry for not putting snippets only as I thought I might did something wrong elsewhere
I'm also looking for advice on implementing sweeping to change screen. I've read about ViewFlipper and I know it will work very well, but I've around 8 screens with different backend coding needed.
CODE:.....................
I'm trying to develop a touch control, but I'm getting some problems with the onTouch method. Basically, only the event ACTION_DOWN is working. The others seems to be in trouble.My application has a LinearLayout, containing a VideoView.I have a HTC Magic updated to 1.6.
View 3 Replies View RelatedI am relatively new to this still, and I have been developing a small app that would benefit greatly from a user being able to press 2 buttons at one time. What is the best method for achieving this? I dont think that an OnClickListener works like that, and I have seen examples for doing this with an OnTouch event. However, I do not know how to set up button presses with an OnTouch event.
View 3 Replies View RelatedI want to intercept the OnTouch event in a PopupWindow, but it failes everytime. Here is the code snip:
CODE:.....................
When the activity started, I can click the button to show the popup window correctly. But after that, nothing happens when I touch the popup window's view. But if I touch any where outside the popup window, the log Log.d("Demo", "layout::onTouch >>> view: " + v + ", event: " + event); will work.
It looks like when I touch the view of the popup window, the touch event has been consumed somewhere?
I have a listview and implemented onclick and also onfling.problem is when i do fling(swipe left to right), onclick event of listview is also getting executed.How to overCome this problem? how to differentiate touch(tap) and fling(swipe) in listview? code...
P.S: is it possible? to comment the onclicklistener of listview and writing the same logic in any onTouchEvent? but still i doubt onfling will call ontouch. right?
I'm trying to implement pinch-zoom in an app I'm making and am having issues with the onTouch event. It appears that the pointer up & down actions do not fire immediately, like you won't get a pointer up or down until an action move occurs. So what happens if both fingers hit the screen nearly simultaneously is that the 2nd finger (should be pointer(1)) gets a move action before pointer down is called, making the code think it's a DRAG not a pinch zoom.
View 2 Replies View RelatedLet's say I have MyActivity and inside my onCreate method I initialize MyBackgroundView, then MyPlayer1View then MyPlayer2View. I want to be able to touch the screen, figure out if I have touched Player1 or Player2 and then respond with changes to the players if I have touched them.
My problem is, where do I put the onTouchListener? Can only MyBackgroundView listen for touches, or can the players listen for touches too? If MyBackgroundView can only accept touches, do I need to call view.ontouchlistener that says, you have touched me, and I have a player at those coordinates, so I'll pass the motion event to the player and let it handle it? Or do call view.ontouchlistener in each of the players that says, you've touched me, now I will react to the motion event?
I have a situation where I have some textview on a framelayout that I have a onTouch event wired in order to simulate dragging. I alos want to enable the ability to have a context menu display when the user long presses the textview. Now that I have implemented the context menu functionality dragging no longer works since the longpress is always served by the context menu event.Does anyone know of a workaround for this.
View 2 Replies View Relatedwill the device wake up if there is a widget instance on the homepage but the widget provider or receiver is disabled?If I have a widget instance on the home page, but if I were to disable the widget provider from receiving messages by disabling the component, and if I have no components receiving the messages targeted for that widget, will Android still wake up the device?
View 5 Replies View RelatedOne of the things I liked about Sense (I'm rooted now and running the Second Wave ROM) was the HTC weather animations when the screen was unlocked. After installing Widget Locker, I noticed an option to turn them on and now I have them back! I also installed the Weather & Toggle Widget and installed the weather skin that looks just like the Sense weather with the flip clock.The annoying part is that when it's sunny, or partly sunny, the "sun animation" from Sense doesn't perfectly align with the Weather & Toggle Widget weather icon. I know, I know, it's a minor problem and goes away when the animation is done, but the lack of symmetry sometimes annoys the hell out of me.
View 1 Replies View RelatedI am writing my first application and am trying to get my widget to load a different image when it is added to the home screen based on the state of the notification volume.It is detecting the notification state fine and the proper Toast messages appear when I add the widget, but I'm not getting any icon.I just get an empty button.I'm using the same code to change the icon in my onReceive() method to do other things and that works fine.Is this the proper way to accomplish that?
View 3 Replies View RelatedI am trying to pass the same touch events on one widget to the other so they both scroll at the same time and in same way. I have two Gallery widgets one above and one below. If the above one is scrolled then I want to pass the same touch event to the bottom widget so it also scrolls the same way.I have tried to use dispatchtouchevent events but I am facing an issue where in if the bottom gallery widget has some edit text then the edit text gets the key event and both widgets doesnt scroll anymore.I have tried to set focussable and editable to false on edittext even then it gets the touch events.I think I am going in the right direction. However I need some assistance in doing the right way.
View 3 Replies View RelatedI'm not understanding this whole weather app & widget thing...I'd like to have a nice looking widget on my desktop that flows with my theme. Not the one that the weather channel app has.
View 5 Replies View RelatedI can create a static widget without thinking, I can even create a widget like the analogue clock widget that will update itself, however, I can not for the life of me figure out how to create a widget that reacts to when a user clicks on it. Here is the best code sample that the developer documentation gives to what a widget activity should contain (the only other hint being the API demos, which only creates a static widget):
public class ExampleAppWidgetProvider extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
// Perform this loop procedure for each App Widget that belongs to this provider
for (int i=0; i<N; i++) {
int appWidgetId = appWidgetIds[i];
// Create an Intent to launch ExampleActivity
Intent intent = new Intent(context, ExampleActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider_layout);
views.setOnClickPendingIntent(R.id.button, pendingIntent);................
Is there a way of getting the speed at which the device is running?
View 5 Replies View RelatedI need to catch event when a key is held down, not pressed down and but held for some time, equivalent to long click but for the key. You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To un subscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en.
View 2 Replies View RelatedI have ported the Android to a x86 platform. And i want to detect the USB plug-in.But follow the information about the android.intent.action.MEDIA_MOUNTED in the SDK's DOC, i can't receive the event of the USB's plug-in. i have checked my code and it can receive the other event ( ps:intent action) .
Besides, in the CLI, i could mount the USB device to /sdcard but it couldn't mount automatically. have seen some source code about the mount and mountlistener and it should be effective. my SDK's version is 1.5.
I would like to have my code run slightly differently when running on the emulator than when running on a device. (For example, using 10.0.2.2 instead of a public URL to run against a development server automatically.) What is the best way to detect when an Android application is running in the emulator?
View 9 Replies View RelatedI want to incorporate some Accelerometer code into a Android application im working and want to see if this is possible. Basically what I need is for the code to detect car acceleration motion. I am not wanting to determine speed with the code but just distinguish if the phone is in a car and has accelerated motion (Hence the car is moving for the first time). I have gone through many different accelerometer applications to see if this motion produces a viable profile to go off of and it appears it does. Just looking for something that popups a "Hello World" dialog when it detects your in the car and its moving for the first time down the street. Any help would be appreciated and a simple yes or no its possible would work. I would also be interested in compensating anyone that is capable of doing this as well.
View 2 Replies View RelatedI need to implement HorizontalScrollView which is scrolled to predefined positions (similar to Home behaviour). It works with slow gestures, but does not work with neither flings nor arrow key press.
I hooked to View.onScrollChanged() and it is called when scrolling happened, but I can't determine when scrolling animation ends.
In theory there should be a way to say that fling movement is over. Is there such API?
How to detect quickly if a specified URL contains an image in Android?
I have link of type http://foo.bar/w23afv so naive approach like checking end of URL string won't work here.
My application requires users to hold down the trackball in order to access an advanced menu.Not all phones have a trackball, however, so I need to remove this requirement for such phones.Is there a way to detect if the phone has a trackball?
View 1 Replies View Related