mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-24 02:12:15 -05:00
Issue 737
Don't crash if unable to find the owner name. The actual owner name fetching code will need to be updated for Android 2.0, but this will help for now.
This commit is contained in:
parent
044770f85b
commit
2f4b9a1178
@ -137,24 +137,48 @@ public class AccountSetupBasics extends K9Activity
|
|||||||
|
|
||||||
private String getOwnerName() {
|
private String getOwnerName() {
|
||||||
String name = null;
|
String name = null;
|
||||||
String projection[] = {
|
try
|
||||||
ContactMethods.NAME
|
{
|
||||||
};
|
String projection[] = {
|
||||||
Cursor c = getContentResolver().query(
|
ContactMethods.NAME
|
||||||
Uri.withAppendedPath(Contacts.People.CONTENT_URI, "owner"), projection, null, null,
|
};
|
||||||
null);
|
Cursor c = getContentResolver().query(
|
||||||
if (c.getCount() > 0) {
|
// TODO: For Android 2.0, needs to change to ContactsContract.People...
|
||||||
c.moveToFirst();
|
Uri.withAppendedPath(Contacts.People.CONTENT_URI, "owner"), projection, null, null,
|
||||||
name = c.getString(0);
|
null);
|
||||||
c.close();
|
if (c.getCount() > 0) {
|
||||||
}
|
c.moveToFirst();
|
||||||
|
name = c.getString(0);
|
||||||
if (name == null || name.length() == 0) {
|
c.close();
|
||||||
Account account = Preferences.getPreferences(this).getDefaultAccount();
|
|
||||||
if (account != null) {
|
|
||||||
name = account.getName();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.e(Email.LOG_TAG, "Could not get owner name, using default account name", e);
|
||||||
|
}
|
||||||
|
if (name == null || name.length() == 0) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
name = getDefaultAccountName();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.e(Email.LOG_TAG, "Could not get default account name", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name == null) {
|
||||||
|
name = "";
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDefaultAccountName()
|
||||||
|
{
|
||||||
|
String name = null;
|
||||||
|
Account account = Preferences.getPreferences(this).getDefaultAccount();
|
||||||
|
if (account != null) {
|
||||||
|
name = account.getName();
|
||||||
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user