-1

I want to start a java service from a phonegap plugin so I can do some background processing for the application. I am using cordova-2.0.0 . Now i found some background service plugins for cordova-1.8.1 but they didint run in 2.0.0 . I would really appreciate if you could help me.

-- Aayush Shrestha

aayush shrestha
  • 1,858
  • 2
  • 17
  • 33

1 Answers1

2

You definitely need a plugin to access native code of android from phonegap.

Have a look at this site: https://github.com/phonegap/phonegap-plugins/tree/master/Android

It is full with plugins. Probably you found yours on this page.

Unfortunately phonegap is being developed so fast that the plugins dont always keep up. So you either have the choice of going down in Version with phonegap to use the "old" plugin, write your own plugin or depending on what you would like to do you could start your background service already when the app itself starts, or with a delay etc.

EDIT: Check here to find the knowledge of how to write a plugin. http://docs.phonegap.com/en/2.0.0/guide_plugin-development_android_index.md.html

As for an android service(in the background) there are different ways. Depending on what you would like to do. I always like to use the ScheduledExecutorService http://developer.android.com/reference/java/util/concurrent/ScheduledExecutorService.html

SunnySonic
  • 1,318
  • 11
  • 37
  • I saw that plugin. But it is written for cordova-1.8.1 . Which is not properly working in cordova-2.0.0. And i cannot debug it because its only got jar file. So I'd just like to know how to start a native service from the plugin So i could write my own. – aayush shrestha Sep 26 '12 at 15:28
  • Please see my edit above. I take it that you know how to write your service. Now you just need to pack it inside a plugin. Posted you a howto from phonegap above. hope that helps. – SunnySonic Sep 26 '12 at 15:40