Issue
Looks like an Android Service (TIMOB-14179) may prevent the preferences window be opened.
This is another use case where the developer noticed that after installing his app from Google Play, he couldn't open the preferences window for the first time the app ran.
Yet another way one can re-produce it on an emulator. After a fresh install, the first time the app runs, if you try to open the preferences window, you got:
- Runtime Error:
Message:
Uncaught Error: Java Exception occurred
Source:
Ti.UI.Android.openPreferences();
Tested on
HTC One (Android 4.1.2)
preferences.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:title="系統設置">
<CheckBoxPreference
android:key="wifi_only"
android:title="Download over Wi-Fi Only"
android:summary="Enable this option to prevent you from downloading over a mobile network."
android:defaultValue="false" />
</PreferenceScreen>
Docs
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Android-method-openPreferences
A sample
- app.js
var prefs = require('preferences');
var args = {
title: 'Preferences'
};
var win = new prefs(args);
win.open();
- preferences.js
// See:
// platform/android/res/xml/preferences.xml
// platform/android/res/values/array.xml
// Similar files MUST be present at build time or
// Titanium.UI.Android.openPreferences() will simply
// do nothing.
function prefs(_args) {
var win = Ti.UI.createWindow({
title: _args.title
});
var btn = Titanium.UI.createButton({
title: 'Click to Open Preferences'
});
btn.addEventListener('click', function() {
Titanium.UI.Android.openPreferences();
});
win.add(btn);
return win;
};
module.exports = prefs;
Master PR: https://github.com/appcelerator/titanium_mobile/pull/4436
3_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/4608
Tested the above code and did not get a runtime "Uncaught Error: Java Exception occurred" Appcelerator Studio, build: 3.1.3.201308292449 Titanium SDK, build: 3.1.3.v20130828171413 CLI: 3.1.2 alloy 1.2.1 Device: GalaxyS4 Android version 4.2.2 Closing as fixed.