Search code examples
androidandroid-appwidget

Get touch location for appwidget


When a user clicks on my appwidget, the widget's configuration activity is opened up. So far that has suited my needs.

Now I'd like to add the ability to perform a special action (e.g. a widget refresh) when the user touches a particular feature or area on the widget, rather than open up the configuration activity.

Is there any way to do that? Even if it's just a case of detecting whether the touch was in the left half of the widget, for example, that would be useful.


Solution

  •         Intent myIntent = new Intent(...);
            ...
            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, myIntent, 0);
            remoteViewsFive.setOnClickPendingIntent(R.id.imgRefresh, pendingIntent);
    

    Like this, imgRefresh is your ImageView with refresh icon (for example). You should define an Intent then create a PendingIntent that set on view

    A easy solution to do what you want it's use a transparent png in imgRefresh