Question

I'm trying to get click event on my ListView on homesreen widget. For this I'm using following code:

public class ViewFactory implements RemoteViewsService.RemoteViewsFactory {
...

  @Override
    public RemoteViews getViewAt(int position) {
         RemoteViews row=new RemoteViews(ctxt.getPackageName(),
                R.layout.row);
        Log.i("position receive trans", Integer.toString(position));

        row.setTextViewText(android.R.id.text1, items[position]);
        Intent i = new Intent(this.ctxt, AppWidget.class);
        i.setAction(ACTION_WIDGET_UPDATE_POSITION);
        i.putExtra("position", position);
        row.setOnClickFillInIntent(android.R.id.text1, i);
        return(row);
    }

But I'm getting this event not only after clicking on widget. I'm getting this also after adding widget to the home screen.

Is there any way to determine different actions (Click and adding to homescreen?)

Was it helpful?

Solution

Such situation can be determined by
intent.getAction();
For enabling widget is : android.appwidget.action.APPWIDGET_ENABLED
For updatewidget is : android.appwidget.action.APPWIDGET_UPDATE

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top