android - onClick starting another activity -


private onclicklistener startlistener = new onclicklistener() {     public void onclick(view v) {         startservice(new intent(simpleservicecontroller.this,                 simpleupdateservice.class));         startactivity(new intent (this, alarmmanagerlistening.class));     } }; 


problem occur @ startactivity execution. doesnt allow me start activity. may know what's wrong code?

the error facing because of use of this in startactivity(new intent (this, alarmmanagerlistening.class));. since instantiating new instance of onclicklistener this refers instance of listener , not service required context. utilizing simpleservicecontroller.this specify this refers controller subclass of context required new intent() method.


Comments