i implementing big picture view notification in android. first download imagefile using async task class , pushes downloaded image notification method. picture able download servers(because shows downloaded picture in .setlargeicon
) unable show in big style format.
below have done
private class notification extends asynctask<string, void, bitmap> { context c; string message; public notification(context context) { super(); this.c = context; } @override protected bitmap doinbackground(string... params) { inputstream in; string urls="http//myimagefile"; try { url url = new url(urls); httpurlconnection connection = (httpurlconnection) url.openconnection(); connection.setdoinput(true); connection.connect(); in = connection.getinputstream(); bitmap mybitmap = bitmapfactory.decodestream(in); return mybitmap; } catch (malformedurlexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } return null; } @override protected void onpostexecute(bitmap result) { super.onpostexecute(result); try { notificationmanager notificationmanager = (notificationmanager) c .getsystemservice(context.notification_service); intent intent = new intent(c, news.class); intent.putextra("alliswell", false); notification notification = new notificationcompat.builder(c) .setcontenttitle("title") .setcontenttext("message") .setsmallicon(r.drawable.ic_launcher) .setlargeicon(result) // downloaded bitmap able show here .setstyle(new notificationcompat.bigpicturestyle() .bigpicture(result)) // unable show in format .build(); // hide notification after selected notification.flags |= notification.flag_auto_cancel; notificationmanager.notify(1, notification); } catch (exception e) { e.printstacktrace(); } } }
update
i thinking maybe image size not expected displayed in notification box. tried .setstyle(new notification.bigtextstyle().bigtext(averylongstring))
, didnt work. think might doing wrong. wish me out because have implement functions correctly source (http://developer.android.com/reference/android/support/v4/app/notificationcompat.bigtextstyle.html) none seems work.
please doing wrong in above codes, grateful know, soo much.
Comments
Post a Comment