MQTT: Android Simple Connect

From OnnoWiki
Revision as of 05:23, 26 March 2022 by Onnowpurbo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

setting.gradle

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
        maven {
              url "https://repo.eclipse.org/content/repositories/paho-releases/"
        }
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
                url "https://repo.eclipse.org/content/repositories/paho-releases/"
        }
    }
}


build.gradle app

dependencies {
   implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.0.2' exclude module: 'support-v4'
}


AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="itts.onno.hms.ittsmqttsimpleconnect">

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
       ..............
       <service android:name="org.eclipse.paho.android.service.MqttService" >
       </service>
    </application>

</manifest>


Referensi