Code Monkey home page Code Monkey logo

Comments (9)

Red-Folder avatar Red-Folder commented on June 25, 2024

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.

amitashkenazi avatar amitashkenazi commented on June 25, 2024

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.

Red-Folder avatar Red-Folder commented on June 25, 2024

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.

amitashkenazi avatar amitashkenazi commented on June 25, 2024

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.

Red-Folder avatar Red-Folder commented on June 25, 2024

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.

amitashkenazi avatar amitashkenazi commented on June 25, 2024

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.

Red-Folder avatar Red-Folder commented on June 25, 2024

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.

amitashkenazi avatar amitashkenazi commented on June 25, 2024

I fixed it!
added synchronized before firing the notification,
synchronized(notification){
notification.notify();
}

from bgs-core.

Red-Folder avatar Red-Folder commented on June 25, 2024

Good to here.

from bgs-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.