Problem description
The value of Ti.Android.currentActivity.intent.className and Ti.Android.currentActivity.intent.packageName is always undefined.
Steps to reproduce
This simple app will print out undefined in the logs:
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
fullscreen: true
});
win1.open();
Titanium.API.info("Class name: " + Titanium.Android.currentActivity.intent.className());
Titanium.API.info("Package name: " + Titanium.Android.currentActivity.intent.packageName);
an error is shown while running the test case Uncaught TypeError:Property'className'of object #
As per the documentation, these are creation-only properties.
[~cng] can we reconsider this one? With TIMOB-19679 this has become relevant again because unless you create the intent in
app.js
/alloy.js
you need the className/packageName of your app in order to create an alternative launch shortcut for it. Sunila mentions its creation only, but that doesn't say they cannot be read.This was closed as Invalid because the properties are creation only, but that's not what the ticket is about. It is about being able to read the properties after creation, not change.
PR: https://github.com/appcelerator/titanium_mobile/pull/7940 Use this test code
PR reviewed and merged. [~fokkezb] with this fixed, which other ticket is related to this?
[~msamah] Thanks, with this fixed TIMOB-19679 will be easier to implement for users, but that feature is still blocked by TIMOB-20459
Reverting this ticket: https://github.com/appcelerator/titanium_mobile/pull/7996 A bug was introduced in this PR where if you back out of the app using the back button and enter the app again, it will crash. Line causing bug is:- https://github.com/appcelerator/titanium_mobile/blob/50dec34783b243948ef3dfdde25750ef9ff478d8/android/titanium/src/java/org/appcelerator/titanium/proxy/IntentProxy.java#L63 https://github.com/appcelerator/titanium_mobile/blob/50dec34783b243948ef3dfdde25750ef9ff478d8/android/titanium/src/java/org/appcelerator/titanium/proxy/IntentProxy.java#L66 The crash occurs in the native code of android. Last debug point was in MessageQueue.class line 581:-
Will be leaving ticket open. [~fokkezb] Fyi.
Setting this for release 6.0.0 instead due to bug.
master PR: https://github.com/appcelerator/titanium_mobile/pull/8013 Testing code:
PR https://github.com/appcelerator/titanium_mobile/pull/8013 has been merged.
Verified the fix. The
Ti.Android.currentActivity.intent.className
&Ti.Android.currentActivity.intent.packageName
is notundefined
. Closing. Environment: Appc Studio : 4.7.0.201607070843 Ti SDK : 5.4.0.v20160705213725 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.5 Appc NPM : 4.2.8-1 Appc CLI : 5.4.0-29 Node: 4.4.4 Nexus 6 - Android 6.0.1