gpt4 book ai didi

android - 位图作为通知图标

转载 作者:行者123 更新时间:2023-11-30 04:40:14 25 4
gpt4 key购买 nike

我是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。如何获得 gdrawable ID?

最佳答案

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

关于android - 位图作为通知图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6108996/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com