Skip to content

Instantly share code, notes, and snippets.

@OtavioBraga
Created July 16, 2020 18:34
Show Gist options
  • Save OtavioBraga/25838881f6e06c937e0d4eaca0ce858a to your computer and use it in GitHub Desktop.
Save OtavioBraga/25838881f6e06c937e0d4eaca0ce858a to your computer and use it in GitHub Desktop.
### RNPushNotificationHelper
#Linha 263
String imageUrl = bundle.getString("pinpoint.notification.imageUrl");
if (imageUrl != null) {
Bitmap bigPicture = new DownloadImageAsync().execute(imageUrl).get();
notification.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bigPicture));
} else {
notification.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText));
}
# Fim do arquivo
class DownloadImageAsync extends AsyncTask<String, Void, Bitmap>
{
@Override
protected Bitmap doInBackground(String... params)
{
return this.loadImage(params[0]);
}
public Bitmap loadImage(String src)
{
try
{
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
}
catch (IOException e)
{
e.printStackTrace();
return null;
}
}
}
# Imports
import android.os.AsyncTask; (colocar na linha 32 logo abaixo de import android.net.Uri;)
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment