Problem description
Calling Ti.Android.getCurrentActivity() always fails with an exception in the logs.
E/TiJSError( 1288): (main) [2,1195] - Message: Uncaught TypeError: Object #<Android> has no method 'getCurrentActivity'
Steps to reproduce
Use this simple app to test:
Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({
backgroundColor:'#fff',
fullscreen: true
});
win1.open();
Titanium.API.info("Activity: " + Titanium.Android.getCurrentActivity());
Changing from getCurrentActivity() to currentActivity (direct access to the property) works fine.
https://github.com/appcelerator/titanium_mobile/pull/6109
Verified with below Test Environment: 1. Mac OSX Yosemite 10.10 2. Appcelerator Studio, build: 4.0.0.201502041613 3. Titanium SDK, build: 4.0.0.v20150206131709 4. Titanium CLI, build: 3.6.0-dev 5. Alloy: 1.5.1 6. S Galaxy S5 with Android 4.4.2 Still seeing the same exception on the console. [ERROR] : TiExceptionHandler: (main) [0,81] - Message: Uncaught TypeError: Object #
Both _Titanium.Android.getCurrentActivity()_ and _Titanium.Android.getCurrentService_ have been removed from the documentation. _Titanium.Android.currentActivity_ and _Titanium.Android.currentService_ should be used instead. This bug is because docgen automatically generates getter methods for properties even if the getter is not implemented.
Resolving as a duplicate of TIDOC-2124 as when that is fixed, it will address this issue as well.