1. The pubnub service features full SDK support with over 70 platform and programming language. That gives more choice for developers for creative. In fact, the free network service always means more payment sacrificing better performance or leakage of personal data.
I have used one IoT platform service, until I notice my data is sending back to one famous Search Engine Analysis Server. At least, this delay my access to the IoT service.
The pubnub runs well on arduino. And good in mobile too.
I would like to make the BWaC traceable, using pubnub service in android application.
2. There have been two choice for android development, eclipse SDK or android studio. It would be easy for android studio for quick development and deployment.
2.1 The updated version is Android Studio 3.1.4. Start one new project,
2.2 Then, using Gradle (Including Android Studio), include the following line in build.gradle,
compile group: 'com.pubnub', name: 'pubnub-gson', version: '4.19.0'
While the following would be better,
implementation group: 'com.pubnub', name: 'pubnub-gson', version: '4.19.0'
Put these permission outside the <application> tag, preferable before the tag in the AndroidManifest.xml.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.bwac"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permi ssion.ACCESS_NETWORK_STATE"/> <application
2.3 Program in the MainActivity.java as follows,
Creating PNconnection,
PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.setSubscribeKey("demo"); pnConfiguration.setPublishKey("demo"); PubNub pubnub = new PubNub(pnConfiguration);
add listeners
pubnub.addListener(new SubscribeCallback()
subscribe to channel "bwac",
pubnub.subscribe().channels(Arrays.asList("bwac")).execute();
2.4 Print out message received from pubnub channel in
@Override public void message(PubNub pubnub, PNMessageResult message) { // Handle new message stored in message.message if (message.getChannel() != null) { } else { } System.out.println(message.getMessage() ); received( ); }
,
3. The run the arduino sketch in last blog,
Received by android application.
This test is passed.