cleant server 7
Assalam’alaikum warohmatulahi wabarokatu..
Baiklah pada blog kali ini saya akan menjelaskan apikasi client server android, database,dan mysql..
package com.example.aplikasi_android;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Pelanggan extends Activity {
 EditText Email,password;
 TextView status;
 Button login,daftar;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_pelanggan);
   Email=(EditText) findViewById(R.id.txtusername);
         password=(EditText) findViewById(R.id.txtpassword);
         status=(TextView) findViewById (R.id.txtstatus);
         login=(Button) findViewById (R.id.btnlogin);
         daftar=(Button) findViewById (R.id.btndaftar);
         login.setOnClickListener(new View.OnClickListener() {
          @Override
             public void onClick(View v) {
                // TODO Auto-generated method stub
                ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
                postParameters.add(new BasicNameValuePair("username", Email.getText().toString()));
                postParameters.add(new BasicNameValuePair("password", password.getText().toString()));
    /*            String valid = "1";*/      
                String response = null;
                try {
                   response = CustomHttpClient.executeHttpPost("http://10.0.2.2/kk/config/koneksi.php", postParameters);
                   String res = response.toString();
                   res = res.trim();
                   res = res.replaceAll("\\s+","");
                   status.setText(res);
                   if (res.equals("1")) 
                   {
                    status.setText("Correct Username or Password");
                    berhasil(v); 
                   }
                   else { 
                     status.setText("Sorry!! Wrong Username or Password Entered");
                        }
                }
                catch (Exception e) {
                   status.setText(e.toString());
                }
             }
             });
      // penutup buka dari public void onCreate
     }   
     public void daftar (View theButton)
     {
      Intent d = new Intent (this,Daftar_pel.class);
      startActivity(d);
     }
 // apabila user berhasil login.
     public void berhasil (View theButton)
     {
      Intent s = new Intent (this,Satu_kost .class);
      startActivity(s);
     }
 }
 
 
Komentar
Posting Komentar