mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-18 11:58:09 +00:00
Fixed illegal state exception that can happen
This commit is contained in:
parent
8b1b81959e
commit
3fbb7eeab4
3 changed files with 15 additions and 14 deletions
|
|
@ -24,7 +24,11 @@ import android.content.Context;
|
|||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.ContactsContract;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
|
|
@ -35,12 +39,6 @@ import org.linphone.core.tools.Log;
|
|||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.AsyncContactsData> {
|
||||
@SuppressLint("InlinedApi")
|
||||
public static final String[] PROJECTION = {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ public final class LinphoneService extends Service {
|
|||
private Application.ActivityLifecycleCallbacks mActivityCallbacks;
|
||||
private boolean misLinphoneContextOwned;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
|
|
|||
|
|
@ -180,12 +180,16 @@ public class FileUtils {
|
|||
|
||||
public static String getRealPathFromURI(Context context, Uri contentUri) {
|
||||
String[] proj = {MediaStore.Images.Media.DATA};
|
||||
Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
String result = cursor.getString(column_index);
|
||||
cursor.close();
|
||||
return result;
|
||||
try {
|
||||
Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
String result = cursor.getString(column_index);
|
||||
cursor.close();
|
||||
return result;
|
||||
}
|
||||
} catch (IllegalArgumentException iae) {
|
||||
Log.e("[File Utils] Failed to get real path from uri: ", iae);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue