Loading existing .html file with android WebView
mWebView.loadUrl("file:///android_asset/myfile.html");
References
https://stackoverflow.com/questions/4027701/loading-existing-html-file-with-android-webview
mWebView.loadUrl("file:///android_asset/myfile.html");
References
https://stackoverflow.com/questions/4027701/loading-existing-html-file-with-android-webview
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs
References
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java9-installer
if you want to set Oracle Java 9 as default
sudo apt-get install oracle-java9-set-default
If you don’t want to make Oracle Java 9 default
sudo apt-get install --no-install-recommends oracle-java9-installer
References
http://www.webupd8.org/2015/02/install-oracle-java-9-in-ubuntu-linux.html
AndroidManifest.xml
<!-- Permissions the Application Requires --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!--<uses-permission android:name="android.permission.READ_PHONE_STATE" />--> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.INTERNET" />
And register our MQTT Android Service in our app before the closing tag by adding this line:
<service android:name="org.eclipse.paho.android.service.MqttService" />
Java
public class MqttManager { MqttAndroidClient mqtt=null; public void publishTest() throws MqttException { try { String clientId= MqttClient.generateClientId(); mqtt=new MqttAndroidClient(CachePupli.context,"tcp://192.168.1.2:1883",clientId); MqttConnectOptions connectOptions=new MqttConnectOptions(); connectOptions.setAutomaticReconnect(true); connectOptions.setCleanSession(true); IMqttToken token= mqtt.connect(connectOptions); token.setActionCallback(onConnect); } catch (Exception ex) { ex.printStackTrace(); } } private IMqttActionListener onConnect=new IMqttActionListener() { @Override public void onSuccess(IMqttToken asyncActionToken) { MqttMessage message=new MqttMessage("Hello World".getBytes()); try { mqtt.publish("test",message); } catch (MqttException e) { e.printStackTrace(); } } @Override public void onFailure(IMqttToken asyncActionToken, Throwable exception) { } }; }
References
https://www.eclipse.org/paho/clients/android/
https://wildanmsyah.wordpress.com/2017/05/11/mqtt-android-client-tutorial/
for example change GOPATH for current CMD session with set and use setx to set permanently
set GOPATH=C:\Projects\mediasync\go
References
https://superuser.com/questions/79612/setting-and-getting-windows-environment-variables-from-the-command-prompt
https://ss64.com/nt/set.html
https://ss64.com/nt/setx.html
Create GOPATH folder
Create a folder in your project directory.This folder is going to be your GOPATH folder.
I creeated a folder named go for my specific GOPATH inside my project.
cd go mkdir src
Create project folder
cd src mkdir msync # project folder
Setup Jetbrains Gogland IDE
set the IDE to use your specific GOPATH not the global GOPATH
go get
every time you want to get an external package open a terminal ( I have tested in Linux) :
GOPATH=~/git/mediasync/go/
go env # for checking env
go get github.com/eclipse/paho.mqtt.golang
References
https://www.jetbrains.com/help/go/getting-started-with-gogland.html
https://stackoverflow.com/questions/37163048/how-to-install-github-repository-in-a-specific-gopath
f, err := os.OpenFile("testlogfile", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666) if err != nil { t.Fatalf("error opening file: %v", err) } defer f.Close() log.SetOutput(f) log.Println("This is a test log entry")
References
https://stackoverflow.com/questions/19965795/go-golang-write-log-to-file