Don't direct to market if no markets installed
The search intent cannot be resolved if there aren't any market apps installed, so it will cause Settings crashed by the ActivityNotFound exception. So we need to check if the market intent requst can be resolved. Then determine to notify user to direct the accessibility services to market to get TalkBack or not. Change-Id: I0f0d7b54eb5215e1a886315bb6816704384f6c59 Signed-off-by: Roger Chen <cxr514033970@gmail.com>
This commit is contained in:
@@ -179,9 +179,9 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
super.onResume();
|
||||
loadInstalledServices();
|
||||
updateAllPreferences();
|
||||
if (mServicesCategory.getPreference(0) == mNoServicesMessagePreference) {
|
||||
offerInstallAccessibilitySerivceOnce();
|
||||
}
|
||||
|
||||
offerInstallAccessibilitySerivceOnce();
|
||||
|
||||
mSettingsPackageMonitor.register(getActivity(), getActivity().getMainLooper(), false);
|
||||
RotationPolicy.registerRotationPolicyListener(getActivity(),
|
||||
mRotationPolicyListener);
|
||||
@@ -465,6 +465,17 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
final boolean offerInstallService = !preferences.getBoolean(
|
||||
KEY_INSTALL_ACCESSIBILITY_SERVICE_OFFERED_ONCE, false);
|
||||
if (offerInstallService) {
|
||||
String screenreaderMarketLink = SystemProperties.get(
|
||||
SYSTEM_PROPERTY_MARKET_URL,
|
||||
DEFAULT_SCREENREADER_MARKET_LINK);
|
||||
Uri marketUri = Uri.parse(screenreaderMarketLink);
|
||||
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
|
||||
|
||||
if (getPackageManager().resolveActivity(marketIntent, 0) == null) {
|
||||
// Don't show the dialog if no market app is found/installed.
|
||||
return;
|
||||
}
|
||||
|
||||
preferences.edit().putBoolean(KEY_INSTALL_ACCESSIBILITY_SERVICE_OFFERED_ONCE,
|
||||
true).commit();
|
||||
// Notify user that they do not have any accessibility
|
||||
|
Reference in New Issue
Block a user