{ "id": "166358", "key": "TIMOB-24440", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2017-03-02T19:01:56.000+0000", "created": "2017-02-28T22:20:27.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [ { "id": "18154", "name": "Release 6.0.1", "archived": false, "released": true, "releaseDate": "2016-12-21" } ], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-02T19:01:56.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h5. Issue Description\r\n\r\ngetapplicationcontext() method is present in android native code to get application context.\r\n\r\nThis is the code that needs to be executed in app.js\r\n\r\n{code:js}\r\nvar localytics = require('com.localytics.android.Localytics');\r\nlocalytics.autoIntegrate(application context);\r\n{code}\r\n\r\nCustomer is not able to get current application context. He tried lot of things.\r\n\r\n{code:js}\r\nvar context = require(\"android.context.Context\");\r\nvar appContext = context.getApplicationContext();\r\n{code}\r\n\r\nThis one throwing error stating could not find getapplicationContext method.\r\n\r\nhttps://developer.android.com/reference/android/content/Context.html#getApplicationContext()", "attachment": [], "flagged": false, "summary": "Android: get Application context ", "creator": { "name": "rramirez", "key": "rramirez", "displayName": " Ricardo Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "rramirez", "key": "rramirez", "displayName": " Ricardo Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "408233", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "The above code only requires the class and tries to call a method on that, which will never work, because it isn't an instance, just a class. [~cwilliams] may be able to help where to call the {{getApplicationContext}} from. Maybe this *could* work:\r\n{code:js}\r\nvar activity = new Activity(Titanium.App.Android.getTopActivity());\r\nvar appContext = activity.getApplicationContext();\r\n{code}\r\nBecause the {{android.app.Activity}} class indirectly inherits from the {{android.content.Context}} class.\r\n\r\nOtherwise, and I'm not sure if that's possible so far, you could try to require {{org.appcelerator.titanium.TiApplication}} (the internal classes) to call {{TiApplication.getInstance().getApplicationContext()}}. But I think those classes are not generated so far.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-03-01T18:27:04.000+0000", "updated": "2017-03-01T18:34:08.000+0000" }, { "id": "408317", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~rramirez], please also check my comments in TIMOB-24420 which is exactly about the same issue.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-03-02T17:20:02.000+0000", "updated": "2017-03-02T17:20:02.000+0000" }, { "id": "408320", "author": { "name": "rramirez", "key": "rramirez", "displayName": " Ricardo Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thanks ! [~nmishra] please take a look ", "updateAuthor": { "name": "rramirez", "key": "rramirez", "displayName": " Ricardo Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-03-02T18:09:36.000+0000", "updated": "2017-03-02T18:09:36.000+0000" }, { "id": "408402", "author": { "name": "rramirez", "key": "rramirez", "displayName": " Ricardo Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Be my guest. ", "updateAuthor": { "name": "rramirez", "key": "rramirez", "displayName": " Ricardo Ramirez", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-03-02T19:01:32.000+0000", "updated": "2017-03-02T19:01:32.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }