开发者

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());

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