android - startForeground() throws RemoteServiceException -
so want show custom notification whenever call startforeground fails.
i create new layout , set informations collapsed layout. in layout have 3 buttons play/pause next , close.
then create expanded layout. same buttons + previous button. (like common music control notifications)
on startforeground this:
bad notification posted package com.driiinx.musicslide: couldn't expand remoteviews for: statusbarnotification
i haven't found answer yet need guys!
mnotificationtemplate = new remoteviews(mservice.getpackagename(), r.layout.notification_template_base); mnotificationtemplate.settextviewtext(r.id.notification_base_line_one,trackname); mnotificationtemplate.settextviewtext(r.id.notification_base_line_two,artistname); mnotificationtemplate.setimageviewbitmap(r.id.notification_base_image, albumart); if (apputils.hasics()) { mnotification = new notificationcompat.builder(mservice) .setsmallicon(r.drawable.ic_play) .setcontentintent(getpendingintent()) .setcontent(mnotificationtemplate) .build(); initplaybackactions(); if (apputils.hasjellybean()) { mexpandedview = new remoteviews(mservice.getpackagename(), r.layout.notification_template_expanded_base); mnotification.bigcontentview = mexpandedview; initexpandedplaybackactions(); initexpandedlayout(trackname, albumname, artistname, albumart); } mservice.startforeground(musicslide_service, mnotification);
stack trace:
05-29 18:10:40.240 29119-29119/com.driiinx.musicslide:main d/androidruntime﹕ shutting down vm 05-29 18:10:40.250 29119-29119/com.driiinx.musicslide:main e/androidruntime﹕ fatal exception: main process: com.driiinx.musicslide:main, pid: 29119 android.app.remoteserviceexception: bad notification posted package com.driiinx.musicslide: couldn't expand remoteviews for: statusbarnotification(pkg=com.driiinx.musicslide user=userhandle{0} id=1 tag=null score=0: notification(pri=0 contentview=com.driiinx.musicslide/0x7f03000b vibrate=null sound=null defaults=0x0 flags=0x62 kind=[null])) @ android.app.activitythread$h.handlemessage(activitythread.java:1363) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:136) @ android.app.activitythread.main(activitythread.java:5017) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595)
expanded notification:
private void initexpandedlayout(final string trackname, final string artistname, final string albumname, final bitmap albumart) { // track name (line one) mexpandedview.settextviewtext(r.id.notification_expanded_base_line_one, trackname); // album name (line two) mexpandedview.settextviewtext(r.id.notification_expanded_base_line_two, albumname); // artist name (line three) mexpandedview.settextviewtext(r.id.notification_expanded_base_line_three, "test"); // album art mexpandedview.setimageviewbitmap(r.id.notification_expanded_base_image, albumart); }
thanks in advance!
Comments
Post a Comment