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() {
|
||||
String name = null;
|
||||
String projection[] = {
|
||||
ContactMethods.NAME
|
||||
};
|
||||
Cursor c = getContentResolver().query(
|
||||
Uri.withAppendedPath(Contacts.People.CONTENT_URI, "owner"), projection, null, null,
|
||||
null);
|
||||
if (c.getCount() > 0) {
|
||||
c.moveToFirst();
|
||||
name = c.getString(0);
|
||||
c.close();
|
||||
}
|
||||
|
||||
if (name == null || name.length() == 0) {
|
||||
Account account = Preferences.getPreferences(this).getDefaultAccount();
|
||||
if (account != null) {
|
||||
name = account.getName();
|
||||
try
|
||||
{
|
||||
String projection[] = {
|
||||
ContactMethods.NAME
|
||||
};
|
||||
Cursor c = getContentResolver().query(
|
||||
// TODO: For Android 2.0, needs to change to ContactsContract.People...
|
||||
Uri.withAppendedPath(Contacts.People.CONTENT_URI, "owner"), projection, null, null,
|
||||
null);
|
||||
if (c.getCount() > 0) {
|
||||
c.moveToFirst();
|
||||
name = c.getString(0);
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user