Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12411] Android: Ti.Android.getCurrentActivity() fails with an exception

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionDuplicate
Resolution Date2015-02-28T15:42:51.000+0000
Affected Version/sn/a
Fix Version/sRelease 4.0.0
ComponentsAndroid
Labelsqe-4.0.0
ReporterDavide Cassenti
AssigneeGary Mathews
Created2013-01-24T11:29:38.000+0000
Updated2015-03-03T22:45:35.000+0000

Description

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.

Comments

  1. Gary Mathews 2014-09-16

    https://github.com/appcelerator/titanium_mobile/pull/6109
  2. Khushbu Agrawal 2015-02-09

    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 # has no method 'getCurrentActivity' [ERROR] : TiExceptionHandler: (main) [0,81] - Source: Titanium.API.info("Activity: " + Titanium.Android.getCurrentActivity()); So reopening the ticket.
  3. Gary Mathews 2015-02-11

    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.
  4. Ingo Muschenetz 2015-02-28

    Resolving as a duplicate of TIDOC-2124 as when that is fixed, it will address this issue as well.

JSON Source