diff options
-rw-r--r-- | res/values/cm_strings.xml | 1 | ||||
-rw-r--r-- | src/com/android/settings/cyanogenmod/WeatherServiceSettings.java | 24 |
2 files changed, 21 insertions, 4 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 337c31c..128660e 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -1166,6 +1166,7 @@ <string name="weather_settings_title">Weather</string> <string name="weather_settings_no_services_prompt">No weather provider services installed</string> <string name="weather_settings_button">Provider settings</string> + <string name="weather_settings_activity_not_found">Unable to launch the settings menu of this provider</string> <string name="background_data_access">Background data access</string> <string name="allow_background_both">Over cellular data & Wi\u2011Fi</string> diff --git a/src/com/android/settings/cyanogenmod/WeatherServiceSettings.java b/src/com/android/settings/cyanogenmod/WeatherServiceSettings.java index 424f7de..0fae5fd 100644 --- a/src/com/android/settings/cyanogenmod/WeatherServiceSettings.java +++ b/src/com/android/settings/cyanogenmod/WeatherServiceSettings.java @@ -17,6 +17,7 @@ package com.android.settings.cyanogenmod; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -32,6 +33,7 @@ import android.os.UserHandle; import android.util.AttributeSet; import android.util.Log; import android.util.Xml; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -41,6 +43,7 @@ import android.widget.ImageView; import android.widget.ListView; import android.widget.RadioButton; import android.widget.TextView; +import android.widget.Toast; import com.android.internal.content.PackageMonitor; import com.android.internal.os.BackgroundThread; import com.android.settings.R; @@ -295,7 +298,22 @@ public class WeatherServiceSettings extends SettingsPreferenceFragment { private void launchSettingsActivity(WeatherProviderServiceInfo info) { if (info != null && info.settingsComponentName != null) { - mContext.startActivity(new Intent().setComponent(info.settingsComponentName)); + try { + mContext.startActivity(new Intent().setComponent(info.settingsComponentName)); + } catch (ActivityNotFoundException e) { + mHandler.post(new Runnable() { + @Override + public void run() { + Toast t = Toast.makeText(mContext, + R.string.weather_settings_activity_not_found, + Toast.LENGTH_LONG); + TextView v = (TextView) t.getView().findViewById(android.R.id.message); + if (v != null) v.setGravity(Gravity.CENTER); + t.show(); + } + }); + Log.w(TAG, info.settingsComponentName + " not found"); + } } } @@ -324,9 +342,7 @@ public class WeatherServiceSettings extends SettingsPreferenceFragment { CMSettings.Secure.putString(mContext.getContentResolver(), CMSettings.Secure.WEATHER_PROVIDER_SERVICE, info.componentName.flattenToString()); - if (info.settingsComponentName != null) { - mContext.startActivity(new Intent().setComponent(info.settingsComponentName)); - } + launchSettingsActivity(info); notifyDataSetChanged(); } |