Вы можете использовать эту пользовательскую библиотеку (написанную с помощью Promise) для выполнения удаленного вызова.
function $http(apiConfig) {
return new Promise(function (resolve, reject) {
var client = new XMLHttpRequest();
client.open(apiConfig.method, apiConfig.url);
client.send();
client.onload = function () {
if (this.status >= 200 && this.status < 300) {
// Performs the function "resolve" when this.status is equal to 2xx.
// Your logic here.
resolve(this.response);
}
else {
// Performs the function "reject" when this.status is different than 2xx.
reject(this.statusText);
}
};
client.onerror = function () {
reject(this.statusText);
};
});
}
Пример простого использования:
$http({
method: 'get',
url: 'google.com'
}).then(function(response) {
console.log(response);
}, function(error) {
console.log(error)
});
Посмотрите на этот вопрос:
Использование Android-планшета в качестве MQTT-сервера
TLDR;
Возможно , посмотрите на чистый Java-брокер, такой как HiveMQ.
Вот брокерская библиотека MQTT, которую я адаптировал для Android: https://github.com/interaktionsbyran/moquette . Вам нужно будет создать собственное приложение для Android, хотя это просто библиотека .