0

I'm trying to modify data on certain action but it throws NPE.

if("Button1_OnClickTag".equals(mIntent.getAction())){
        Collections.sort(mCollections, Anlik.COMPARE_BY_BIRIM);
        Log.d("****CollectionSize****", "initDataFromService_if: "+mCollections.size());
        notify();
    }

I'm using this piece in data initialization of my RemoteViesFactory. I don't know if this is the right way to do it. If not can you suggest any other way(s)? Thanks.

EDIT: code flow comes to that point by following

if(Button1_OnClick.equals(intent.getAction())){
        sharedPreferences = context.getSharedPreferences("PREFERENCES", context.getApplicationContext().MODE_PRIVATE);
        widgetIdupdate=sharedPreferences.getInt("mWidgetId", 66);
        Toast.makeText(context, "Category1", Toast.LENGTH_SHORT).show();
        //WidgetDataProvider.modifData();
        Log.d("****ONCLICK WIDGETID", "onReceive: " + widgetIdupdate);
        RemoteViews mView = new RemoteViews(context.getPackageName(),R.layout.mudo_life_widget);
        mView.setRemoteAdapter(widgetIdupdate, R.id.list,intent);
        onUpdate(context);
    }

in my AppWidgetProvider than,

public class WidgetService extends RemoteViewsService {

@Override
public RemoteViewsFactory onGetViewFactory(Intent intent) {

    WidgetDataProvider dataProvider = new WidgetDataProvider(
            getApplicationContext(), intent);
    return dataProvider;
}

}

in WidgetService and when it creates WidgetDataProvider

public WidgetDataProvider(Context context, Intent intent) {mContext = context; mIntent=intent;}

so I think it is already assigned to Button1_OnClick . Am I thinking wrong?

Kdaydin
  • 441
  • 5
  • 17
  • 1
    Possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – 0xDEADC0DE Apr 13 '16 at 10:29
  • Very low information provided. Can you provide more code and logs? – Jimit Patel Apr 13 '16 at 10:36

0 Answers0