android - Launching an activity from notification -
i trying launch activity notification. have activity a. activity launched clicking on notification. once activity launched, mainactivity upon pressing phone's button. happen implement follow. code implemented in broadcastreceiver. having compilation error @ line intent resultintent = new intent(mainactivity.this, theclass);
because mainactivity.this not valid in broadcastreceiver class. how can make correct?
class theclass = class.forname("sg.santhit.trackme.notificationlistactivity"); intent resultintent = new intent(mainactivity.this, theclass); resultintent.putextra("mobilenumber", tel); taskstackbuilder stackbuilder = taskstackbuilder.create(mainactivity.this); // adds stack intent (but not intent itself) stackbuilder.addparentstack(theclass); // adds intent starts activity top of stack stackbuilder.addnextintent(resultintent); pendingintent resultpendingintent = stackbuilder.getpendingintent( 0, pendingintent.flag_update_current ); mbuilder.setcontentintent(resultpendingintent);
Comments
Post a Comment