GithubHelp home page GithubHelp logo

jessefarebro / android-mqtt-service Goto Github PK

View Code? Open in Web Editor NEW
243.0 28.0 98.0 135 KB

A simple MQTT Service that will keep running for the duration of your Android application using the Paho Java MQTT Client.

License: Apache License 2.0

Java 100.00%
android mqtt mqtt-client java-library

android-mqtt-service's Introduction

DEPRECATED

I would strongly recommend using the official Paho Android client.

Setup

  • Make sure to add the service to your AndroidManifest.xml
  • Edit the appropriate fields in the class with the information required

Simple Example

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
         android:versionCode="1"
         android:versionName="1.0">

         <receiver android:name=".MyReceiver" android:enabled="true" android:exported="false">
             <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
             </intent-filter>
         </receiver>

         <service android:name="com.jessefarebro.mqtt.MqttService" android:exported="false" />

         <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
</manifest>

License

Copyright 2013 Jesse Farebrother

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-mqtt-service's People

Contributors

jessefarebro avatar madlymad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-mqtt-service's Issues

ActiveMq+android-mqtt

when I close wife and reconnected
at de.eclipsemagazin.mqtt.push.MqttService.sendKeepAlive(MqttService.java:426)
at de.eclipsemagazin.mqtt.push.MqttService.keepAlive(MqttService.java:328)
at de.eclipsemagazin.mqtt.push.MqttService.onStartCommand(MqttService.java:171)
Would you mind answering this quesstions?

topic to keep alive

Sir. I donot think it a good idea to kepp alive by publishing a topic. As I have tested your code, to publish a topic needs sending at lease 7 or 8 bytes. while the mqtt heartbeat is only 2 bytes. That means the best advantage of mqtt is not longer existed.
We could send the MqttPingReq by modify the paho code. See : https://github.com/chinesejie/paho-for-android

retained messages not received

Hello,
I noticed that a topic's retained message is not received upon subscription. how would i go about fixing this?

Starting Service

Hi, sorry i am new in android programming. Can you describe more detail how to use this service?

I had tried made a new project in Android Studio,

then I have added the MqttService.java to my java/..../ folder,

add " " to AndroidManifest.xml

and according this http://www.techotopia.com/index.php/Implementing_an_Android_Started_Service_in_Android_Studio, i started MqttService's Service with this command
Intent intent = new Intent(this, MqttService.class);
startService(intent);
in my mainactivity

but it seems from my MQTT broker, that program doesn't connect to MQTT broker.

How to use this code correctly?

Thank you :)

MqttConnectOptions not used when connecting

Hey,

thanks for this great example.

I think i found a bug in your service.
You create an MqttConnectOptions object (mOpts) and set a clean session
(https://github.com/JesseFarebro/Android-Paho-MQTT-Service/blob/master/src/com/jessefarebro/mqtt/MqttService.java#L134-135).
However, mOpts is not used when connecting ( https://github.com/JesseFarebro/Android-Paho-MQTT-Service/blob/master/src/com/jessefarebro/mqtt/MqttService.java#L247).

Needs to be changed to "mClient.connect(mOpts);".
Found it when I tried to set username and password :)

Thanks,
Sebastian

Need More Details

Hi Jesse,
How can i handle the response messages from receiver(i am a sender)..messageArrived method will have all the responses (or) it will have only themessage which has been sent by user atlast . . .if u have any flow diagram for mqtt working actions for android pls provide .. ..

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.