位图作为通知图标

时间:2011-05-24 10:22:50

标签: android

我是android新手,我有以下代码:

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

这些代码“Notification(gdrawable, "Notification!",System.currentTimeMillis());”会出错,需要我获取int id。 我如何获得可提取的身份证?

1 个答案:

答案 0 :(得分:1)

您可以将图像文件放在res-> drawable(或drawable-hdpi,ldpi,mdpi)中,例如notify.png 并使用它  myNotification =新通知(R.id.notify,                                             “通知!”,System.currentTimeMillis());