I have problem with Bitmap. I call method:
mStickerListener.onStickerClick(
BitmapFactory.decodeResource(getResources(),
Integer.parseInt(stickerList.get(getLayoutPosition()))));
But the problem is my stickerList.get(getLayoutPosition())))
returns String value(link), because I show images with Picasso, so I get exception:
java.lang.NumberFormatException: For input string: "https://firebasestorage.googleapis.com/v0/b/templatestest-38e3f.appspot.com/o/templates%2Fanimals_templates%2Fdog.png?alt=media&token=3e31962f-df24-493a-91c9-273f3496fa89"
Please, help me solve it!
First of all the exception you are getting says that you are trying to convert a string "https://firebasestorage.googleapis.com/v0/b/templatestest-38e3f.appspot.com/o/templates%2Fanimals_templates%2Fdog.png?alt=media&token=3e31962f-df24-493a-91c9-273f3496fa89" to Integer
The method you are using BitmapFactory.decodeResource takes id of the resource as an input not an url.
You need to use the following code to get bitmap from the url:
try {
URL url = new URL("https://firebasestorage.googleapis.com/v0/b/templatestest-38e3f.appspot.com/o/templates%2Fanimals_templates%2Fdog.png?alt=media&token=3e31962f-df24-493a-91c9-273f3496fa89");
Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch(IOException e) {
System.out.println(e);
}
Also, add the Internet permission in AndroidManifest.xml as you will be accessing internet for getting stream from an url.
<uses-permission android:name="android.permission.INTERNET" />