Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14324] Android: openPreferences( ) not working (after installed from google play)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-07-08T21:44:48.000+0000
Affected Version/sRelease 3.1.0, Release 3.2.0
Fix Version/s2013 Sprint 14, 2013 Sprint 14 API, Release 3.1.3, Release 3.2.0
ComponentsAndroid
Labelsqe-closed-3.1.3, supportTeam
ReporterEduardo Gomez
AssigneeHieu Pham
Created2013-06-20T21:26:43.000+0000
Updated2013-08-29T22:33:20.000+0000

Description

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;

Attachments

FileDateSize
logOpenPreferences.txt2013-06-20T21:26:43.000+0000154955

Comments

  1. Hieu Pham 2013-07-03

    Master PR: https://github.com/appcelerator/titanium_mobile/pull/4436
  2. Ping Wang 2013-08-27

    3_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/4608
  3. Olga Romero 2013-08-29

    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.

JSON Source