Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Android Paho client on Andriod OS 8 (Oreo) issue

Hi Kostas,
 
I've just tried running the Android Sample Application on Android 8.1 and wasn't able to recreate this issue, though this could be because the sample application is quite basic. It might be worth checking on Stack Overflow as well where there will be more general Android experts who may be able to help.
Kind regards,
 
James Sutton
Software Engineer - IoT Foundation - MQTT Open Source Projects
Ops Team - Wimbledon Project

Phone: 01962 815438 | Extension: x372454
E-mail: 
Personal Website: www.jsutton.co.uk
Find me on:     
IBM

Hursley Park
HursleySO212JN
United Kingdom
 
IBM United Kingdom Limited Registered in England and Wales with number 741598 Registered office: PO Box 41, North Harbour, Portsmouth, Hants. PO6 3AU
 
 
----- Original message -----
From: Kostas Kalogirou <kalgik@xxxxxxxxx>
Sent by: paho-dev-bounces@xxxxxxxxxxx
To: paho-dev@xxxxxxxxxxx
Cc:
Subject: [paho-dev] Android Paho client on Andriod OS 8 (Oreo) issue
Date: Mon, Jul 23, 2018 7:34 PM
 

Dear all,

I am using the library org.eclipse.paho.client (https://www.hivemq.com/blog/mqtt-client-library-enyclopedia-paho-android-service) to implement a simple Android MQTT client which connects to our MQTT server.

 

My Android MQTT client application worked properly until Android OS 7.x.  Unfortunately, it is not working properly for Android 8 (Oreo version). Specifically, I received the following exceptions:

 

·         android.app.ServiceConnectionLeaked: Activity.certh.gr.pedestrian.MainActivity has leaked ServiceConnection org.eclipse.paho.android.service.MqttAndroidClient$MyServiceConnection@4058b04 that was originally bound here

 

·         android.app.IntentReceiverLeaked: Service org.eclipse.paho.android.service.MqttService has leaked IntentReceiver org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver@b9978a0 that was originally registered here. Are you missing a call to unregisterReceiver()?

 

·         java.lang.IllegalStateException: Not allowed to start service Intent { cmp= certh.gr.pedestrian/org.eclipse.paho.android.service.MqttService }: app is in background uid UidRecord {61f9870 …………………}

 

I followed the recommendations from Google for Androdi 8.0 (https://developer.android.com/about/versions/oreo/android-8.0-changes#back-all and https://developer.android.com/about/versions/oreo/background ) , so I changed my class to extend JobIntentService and use the enqueueWork().

In the MainActivity’s onCreate()  I am calling the JobIntentService as following:

 

Intent intentService = new Intent(MainActivity.this, SimpleJobIntentService.class);
intentService.putExtra(
"label", intentService.toString());

SimpleJobIntentService.enqueueWork(
this, intentService);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
     startForegroundService(
new Intent(this, SimpleJobIntentService.class));
}
else {
     startService(
new Intent(this, SimpleJobIntentService.class));
}

 

where the SimpleJobIntentService is calling the MQTT connection (MqttConnectOptions)

I am using the paho library in gradle.build:

 implementation('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {

        exclude module: 'support-v4'

    }

 

I would like to ask you if there is any solution to this problem or if there is any newer version which is compliant with Android OS 8 (Oreo).

 

Regards,

Kostas

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev
 
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Back to the top