How to use Android Resources in Application class? -


i have simple question, can't resource drawable in application class. there anyway it?

public class capplication extends application {      @override     public void oncreate(){         super.oncreate();     }      public void sendnotification(string message, class<?> activitytoopen, int appid) {         notificationcompat.builder mbuilder =                 new notificationcompat.builder(this)                         .setsmallicon(r.drawable.noticon)                         .setcontenttitle("my notification")                         .setcontenttext("hello world!");         intent resultintent = new intent(this, activitytoopen);         taskstackbuilder stackbuilder = taskstackbuilder.create(this);         stackbuilder.addparentstack(mainscreenactivity.class);         stackbuilder.addnextintent(resultintent);         pendingintent resultpendingintent =                 stackbuilder.getpendingintent(                         0,                         pendingintent.flag_update_current                 );         mbuilder.setcontentintent(resultpendingintent);         notificationmanager mnotificationmanager =                 (notificationmanager) getsystemservice(context.notification_service);         mnotificationmanager.notify(appid, mbuilder.build());     } } 

i have custom application class handle application stuff. i'm trying delegate notification stuff application class can't access resource folder small icon.

.setsmallicon(r.drawable.noticon) 

r not found. how resolve issue or implement notification method in service/activity?

edit: i'm sorry. realised application didn't rebuild properly, r not found.

sometimes need clean , build recreate r file. comment line calling r class , uncomment after has been generated


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -