[TIMOB-10214] TiAPI: Expose broadcast receiver API
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-02-12T18:51:50.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | Release 3.1.0, 2013 Sprint 03, 2013 Sprint 04 Core, 2013 Sprint 04 |
Components | TiAPI |
Labels | core, module_api, qe-testadded |
Reporter | Rick Blalock |
Assignee | Allen Yeung |
Created | 2012-07-27T14:00:40.000+0000 |
Updated | 2013-10-23T23:15:37.000+0000 |
Description
In order to complete this project for the customer we need the receiver API exposed in Titanium - http://developer.android.com/guide/topics/manifest/receiver-element.html
Use case: We need to use the broadcast / receiver API to launch a transparent activity that sits on top of the phone app when a phone call is received and during the call. Josh has some more details and a sample native app.
This feature request has been put on a low priority list following the discussion with services team.
Why?
See my example native code in TIMOB-10066.
The goal stated here is to be able to have JS code that is executed by a broadcast receiver. The broadcast receiver is registered in AndroidManifest.xml for the application. For example:
Test case: 1. Run a titanium app with the following code snippet app.js
mybroadcast.js
2. Click on 'register broadcast receiver' 3. Toggle airplane mode and you should see the hello world message print out. _______________________________________________________________________________ 4. click on 'unregister broadcast receiver' 5. Toggle airplane mode, and you should NOT see the hello world message. ______________________________________________________________________________ 6. Click on 'register broadcast receiver' 7. Back out of the app 8. Toggle airplane mode again, and you should see the hello world message _______________________________________________________________________________ 9. Change the create broadcast call to use the onReceive property and run through steps 1-8 again.
PR: https://github.com/appcelerator/titanium_mobile/pull/3837
Hi, Trying to use this to receive the android.intent.action.BOOT_COMPLETED into a Titanium App (To then start a small service). Is this possible... struggling to get it working. Thanks!
Tested with: SDK:3.1.0.v20130319222852 Studio: 3.1.0.201303091040 Device: Samsung galaxy note(v 2.3.6) Works as expected
Hi - did you get this to work with the BOOT_COMPLETED event? If so, are you able to share any example code? Thanks!
BOOT_COMPLETED probably won't work with this API since you need the app to be launched first to register the broadcast event. You may have to write a module to hook up the BOOT_COMPLETED broadcast intent.
Thanks - we will be having the App launch first before we need it to accept the BOOT_COMPLETED event. So we don't want that event if the user has never opened the App. Does that make sense? Thanks!
You might want to see if this module can assist you with your requirement. If not you can always fork and make adjustments as needed. https://github.com/benbahrenburg/benCoding.Android.Tools/blob/master/documentation/bootreceiver.md
Thanks Ben - that looks just right!