【发布时间】:2017-12-14 15:43:16
【问题描述】:
这是我的preference.xml的一部分。
<Preference
android:summary="Write me"
android:title="Title">
<intent
android:action="android.intent.action.VIEW"
android:data="mailto:support@xxxxx.com"
/>
</Preference>
当我单击此首选项时,我遇到了崩溃
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=mailto:xxxxxx.x@x-xxxxxx.xxx }
我做错了什么?
这是我的首选课程。我读了很多标题,但没有找到答案:
public class Preferences extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
public static final String KEY_PREF_INSTANT_PRINT = "instantPrinting";
public static final String KEY_PREF_INSTANT_PRINT_SCREEN = "instantPrintingScreen";
public static final String KEY_PREF_PAY_BUTTONS = "paymentTypes";
@Override
protected void onResume() {
super.onResume();
getPreferenceScreen().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
}
@Override
protected void onPause() {
super.onPause();
getPreferenceScreen().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
addPreferencesFromResource(R.xml.preference);
Preference instantPrintingScreen = findPreference(KEY_PREF_INSTANT_PRINT_SCREEN);
instantPrintingScreen.setEnabled(sharedPref.getBoolean(KEY_PREF_INSTANT_PRINT, false));
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
if (key.equals(KEY_PREF_INSTANT_PRINT)) {
Preference connectionPref = findPreference(KEY_PREF_INSTANT_PRINT_SCREEN);
connectionPref.setEnabled(sharedPreferences.getBoolean(key, false));
}
}
}
【问题讨论】:
标签: android