Prevent crash when download bitmap is invalid

This commit is contained in:
Sylvain Berfini 2016-04-27 16:33:52 +02:00
parent d92fae163e
commit 672b0337cc

View file

@ -84,6 +84,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@ -292,9 +294,12 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
} else {
File file = new File(Environment.getExternalStorageDirectory(), msg.getAppData());
try {
Bitmap bm = BitmapFactory.decodeFile(file.getPath());
if (bm != null) {
String url = MediaStore.Images.Media.insertImage(getContext().getContentResolver(), file.getPath(), file.getName(), null);
msg.setAppData(url);
file.delete();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}