Comments (9)
Is there anything else within the logcat? I would expect to see further information in the logcat or within the data (which seems to be missing).
Within the logcat, look for either:
"Processing config JSON from background service failed"
or
"setConfiguration failed"
from bgs-core.
Thank you for the quick response!
On the last failure I get the following:
02-14 16:17:00.279: D/ServiceDetails(19062): setConfiguration failed
02-14 16:17:00.279: D/ServiceDetails(19062): android.os.RemoteException
02-14 16:17:00.279: D/ServiceDetails(19062): at com.red_folder.phonegap.plugin.backgroundservice.BackgroundService$1.setConfiguration(BackgroundService.java:278)
02-14 16:17:00.279: D/ServiceDetails(19062): at com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic$ServiceDetails.setConfiguration(BackgroundServicePluginLogic.java:400)
02-14 16:17:00.279: D/ServiceDetails(19062): at com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic.execute(BackgroundServicePluginLogic.java:160)
02-14 16:17:00.279: D/ServiceDetails(19062): at com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePlugin$1.run(BackgroundServicePlugin.java:48)
02-14 16:17:00.279: D/ServiceDetails(19062): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-14 16:17:00.279: D/ServiceDetails(19062): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-14 16:17:00.279: D/ServiceDetails(19062): at java.lang.Thread.run(Thread.java:841)
02-14 16:17:00.449: I/chromium(19062): [INFO:CONSOLE(53)] "Error set config", source: file:///android_asset/www/js/service.js (53)
02-14 16:17:00.449: I/chromium(19062): [INFO:CONSOLE(54)] "Error: undefined", source: file:///android_asset/www/js/service.js (54)
02-14 16:17:00.449: I/chromium(19062): [INFO:CONSOLE(55)] "{"TimerMilliseconds":60000,"LatestResult":{},"Configuration":{},"ErrorCode":-99,"Success":false,"RegisteredForBootStart":false,"TimerEnabled":false,"ServiceRunning":true}", source: file:///android_asset/www/js/service.js (55)
from bgs-core.
Could you provide the contents of the setConfig() from your service class (equivalent of MyService.java)?
I suspect it is throwing an error while processing your config which is not being handled locally (with setConfig) thus is being returned to the plugin as a RemoteException.
from bgs-core.
java side:
protected void setConfig(JSONObject config) {
fifo = new LinkedList();
boolean pubnubFlag = false;
try {
if (config.has("pubnub")){
if(config.getString("pubnub").equals("active")) {
pubnubFlag = true;
String notifyMessage = "";
//notifyUserBigView(notifyMessage);
} else {
pubnubFlag = false;
}
if(config.getString("pubnub").equals("on")) {
notifyUserService();
}
}
} catch (JSONException e) {
}
if(pubnubFlag) {
subscribe();
}else{
pubnub.unsubscribe("hello");
}
Log.d(TAG, "get config");
}
from bgs-core.
I'd suspect that your getting an exception in there. First I'd comment out the entire contents of the setConfig to confirm it is causing the exception.
Assuming it is;
Add a Log.d on the JSONException block. Also add try/ catch round your subscribe/ unsubscribe. Basically saturate the method with Log.d to narrow down what is throwing the exception
from bgs-core.
OK.
I tried to take it step by step.
The first thing that I added to the setConfig function which cause the Error was the "notifyUserService();" function
This function trigger a notification as followed:
private void notifyUserService() {
Intent i = new Intent();
i.setAction("com....");
i.putExtra("id", Integer.toString(NOTIFICATION_ID));
PendingIntent resultPendingIntent = PendingIntent.getBroadcast(this, 0, i,PendingIntent.FLAG_CANCEL_CURRENT );
Uri uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).
setSmallIcon(R.drawable.logo2).
setContentTitle("....").
setContentText(".....");
mBuilder.setContentIntent(resultPendingIntent);
final Notification notification = mBuilder.build();
startForeground(NOTIFICATION_ID, notification);
notification.notify();
}
This caused the error:
02-15 00:03:59.209: D/ServiceDetails(12580): setConfiguration failed
02-15 00:03:59.209: D/ServiceDetails(12580): android.os.RemoteException
02-15 00:03:59.209: D/ServiceDetails(12580): at com.red_folder.phonegap.plugin.backgroundservice.BackgroundService$1.setConfiguration(BackgroundService.java:278)
02-15 00:03:59.209: D/ServiceDetails(12580): at com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic$ServiceDetails.setConfiguration(BackgroundServicePluginLogic.java:400)
02-15 00:03:59.209: D/ServiceDetails(12580): at com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePluginLogic.execute(BackgroundServicePluginLogic.java:160)
02-15 00:03:59.209: D/ServiceDetails(12580): at com.red_folder.phonegap.plugin.backgroundservice.BackgroundServicePlugin$1.run(BackgroundServicePlugin.java:48)
02-15 00:03:59.209: D/ServiceDetails(12580): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-15 00:03:59.209: D/ServiceDetails(12580): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-15 00:03:59.209: D/ServiceDetails(12580): at java.lang.Thread.run(Thread.java:841)
02-15 00:03:59.249: I/chromium(12580): [INFO:CONSOLE(51)] "Error set config", source: file:///android_asset/www/js/service.js (51)
02-15 00:03:59.249: I/chromium(12580): [INFO:CONSOLE(52)] "Error: undefined", source: file:///android_asset/www/js/service.js (52)
02-15 00:03:59.249: I/chromium(12580): [INFO:CONSOLE(53)] "{"TimerMilliseconds":60000,"LatestResult":{},"Configuration":{},"ErrorCode":-99,"Success":false,"RegisteredForBootStart":false,"TimerEnabled":false,"ServiceRunning":true}", source: file:///android_asset/www/js/service.js (53)
from bgs-core.
You could really do with getting the actual exception. If you wrap you notifications function with a try/ catch then log.d the exception message and stack trade that will help identify why your code is failing.
from bgs-core.
I fixed it!
added synchronized before firing the notification,
synchronized(notification){
notification.notify();
}
from bgs-core.
Good to here.
from bgs-core.
Related Issues (20)
- Error Occurs on startService(success,failed) ;
- Backgound service stops when the app is terminated HOT 2
- creating multiple service class HOT 2
- Does this plugin works with local notifications? HOT 2
- Integrating with NotificationListenerService would it work?
- If Background Service is Running Through Any Local Notification or Alerts?
- Where to put MyService.java in IONIC? Android is unable to find/bind. HOT 2
- Error on Boot
- Its not working in Android 10 HOT 1
- running cordova inside of a service HOT 5
- What is service will not running when app closed ? HOT 8
- It's Possible MyService.java Call Javascript Function ? HOT 3
- ideas to make a service to continue receiving push notifications HOT 2
- Build Android Error HOT 13
- Add method onCleanup to override
- Can I load a third party android library?
- Service starting but restart on exit failing
- Application run but factory is empty
- How to stop a Countdown when the App is backgrounded (Xamarin forms) HOT 2
- Detect the volum up pression in background service
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bgs-core.