If you do not already have Android Debug Bridge (ADB) installed, you can get the platform tools at android.com. How to check if you already have ADB?

adb --version

Next you will need to enable developer options and test the connectivity.

adb devices

Sample code below is a very simple web server written in Kotlin. A [Start] button to start listening, a [Stop] button to stop listening and text view to display WiFi address.

Remember to add these 2 permissions else the app will crash upon start.

Constructing JSON by concatenating string is not the best way as it will probably lead to bugs in your application. The easiest way to do it in CSharp(C#) is to use the library by Newtonsoft.

static void Main(string[] args)
var n = new Name();
n.FirstName = "William";
n.MiddleName = "Henry";
n.LastName = "Gates";
var c = new Contact();
c.Name = n;
c.PhoneNumber = "+1 425-882-8080";
private class Name {
public string FirstName;
public string MiddleName;
public string LastName;
private class Contact {
public Name Name;
public string PhoneNumber;

The code…

It is very easy to install the APK decompiler in Mac. Just type the following command.

brew install apktool
apktool installation using Homebrew

The “brew” command is Homebrew and it doesn’t come with Mac by default. You will have to install it by copy pasting the command from their official site.

Once done, you can decompile an APK with the following command

apktool d filename.apk

If you do not have the APK file and need to extract from your phone, you can read the how to extract APK article. Once decompiled, you can search keyword within the folder with grep.

grep -rnw 'path' -e…

Been googling several sites on how to navigate/traverse between fragments in Android. It is not easy because it is mostly in Java and they are so old and deprecated. Finally after piecing together the information from several sites, I managed to get it working.

I better document it down for my own use in future. Don’t want to go through the tiring process of googling again.

At MainActivity.kt , add the function “replaceFragment”.

fun AppCompatActivity.replaceFragment(fragment:Fragment){
val fragmentManager = supportFragmentManager
val transaction = fragmentManager.beginTransaction()

Kevin FOO

A software engineer, a rock climbing, diving & inline skating enthusiast, a husband, a father.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store