Fire Chrome Alarms from background service when using Google Chrome apps

Experiment with the Mobile Chrome Apps API: ( https://github.com/MobileChromeApps/mobile-chrome-apps )

What I am trying to achieve is logging my chrome alarms without having to roughly trigger the main application activity as this results in a poor user experience.

Challenge: I specified chome.alarm, which registers successfully when I open the app (like cca run android). These alarms are specified in the background.js file, which is declared as a background script in the manifest.json file.

I wanted them to be automatically logged on load, so I implemented a background service and thought I could just call the application to log the alarms specified in the background.js file. However, the only way I can find so far to achieve this is to call to launch the main application activity via an Intent from a background service, as explained in more detail below.

On load, my background service just calls:

//Launch main activity..
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.company.appname");
startActivity(LaunchIntent);

      

The above application launches the application in its main activity and the above chrome files are registered at will. Happy Days! The massive downside to this, of course, is that no user wants the main activity popup to open on boot.

Please advise if there is a less clunky way to have chrome.alarm listed in background.js registered when loaded by background thread. I don't want to open the mainActivity of the application, but currently the only way I can see so far is to get them to register. It is advisable not to log these alarms from the Android SDK as I intend to stay as close to using the web API as possible and want to use background.js as a hook for this to keep communicating with chrome web apps like the Android platform.

What I've done:

A cca (chrome mobile web app) app that registers a background service natively (I'm extending BackgroundService) as a plugin and registers it to run at boot time. This is the only "native Android" code for loading an application at boot time.

Once the android is loaded, this background service then simply starts startActivity (LaunchIntent) to open the app. With this, my chrome.alarm specified in my background.js file will be registered successfully. If I don't, my chrome wake-up call specified in background.js doesn't register until I manually open the main apps app. So I am using backgroundService to open the main app activity. It's not ideal at all, I would just like to register chrome.alarm somehow without roughly launching the main application actions window.

Is there a call I can place in my BackgroundService to have only the chrome.alarms contained in my background.js file read and registered to run? Thank you for your time.

+3


source to share


1 answer


First, thanks for using Chrome Apps for Mobile! (Note: I am working on a project)

Sorry that our current boot file is "gross" and "awkward" and we agree that it is. You can track this issue for progress in our efforts to replace our current strategy of Background-scripts-embedded-in-main-Activity-webview with real background maintenance and multi-window support. Basically, you have accurately described our plan and existing restrictions.



This work is actually planned for the near future and will certainly be completed by the end of the year.

As well chrome.alarms

, this feature is very important for chrome.gcm

and chrome.tcpServer

(among other reasons).

+3


source







All Articles