我试图.setLargeIcon(getBitmapFromUrl(url),它没有设置。
public void showSmallNotification(String title,String message,String url,Intent intent){ Uri defaultSoundUri = …
如果您使用Glide,您可以像这样下载
GlideApp.with(this).asBitmap().skipMemoryCache(true).load(url).into(150, 150).get()
并且您必须在下载图像后设置通知,
您应该在致电前下载图片 setLargeIcon
setLargeIcon
您可以使用AsyncTask下载图像:
public class DownloadImageAndShowNotification extends AsyncTask<String, Void, Bitmap> { private Context mContext; private String mUrl; DownloadImageAndShowNotification(Context context, String url) { super(); this.mContext = context; this.mUrl = url; } @Override protected Bitmap doInBackground(String... params) { InputStream in; try { URL url = new URL(mUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoInput(true); connection.connect(); in = connection.getInputStream(); return BitmapFactory.decodeStream(in); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Bitmap result) { super.onPostExecute(result); // Build your notification with the bitmap } }