android - How can I call findViewById inside IntentService? -


is there way call findviewbyid inside intentservice? in case, tried using static reference of mainactivity class. didn't work.

mainactivity class calls intentservice:

public static mainactivity ma;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         ma=this;         startservice(new intent(this,myservice.class).setaction("myintent"));     } 

and myservice class is:

protected void onhandleintent(intent intent) {         if(intent.getaction()=="myintent"){             listview lv=(listview)(mainactivity.ma.findviewbyid(r.id.listview));             toast.maketext(getapplicationcontext(), (mainactivity.ma.findviewbyid(r.id.listview)).tostring(), toast.length_long).show();             }      } 

this gives nullpointerexception. verified mainactivity.ma ok inside service class. still, cannot call findviewbyid.

how can resolve this?


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -