5
I’m making an application that needs the login Facebook. I was able to get all the right data, but I’m not able to save the profile photo in the database. I was able to display the photo on ImageView
, but when saving from error.
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
try {
foto = bundle.getString("fotoperfil");
if (foto != null) {
sendFile = new File(foto);
Log.i("sendfile", "" + sendFile);
Log.i("fotoface", "" + foto);
new DownloadImageTask((ImageView) findViewById(R.id.iv_perfil))
.execute(foto);
}
}catch (Exception e){
}
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
Log.i("foto-face", ""+bmImage);
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Log.i("foto-face","urldisplay "+urldisplay);
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
Log.i("foto-face","InputStream "+in);
mIcon11 = BitmapFactory.decodeStream(in);
Log.i("foto-face","mIcon11 "+mIcon11);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
Log.i("foto-face","bmImage "+bmImage);
}
}
The error occurs in the sendFile
, because I’m passing the photo URL. I don’t know if I should do the download and then save, if yes, you can help me?
E/AndroidRuntime: FATAL EXCEPTION: main Process: br.com.flirt, PID: 22156 java.lang.NullPointerException
at br.com.flirt.Utils.Util.getMd5FromFile(Util.java:162)
at br.com.flirt.EditarPerfilActivity$4$1.onResponse(EditarPerfilActivity.java:407)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5426)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
correct your question friend, when I saw I thought that I just wanted to take a photo of a url and was going to answer that for this, just vc give a screen print of your browser and then open the Gimp and separate the line enedereço and ready, took the photo of the url, ririririri
– Armando Marques Sobrinho
Paste the error log.
– Arthur Stapassoli