MQTT Eclipse Paho Android App basic - android

I am a beginner on android and MQTT. I have been trying to figure out how to make an app which send simple messages to the MQTT server(broker). I cant find any simple explanation. Even the sample apps are too complicated to grasp. I know I need the server address, host, client id, user id and password to connect but the question is HOW? Any help will be great, please just try to keep it simple as possible. Thanks!

Here is some tips to make your own mqtt service if you still have a question for this.
1. Server Application - mosquitto
Visit the site to get a binary or source code.
then build or install the mosquitto server for your operating system.
2. Running and testing the mosquitto broker.
Run the mosquitto broker server using command for example,
mosquitto -c $MOSQUITTO_HOME/conf/mosquitto.conf -d > $MOSQUITTO_HOME/log/mosquitto.log
Test it with the mosquitto_sub and mosquitto_pub executable in the bin directory where you installed the mosquitto broker.
my case is here,
mosquitto_sub -h 127.0.0.1 -t /test/1
mosquitto_pub -h 127.0.0.1 -t /test/1 -m "Hello Mosquitt"
3. Paho java client - mqtt client
You can use mqtt clients for the site list using any programming language you are familiar with.
I think you can use java client and android service is the best choice.
The java client might be needed for debugging and the core library.
you can choose either a jframe implementation for the standare jdk or
swt-plugin implementation for eclipse ide from the github.
You can also check my customized jframe version of mine.
it might be helpful how mqtt message can be published
and subscribed by the broker.
4. Paho client for android
Get a source code from github.
Be sure to have the core library from the java client library at the step 3.
You can use pre-compiled version of this core library from my github.
Then, compile and build app with whatever ide tools like eclipse+ADT
or android studio(recommended)
You can check the images since successfully installed the paho app
and can also refer my customized android app version from github.

Related

Running Node.Js on Android

