Bitmap as Notification icon
I am android newbie, I have following code:
URL url = new URL(userpic);
URLConnection conn = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection)conn;
httpConn.setRequestMethod("GET");
httpConn.connect();
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream inputStream = httpConn.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
inputStream.close();
// make a Drawable from Bitmap to allow to set the BitMap
gdrawable = new BitmapDrawable(bitmap);
myNotification = new Notification(gdrawable, "Notification!", System.currentT开发者_运维技巧imeMillis());
for these code "Notification(gdrawable, "Notification!",System.currentTimeMillis());
" which will get an error, it need me to get int id.
How can I get gdrawable ID?
You can put image file in res->drawable (or drawable-hdpi,ldpi,mdpi), for example notify.png and use it myNotification = new Notification(R.id.notify, "Notification!", System.currentTimeMillis());
精彩评论