I'm making an application that needs Facebook's login . I was able to get the data all right, but I can not save the profile photo in the database. I was able to display the photo in ImageView
, but when saving from the 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 sendFile
, because I'm passing the URL of the photo. I do not know if I should download it to later save, if so, can you 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)