views:

59

answers:

2

Hi All, I am new to Android Dev, and this is my first widget.

What is supposed to happen is when the user clicks the widget, it turns off or on the Master Sync option.

However the widget does not do anything when clicked, and appears to not be clickable.

This is the body of the .java code, if it helps to post any of the other code please let me know.

public class MasterSync extends AppWidgetProvider {
    /** Called when the activity is first created. */
    @Override

    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

     final int N = appWidgetIds.length;

        // now label the property of the button
     boolean sync = ContentResolver.getMasterSyncAutomatically();

  if (sync){  

    ContentResolver.setMasterSyncAutomatically(false);}
  else

  if (!sync){

     ContentResolver.setMasterSyncAutomatically(true);
    }

    }}
+1  A: 

processing a click on a widget takes a bit more than just one line of code - have a look at this tutorial - it explains the basics of widgets and also how to process clicks:

Hello Widget Tutorial

Martin
A: 

onUpdate is called when the widget is updated, not when clicked

Ran