문제

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?)

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top