Prevent crash when download bitmap is invalid
This commit is contained in:
parent
d92fae163e
commit
672b0337cc
1 changed files with 10 additions and 5 deletions
|
@ -84,6 +84,8 @@ import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
import android.hardware.SensorEventListener;
|
import android.hardware.SensorEventListener;
|
||||||
|
@ -292,9 +294,12 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
} else {
|
} else {
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), msg.getAppData());
|
File file = new File(Environment.getExternalStorageDirectory(), msg.getAppData());
|
||||||
try {
|
try {
|
||||||
|
Bitmap bm = BitmapFactory.decodeFile(file.getPath());
|
||||||
|
if (bm != null) {
|
||||||
String url = MediaStore.Images.Media.insertImage(getContext().getContentResolver(), file.getPath(), file.getName(), null);
|
String url = MediaStore.Images.Media.insertImage(getContext().getContentResolver(), file.getPath(), file.getName(), null);
|
||||||
msg.setAppData(url);
|
msg.setAppData(url);
|
||||||
file.delete();
|
file.delete();
|
||||||
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue