package xyz.fitraditya.androidmqtt;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

@@ -98,242 +98,2991 @@
 oid.
-os.Bundle;%0A%0Apublic class MainActivity extends AppCompatActivity %7B%0A%0A    @Override%0A    protected void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A        setContentView(R.layout.activity_main);%0A    %7D
+content.Context;%0Aimport android.content.Intent;%0Aimport android.content.SharedPreferences;%0Aimport android.os.Bundle;%0Aimport android.view.View;%0Aimport android.widget.Button;%0Aimport android.widget.EditText;%0Aimport android.widget.Toast;%0A%0Apublic class MainActivity extends AppCompatActivity %7B%0A%0A    private static String PREFS     = %22mqtt-prefs%22;%0A    private static String HOSTNAME  = %22-Hostname%22;%0A    private static String PORT      = %22-Port%22;%0A    private static String USERNAME  = %22-Username%22;%0A    private static String PASSWORD  = %22-Password%22;%0A    private static String TOPIC     = %22-Topic%22;%0A%0A    @Override%0A    protected void onCreate(Bundle savedInstanceState) %7B%0A        final SharedPreferences sharedPref = this.getSharedPreferences(PREFS, Context.MODE_PRIVATE);%0A%0A        super.onCreate(savedInstanceState);%0A        setContentView(R.layout.activity_main);%0A%0A        String sHostname, sTopic, sUsername, sPassword, sPort;%0A        final EditText vHostname, vTopic, vUsername, vPassword, vPort;%0A%0A        vHostname%09= (EditText) findViewById(R.id.mHost);%0A        vPort%09%09= (EditText) findViewById(R.id.mPort);%0A        vUsername%09= (EditText) findViewById(R.id.mUsername);%0A        vPassword%09= (EditText) findViewById(R.id.mPassword);%0A        vTopic%09%09= (EditText) findViewById(R.id.mTopic);%0A%0A        sHostname%09= sharedPref.getString(HOSTNAME, %22%22);%0A        sTopic%09%09= sharedPref.getString(TOPIC,%22%22);%0A        sUsername%09= sharedPref.getString(USERNAME, %22%22);%0A        sPassword%09= sharedPref.getString(PASSWORD, %22%22);%0A        sPort%09%09= sharedPref.getString(PORT, %22%22);%0A%0A        vHostname.setText(sHostname);%0A        vPort.setText(String.valueOf(sPort));%0A        vUsername.setText(sUsername);%0A        vPassword.setText(sPassword);%0A        vTopic.setText(sTopic);%0A%0A        final Button button = (Button) findViewById(R.id.mSave);%0A        button.setOnClickListener(new View.OnClickListener() %7B%0A            public void onClick(View v) %7B%0A                if (vHostname.getText().toString().length() %3E 0 &&%0A                        vTopic.getText().toString().length() %3E 0 &&%0A                        vPort.getText().toString().length() %3E 0) %7B%0A                    SharedPreferences.Editor editor = sharedPref.edit();%0A                    editor.putString(HOSTNAME, vHostname.getText().toString());%0A                    editor.putString(TOPIC, vTopic.getText().toString());%0A                    editor.putString(USERNAME, vUsername.getText().toString());%0A                    editor.putString(PASSWORD, vPassword.getText().toString());%0A                    editor.putString(PORT, vPort.getText().toString());%0A                    editor.commit();%0A%0A                    final Intent intent = new Intent(getApplicationContext(), MQTTService.class);%0A                    startService(intent);%0A                    finish();%0A                %7D else %7B%0A                    Toast.makeText(getApplicationContext(), %22Please Fill Hostname, Port, and Topic%22, Toast.LENGTH_LONG).show();%0A                %7D%0A            %7D%0A        %7D);%0A    %7D%0A
 %0A%7D%0A

Create MainActivity, add edit text for MQTT configuration