So I know this has been questioned quite a lot. To be exact for example in these questions:
Run NodeJs server in Android
How to run my node.js project on android?
and
NodeJS on IOS/Android
Every option presented has a problem though:
I want to run it on my normal device so I would like to avoid installing another OS on my Device
Work on JXCore was stopped last month and (maybe as a result) I couldn't get it to compile (see Can't install jxcore-cordova)
The Android Port of NodeJs Anode has not been worked on since 2014 and wasn't really maintained back then anyways
The second answer in the second thread I linked to mentioned there is an official node distribution for Android now but apart from a link to the Browse-Website of the latest dist I couldn't find any info on how to actually use it
I also saw this but it seems like the device has to be connected to a PC (or similar) to run the adb shell commands while I would like to make it as a separate App
With the time that past since these questions have been posted and as the "best option" JXCore seem to be now unusable:
Is there a way to run a node.js application (a server in my case) on an Android device?
if you're wondering why I'd want this: I made a WebApp with a Node.Js server and I now want a version you can launch locally from your phone without requiring an Internet connection. This means the server needs to run on an Android phone.
I just had a jaw-drop moment - Termux allows you to install NodeJS on an Android device!
It seems to work for a basic Websocket Speed Test I had on hand. The http served by it can be accessed both locally and on the network.
There is a medium post that explains the installation process
Basically:
1. Install termux
2. apt install nodejs
3. node it up!
One restriction I've run into - it seems the shared folders don't have the necessary permissions to install modules. It might just be a file permission thing. The private app storage works just fine.
Dory - node.js
Great New Application
No Need to root your Phone and You Can Run your js File From anywere.
node.js runtime(run ES2015/ES6, ES2016 javascript and node.js APIs in android)
API Documents and instant code run from doc
syntax highlighting code editor
npm supports
linux terminal(toybox 0.7.4). node.js REPL and npm command in shell
(add '--no-bin-links' option if you execute npm in /sdcard)
StartOnBoot / LiveReload
native node.js binary and npm are included. no need to be online.
Update instruction to node js 8 (async await)
Download node.js v8.3.0 arm zip file and unzip.
copy 'node' to android's sdcard(/sdcard or /sdcard/path/to/...)
open the shell(check it out in the app's menu)
cd /data/user/0/io.tmpage.dorynode/files/bin (or, just type cd && cd .. && cd files/bin )
rm node
cp /sdcard/node .
(chmod a+x node
(https://play.google.com/store/apps/details?id=io.tempage.dorynode&hl=en)
You can use Node.js for Mobile Apps.
It works on Android devices and simulators, with pre-built binaries for armeabi-v7a, x86, arm64-v8a, x86_64. It also works on iOS, though that's outside the scope of this question.
Like JXcore, it is used to host a Node.js engine in the same process as the app, in a dedicated thread. Unlike JXcore, it is basically pure Node.js, built as a library, with a few portability fixes to run on Android. This means that it's much easier to keep the project up to date with mainline Node.js.
Plugins for Cordova and React Native are also available. The plugins provide a communication layer between the JavaScript side of those frameworks and the Node.js side. They also simplify development by taking care of a few things automatically, like packaging modules and cross-compiling native modules at build time.
Full disclosure: I work for the company that develops Node.js for Mobile Apps.
J2V8 is best solution of your problem. It's run Nodejs application on jvm(java and android).
J2V8 is Java Bindings for V8, But Node.js integration is available in J2V8 (version 4.4.0)
Github : https://github.com/eclipsesource/J2V8
Example : http://eclipsesource.com/blogs/2016/07/20/running-node-js-on-the-jvm/
the tutorial of how to build NodeJS for Android https://github.com/dna2github/dna2oslab/tree/master/android/build
there are several versions v0.12, v4, v6, v7
It is easy to run compiled binary on Android; for example run compiled Nginx: https://github.com/dna2github/dna2mtgol/tree/master/fileShare
You just need to modify code to replace Nginx to NodeJS; it is better if using Android Service to run node js server on the backend.
Node.js Frontend for Android
releases include signed apks
Android 4.4+
open source (GPLv2)
no root
frontend for Node.js for Mobile Apps by Janea Systems
which was announced earlier in this thread by one of its developers
which is a game-changer; great work!
at a high level:
the "exec in same process" tab:
includes a list of Node.js apps that are intended to run for a short period of time while the application remains open, and may only be executed one at a time
the "fork to separate process" tab:
includes a list of Node.js apps that are each executed in a separate foreground service in a distinct process, and are intended to hold long-running daemons (ex: various types of servers)

Live Video Streaming from android device to server

I need rtmp service url to store my camera video lively from my android devices.
according to this site
I have referred these following sites to implement live streaming at server side.
Helix server
Wowza server
Adboe Server
These servers are providing limited time span for free trials.but i need free one.
At last i found C++ RTMP Server
After working on this server i got to conclusion that the server code was written in C++. So i have added the C++ plugins to the eclipse to run. But i got the following errors
"Launch Failed. Binary Not Found"
To resolve this error i have installed " MinGW installer", but of no use.
Please refer this site
In this site, we have client code for android to implement live streaming from android device to server. Here the live video will be saved directly on to the server.
Can we generate the service url like "rtmp://live:live#128.122.151.108:1935/live/test.flv" using the above C++ server ?
Please guide me in implementing this.
Any help will be appreciated.
i install the Ubuntu server 12.04 in my system.
and i used these commands:
12.04 amd64/i386
install needed stuff
sudo apt-get install g++ subversion cmake make libssl-dev
fetch the latest repo version
cd /tmp
svn co --username anonymous --password "" https://svn.rtmpd.com/crtmpserver/trunk crtmpserver
cd crtmpserver/builders/cmake/
build it
./run
and now the crtmpserver is working successfully... for other questions refer this crtmpserver

Python + Django on Android

I am a Django developer and wanted to know if anyone has any idea of the possibilities of installing and developing on Django using an Android tablet such as the nexus 7. This seems like a reasonably powerful device, can be hooked up with a bluetooth keyboard, and has linux at the core of the OS.
So - is it possible to install Python and Django (or even Flask) on Android?
Yeah! its posible!, but you need install termux terminal on Android and later open the termux terminal and write:
apt-update
apt-install python
pip install django
django-admin startproject demo
cd demo
python manage.py runserver 0.0.0.0:8000
and its all, open localhost:8000 on your browser, see the picture:
We're developing PythonAnywhere to fill just this kind of niche. We tuned it to work with the iPad first. But it seems that the Nexus 7 is popular enough now that there might be enough demand to do the same thing for Android.
SL4A is a ridiculously excellent library/sdk/app for android and gives you a way to install a number of language/scripting runtimes and a thin veneer for accessing android functionality via the scripting frameworks.
It so happens that Python is an option, and I've used it with cherrypy (python framework) on Android. I haven't tried it with flask or Django but with some work it should be possible.
The app provides a way to download python, install it, and then a way to launch a python console or even just run python scripts.
http://code.google.com/p/android-scripting/
There was a downside to the python support originally, due to a silly bug/limitation in the Android SDK. This restricted the use of apk assets with _ underscore in the name. The details are faint in my mind, but I am subscribed to the issue in Android so I can follow up with the details about this issue. This would present a problem with many of the python frameworks, as underscores are part of python style.
One good way to accomplish a django development environment on a Nexus7 is to install a linux distro with a package manager alongside Android. Debian Kit hooks into the existing Android directories with symlinks instead of a chroot environment.
With that you can install Debian or Ubuntu and use apt-get and pip to install git, virtualenv, and all the packages and libraries you need to set up your development environment as you would on a desktop. You can write your code in DroidEdit, run the django development server in an Android terminal through ssh to localhost, and test your app right there in the browser on Android.
I could run on my Tablet (android) and smartphone (android) following the procedure below:
Install "GNUroot Debian" app;
Open "GNUroot Debian" app;
Run these commands:
apt-get update
apt-get install python3
apt-get install python3-setuptools
easy_install3 pip
pip install django
django-admin startproject demo
cd demo
python manage.py runserver
QPython suports Django on Android. I am running it on my android device.
Do you want this? :
p.s: I confess that article's original source is me. But isn't it nice? :)
Well if your end goal is to develop Web applications and host host them on your Android and since you had flask there why not give bottle.py a shot. It's just one file that you copy into your sl4a scripts folder and voila. Bottle is minimalist and near similar to flask. No rooting or Unix environments required.
Install termux terminal on Android and later open the termux terminal and write:
pkg install python
pip install django
django-admin startproject demo
vim demo/demo/settings.py
In settings.py
ALLOWED_HOSTS = ['*']
After save the settings.py and
python manage.py runserver 0.0.0.0:8000
and its all, open localhost:8000 on your browser
If you are developing an android app and you don't want to use Java, you might want to consider Kivy http://kivy.org/#home
If you are talking about having a web server running on Android and then running your django web app on that web server itself, there's a duplicate answer here - Web Server for Android

Eclipse : Creating Web Service via Apache Axis2 & Tomcat server 7

I'm trying to create a web service using eclipse. for that i have install tomcat server 7.and also i have set the "windows--->preference--->server(run time environment) & web service(Axis2 preference )" correctly.
when I try to create a dynamic web project it gives errors as follows.
Failed while installing Axis2 web services Core 1.1.
Reason:
Failed while installing Axis2 web services Core 1.1.
I can't manage this problem please help.
Lahiru,
When installing Apache Tomcat there are a few recommendations. First you want a fresh install with the latest download from http://tomcat.apache.org/download-70.cgi. I suggest Tomcat 7 as is latest version is backwards compatible.
From there you'll be able to use the .zip file after right-clicking on your Project and "Adding" it to you 'Java Build Path'. From there you will want to access your Server tab go to New->Server then select to 'Download additional adapter Servers' (or something close to that) and install a server adapter for Apache Tomcat. I use Geronimo which works pretty well along with their core version too.
If you're still having problems after reinstalling with a fresh copy try Stopping the Server and "re-publishing" or just "publishing" your instance of Tomcat. Sometimes that does the trick.
Hope this helps.

How to use Git on Android?

I have a desktop application using git for synchronization. I have also an android application which do the same as the desktop, but I don't know how to do the synchronization part on it. I haven't found any implementation of git on android. I found a jgit, but its unwell documented and I was not able to do even a commit with that.
I was thinking about remote commands to my git server from my android app, but this is really a tease for me.
Could you tell me if any other git implementation which can be used on android exists? If you have any idea how to solve that, please tell me.
Since this question was first posted, an Android app has been added to the market that can checkout Git repos, called Agit. It can't commit or push yet, but the clone/fetch/pull functionality is useful. The other issue is that a patched version of ConnectBot needs to be installed before Agit if you want to use SSH keys. If you already have ConnectBot, uninstall it first. I did not do this and ran into problems.
Edit: As of April 2021, the ability to push and pull has been added, however, it does seem to be very buggy as I have only been able to pull changes, but never push them.
Another option is using ASE. There seems to be a full-featured pure python implementation of git at https://github.com/jelmer/dulwich.
You can install https://github.com/termux/termux-app # https://play.google.com/store/apps/details?id=com.termux, then you just need to open the terminal and type:
apt update
apt install git
If the device is rooted, you can also use debian's debootstrap ( http://wiki.debian.org/Debootstrap ) application to create a debian/armel image, mount it in your android device and chroot to it, you have aptitude here so any package available for armel can be installed on your device (to install git: aptitude install git). Look here for information on how to install debian for your android: http://lanrat.com/install-debian-on-android/
Some other solutions that are now available, besided Agit, since this question was last answered:
A git & mercurial client for bitbucket called Bitbeaker
A git app from github
The Android Java IDE AIDE also has git functionality, so you can download from a git directory and if its an Android app modify and run it aswell.
You can also try Pocket Git: https://play.google.com/store/apps/details?id=com.aor.pocketgit
Pocket Git supports SSH (with passphrases, but private keys seem to have some issues) and HTTP, cloning, stage, unstage, commit, push and pull; create, delete and merge branches; and it also has a graphical log viewer and can show diffs.
Disclaimer: I'm the developer
A lot of already existing apps have been posted in the answers, but following links might be useful for those looking for their own implementation:
libgit2
This is a pure C implementation that claims to be highly portable. And the project also describes how to compile the sources for android platform. Now what needs to be done is to write a JNI binding for it. Even an executable binary would be sufficient in some cases.
HTTP (dumb) protocol
As an alternative, if one's purely interested in read operations from a repository, this protocol can be implemented over HTTP. There is also a smart protocol which depends on ssh and does differential transfers.
JGit Core Sources
Using just the core package from its sources. All the javax.* dependencies and other incompatible/alien classes will needed to be replaced with android alternatives though. But worth the effort if a pure Java implementation can be ported to android.
I would suggest to take a look at Gidder. It's Git server implementation for Android with user and repository management and also support dynamic DNS. You can easily store your code in your Android device and access using a WiFi connection.
MGit is the successor of SGit, and it works very well for me.
Update:
Comment underneath this answer by OP- (Nathan Osman)
unfortunately, I was forced to pull the application after some recent policy changes on the Play Store that required publishers to have their address displayed on the application's store page.
Original Answer
I've just (circa April 2013) published an app on the Play store named GitDroid. The application allows you to do the following:
clone remote repositories
pull from the remote and merge new revisions
view commits and browse files
The app cannot push to a remote or make local commits yet - this is planned for a future update.
This is how I would do it:
Well you likely want to define an interface for your synchronization needs.
You implement this interface in C for both desktop and android device (with the help of the NDK) by making the implementation use git (native).
Then, for the Android app, you code a JNI layer on top so that it exposes the interface to Java.
The tricky part would be to have the different git commands compile for Android: you'll have to rewrite makefiles.
Try SGit, it can commit & push over SSH with pssphrase-less keys and it is available on F-Droid. It is built on top of JGit. It is not perfect (yet) and JGit implementation is not as good as original Git, but looks usable.
You can install git on android with Termux. Just install from Play Store and run the command:
pkg install git
Reference: https://mvprepublic.com/blog/2020/04/08/how-to-run-git-on-android-devices/
Update: CubeGit has been removed because of changes inside the Android system and missing time / incentives to update.
Please pick one of the alternatives.
One more option is was CubeGit.
We have released CubeGit on Google Play a few days ago.
It is an interface to a cross compiled git binary and also supports local commits and push via ssh/http/https.
JGit - http://eclipse.org/jgit/

Categories

Resources