[TIMOB-15324] Android: Expose the status of the current activity (foreground or background) to module developers
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2013-10-28T21:24:30.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | 2013 Sprint 22, 2013 Sprint 22 API, Release 3.2.0 |
| Components | Android |
| Labels | module_module, qe-testadded |
| Reporter | Ping Wang |
| Assignee | Ping Wang |
| Created | 2013-09-23T23:56:08.000+0000 |
| Updated | 2013-11-20T00:08:06.000+0000 |
Description
Cloudpush module wants to know if the current Titanium activity is in the foreground which is between a call to onResume() until a call to onPause().
PR: https://github.com/appcelerator/titanium_mobile/pull/4836 For FR: 1. Create a new module.
2. Add a new method in the module source file test/src/com/appcelerator/test/TestModule.java:3. Add the above module to a mobile project and paste the below code to app.js.@Kroll.method public boolean isCurrentActivityInForeground() { return TiApplication.isCurrentActivityInForeground(); }4. Run the project. Click the button. Should see an alert "foreground: true".var test = require("com.appcelerator.test"); var win = Ti.UI.createWindow({ backgroundColor: "white" }); var b = Ti.UI.createButton({ title: "isCurrentActivityInForeground" }); b.addEventListener("click", function(){ alert("foreground: " + test.isCurrentActivityInForeground()); }); win.add(b); win.open();[~pwang] [~hpham] Could you please let me know when and which version of Titanium SDK I can use, that contains this code change? I may want to implement this on ti.cloudpush side earlier.
[~plv], the PR was merged yesterday so it should be in the latest [CI build](http://builds.appcelerator.com.s3.amazonaws.com/index.html#master)