KURIR Aplikasi Tracking Pengiriman Paket Berbasis Android.

B-24 Universitas Kristen Maranatha { ArrayList Object output = new ArrayList Object ; int pointer = 0; String data = ; while pointer = input.length-1 { if input.charAtpointer == { output.adddata; data = ; pointer++; } if pointer input.length { data+ = input.charAtpointer; } pointer++; } return output; } }

2. KURIR

Layout Kurir B-25 Universitas Kristen Maranatha Main.xml B-26 Universitas Kristen Maranatha Kurir.xml B-27 Universitas Kristen Maranatha Updatepengiriman.xml ? xml version= 1.0 encoding= utf-8 ? LinearLayout xmlns:android = http:schemas.android.comapkresandroid android:orientation = vertical android:layout_width = fill_parent android:layout_height = fill_parent android:background = drawablelayout LinearLayout android:id = +idLinearLayout01 android:layout_marginTop = 60dip android:layout_gravity = center_horizontal android:layout_width = wrap_content android:layout_height = wrap_content ImageView android:id = +idImageView01 android:layout_width = 100dip android:layout_gravity = center_horizontal android:layout_height = 80dip android:background = drawablelogo2 ImageView LinearLayout LinearLayout android:id = +idLinearLayout05 android:layout_marginTop = 15dip android:layout_gravity = left android:layout_width = fill_parent android:layout_height = wrap_content TextView android:layout_marginTop = 5dip android:id = +idlongi android:gravity = left android:textSize = 12dip android:layout_width = wrap_content android:layout_height = wrap_content android:text = NO POD : android:textColor = 000000 B-28 Universitas Kristen Maranatha android:textStyle = bold EditText android:gravity = left android:id = +idkode android:layout_width = fill_parent android:layout_height = wrap_content android:numeric = integer LinearLayout LinearLayout android:id = +idLinearLayout05 android:layout_marginTop = 15dip android:layout_gravity = left android:layout_width = fill_parent android:layout_height = wrap_content TextView android:layout_marginTop = 1dip android:textColor = 000000 android:textStyle = bold android:textSize = 12dip android:id = +idlat android:gravity = left android:layout_width = wrap_content android:layout_height = wrap_content android:text = PENERIMA : EditText android:id = +idpenerima android:layout_width = fill_parent android:layout_height = wrap_content LinearLayout LinearLayout android:id = +idLinearLayout06 android:layout_marginTop = 15dip android:layout_gravity = center_horizontal android:layout_width = wrap_content android:layout_height = wrap_content Button android:text = UPDATE PENGIRIMAN android:id = +idupdatepengiriman android:layout_gravity = center_horizontal android:layout_width = 200dip android:layout_height = wrap_content Button Button android:text = KEMBALI android:id = +idkembali android:layout_gravity = center_horizontal android:layout_width = wrap_content android:layout_height = wrap_content Button LinearLayout LinearLayout B-29 Universitas Kristen Maranatha Updateposisi.xml ? xml version= 1.0 encoding= utf-8 ? LinearLayout xmlns:android = http:schemas.android.comapkresandroid android:orientation = vertical android:layout_width = fill_parent android:layout_height = fill_parent android:background = drawablelayout LinearLayout android:id = +idLinearLayout01 android:layout_marginTop = 60dip android:layout_gravity = center_horizontal android:layout_width = wrap_content android:layout_height = wrap_content ImageView android:id = +idImageView01 android:layout_width = 100dip android:layout_gravity = center_horizontal android:layout_height = 80dip android:background = drawablelogo2 ImageView LinearLayout TextView android:textColor = 000000 android:textStyle = bold android:layout_marginTop = 15dip android:id = +idsekarang android:gravity = center_horizontal android:layout_gravity = center_horizontal android:layout_width = fill_parent android:layout_height = wrap_content android:text = POSISI SEKARANG LinearLayout android:id = +idLinearLayout09 android:layout_marginTop = 15dip android:layout_gravity = left android:layout_width = wrap_content android:layout_height = wrap_content TextView android:textColor = 000000 B-30 Universitas Kristen Maranatha android:textStyle = bold android:id = +idzzzzz android:gravity = left android:layout_gravity = left android:layout_width = fill_parent android:layout_height = wrap_content android:text = LONGITUDE : TextView android:textColor = 000000 android:textStyle = bold android:id = +idlongitude android:gravity = left android:layout_width = fill_parent android:layout_height = wrap_content android:text = LinearLayout LinearLayout android:id = +idLinearLayout05 android:layout_marginTop = 15dip android:layout_gravity = left android:layout_width = wrap_content android:layout_height = wrap_content TextView android:textColor = 000000 android:textStyle = bold android:layout_gravity = left android:id = +idggg android:gravity = left android:layout_width = fill_parent android:layout_height = wrap_content android:text = LATITUDE : TextView android:textColor = 000000 android:textStyle = bold android:id = +idlatitude android:gravity = left android:layout_width = fill_parent android:layout_height = wrap_content android:text = LinearLayout LinearLayout android:id = +idLinearLayout06 android:layout_marginTop = 15dip android:layout_gravity = center_horizontal android:layout_width = wrap_content android:layout_height = wrap_content Button android:text = UPDATEPOSISI android:id = +idupdateposisi android:layout_gravity = center_horizontal android:layout_width = 150dip android:layout_height = wrap_content Button Button android:text = KEMBALI android:id = +idkembali android:layout_gravity = center_horizontal android:layout_width = wrap_content android:layout_height = wrap_content Button LinearLayout LinearLayout B-31 Universitas Kristen Maranatha Src FormKurir.java package com.rika.kurir; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class FormKurir extends Activity{ Override protected void onCreateBundle savedInstanceState { TODO Auto-generated method stub super.onCreatesavedInstanceState; setContentViewR.layout.main; Button updateposisi =ButtonfindViewByIdR.id.updateposisi; updateposisi.setOnClickListenernew OnClickListener { public void onClickView v { TODO Auto-generated method stub tampilUpdatePosisi; } }; Button updatepengiriman =ButtonfindViewByIdR.id.updatepengiriman; updatepengiriman.setOnClickListenernew OnClickListener { public void onClickView v { TODO Auto-generated method stub tampilUpdatePengirimani; } }; Button logout =ButtonfindViewByIdR.id.logout; logout.setOnClickListenernew OnClickListener { public void onClickView v { TODO Auto-generated method stub finish; } }; } B-32 Universitas Kristen Maranatha public void tampilUpdatePosisi{ Intent i = new IntentgetBaseContext, FormUpdatePosisi.class; startActivityi; } public void tampilUpdatePengirimani{ Intent i = new IntentgetBaseContext, FormUpdatePengiriman.class; startActivityi; } } FormUpdatePengiriman.java package com.rika.kurir; import android.app.Activity; import android.app.ProgressDialog; import android.os.AsyncTask; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class FormUpdatePengiriman extends Activity { String kode,penerima,pen,response; String[][] Data; ProgressDialog a; Override protected void onCreateBundle savedInstanceState { TODO Auto-generated method stub super.onCreatesavedInstanceState; setContentViewR.layout.updatepengiriman; Button update = ButtonfindViewByIdR.id.updatepengiriman; update.setOnClickListenernew OnClickListener { public void onClickView v { TODO Auto-generated method stub EditText Kode = EditTextfindViewByIdR.id.kode; kode=Kode.getText.toString; EditText Penerima = EditTextfindViewByIdR.id.penerima; pen= Penerima.getText.toString; penerima = pen.replace ,; if kode.length==0||penerima.length==0{ Toast.makeTextgetBaseContext, Maaf data pengiriman belum lengkap, 10000.show; } B-33 Universitas Kristen Maranatha else { a=ProgressDialog.showFormUpdatePengiriman.this,, Tunggu....................; a.show; new ProsesUpdate.execute; } } }; Button kembali = ButtonfindViewByIdR.id.kembali; kembali.setOnClickListenernew OnClickListener { public void onClickView v { TODO Auto-generated method stub finish; } }; } class ProsesUpdate extends AsyncTask Void, Void, Void { Override protected Void doInBackgroundVoid... arg0 { TODO Auto-generated method stub try { Sinkronize s = new Sinkronize; EditText kode = EditTextfindViewByIdR.id.kode; String url =http:galluetz.comParserUpdate.php?cat=updatepengirimankode=+s.ge tUsername+pod=+kode+status=diterima+penerima=+penerima; response =s.callurl; } catch Exception e { TODO Auto-generated catch block e.printStackTrace; } return null; } Override protected void onPostExecuteVoid result { TODO Auto-generated method stub super.onPostExecuteresult; int hasil = Integer.valueOfresponse; a.dismiss; if hasil==1 { Toast.makeTextgetBaseContext,Pengiriman berhasil diupdate, 10000.show; } else { Toast.makeTextgetBaseContext,Maaf No POD tidak terdaftar, 10000.show; } } B-34 Universitas Kristen Maranatha } } FormUpdatePosisi.java package com.rika.kurir; import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.AsyncTask; import android.os.Bundle; import android.provider.Settings; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class FormUpdatePosisi extends Activity { Called when the activity is first created. ProgressDialog a; LocationManager lm; TextView Longitude,s; TextView Latitude; String response; Override public void onCreateBundle savedInstanceState { super.onCreatesavedInstanceState; setContentViewR.layout.updateposisi; Longitude = TextViewfindViewByIdR.id.longitude; Latitude = TextViewfindViewByIdR.id.latitude; lm = LocationManager getSystemServiceContext.LOCATION_SERVICE; lm.requestLocationUpdatesLocationManager.GPS_PROVIDER,7200,0, lokasi; if lm.isProviderEnabled LocationManager.GPS_PROVIDER { PeringatanGPS; } Button updateposisi =ButtonfindViewByIdR.id.updateposisi; updateposisi.setOnClickListenernew OnClickListener { public void onClickView v { TODO Auto-generated method stub if Longitude.getText.toString.length==1{ Toast.makeTextgetBaseContext,Maaf Lokasi Anda tidak mendapat sinyal dari satelite,10000.show; B-35 Universitas Kristen Maranatha } else { a=ProgressDialog.showFormUpdatePosisi.this,, Tunggu....................; a.show; new ProsesUpdate.execute; } } }; Button kembali = ButtonfindViewByIdR.id.kembali; kembali.setOnClickListenernew OnClickListener { public void onClickView v { TODO Auto-generated method stub finish; } }; } private void PeringatanGPS { final AlertDialog.Builder builder = new AlertDialog.Builderthis; builder.setMessageGPS Anda sedang tidak aktif +\n + Apakah And akan mengaktifkannya? .setCancelablefalse .setPositiveButtonYa, new DialogInterface.OnClickListener { public void onClickDialogInterface dialog,int id { Intent myIntent = new Intent Settings.ACTION_SECURITY_SETTINGS ; startActivitymyIntent; } } .setNegativeButtonTidak, new DialogInterface.OnClickListener { public void onClickDialogInterface dialog,int id { Toast.makeTextgetBaseContext,Untuk mengakses falitas ini anda harus menyalakan GPS terlebih dahulu ,10000.show; dialog.cancel; finish; } }; final AlertDialog alert = builder.create; alert.show; } LocationListener lokasi= new LocationListener { Override public void onStatusChangedString provider, int status, Bundle extras { TODO Auto-generated method stub Toast.makeTextgetBaseContext, Maaf LOkasi Anda B-36 Universitas Kristen Maranatha Tidak mendapat sinyal lokasi,3600.show; } Override public void onProviderEnabledString provider { TODO Auto-generated method stub } Override public void onProviderDisabledString provider { TODO Auto-generated method stub } Override public void onLocationChangedLocation location { TODO Auto-generated method stub if lm=null{ String longitude = String.valueOflocation.getLongitude; String latitude = String.valueOflocation.getLatitude; Longitude.setTextlongitude; Latitude.setTextlatitude; Toast.makeTextgetBaseContext,aa, 10000.show; } } }; class ProsesUpdate extends AsyncTask Void, Void, Void { Override protected Void doInBackgroundVoid... arg0 { TODO Auto-generated method stub try { Sinkronize s = new Sinkronize; EditText kode = EditTextfindViewByIdR.id.kode; String url =http:galluetz.comParserUpdate.php?cat=updateposisikode=+s.getUse rname+longitude=+Longitude.getText.toString+latitude=+Latitu de.getText.toString; s.callurl; } catch Exception e { TODO Auto-generated catch block e.printStackTrace; } return null; } Override protected void onPostExecuteVoid result { TODO Auto-generated method stub super.onPostExecuteresult; a.dismiss; B-37 Universitas Kristen Maranatha Toast.makeTextgetBaseContext,Posisi sudah terupdate, 10000.show; } } } Login.java package com.rika.kurir; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class Login extends Activity { Called when the activity is first created. ProgressDialog a; String[][] Data; String response; Override public void onCreateBundle savedInstanceState { super.onCreatesavedInstanceState; setContentViewR.layout.kurir; Button login = ButtonfindViewByIdR.id.login; login.setOnClickListenernew OnClickListener { public void onClickView v { TODO Auto-generated method stub a=ProgressDialog.showLogin.this,, Tunggu....................; a.show; new ProsesLogin.execute; } }; Button logout =ButtonfindViewByIdR.id.logout; logout.setOnClickListenernew OnClickListener { public void onClickView v { TODO Auto-generated method stub finish; } }; } class ProsesLogin extends AsyncTask Void, Void, Void { Override protected Void doInBackgroundVoid... arg0 { B-38 Universitas Kristen Maranatha TODO Auto-generated method stub try { Sinkronize s = new Sinkronize; EditText kode = EditTextfindViewByIdR.id.kode; String url =http:galluetz.comParserLogin.php?username=+kode.getText.toStrin g; response = s.callurl; Parser p = new Parser; p.parseresponse; Data = p.getData; s.setUsernameData[0][1]; } catch Exception e { TODO Auto-generated catch block e.printStackTrace; } return null; } Override protected void onPostExecuteVoid result { TODO Auto-generated method stub super.onPostExecuteresult; int has = Integer.valueOfData[0][0]; a.dismiss; if has==1{ Intent i = new IntentgetBaseContext, FormKurir.class; startActivityi; finish; } else { Toast.makeTextgetBaseContext,Maaf Kode Kurir Salah, 10000.show; } } } } Parser.java package com.rika.kurir; To change this template, choose Tools | Templates and open the template in the editor. import java.io.IOException; import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; B-39 Universitas Kristen Maranatha import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class Parser{ Document dom; String[] kolom; String[] kolomG; String[][] data; String[][] gambar; public Parser { kolom = new String[]{}; kolomG = new String[]{}; data = new String[][]{{}}; gambar = new String[][]{{}}; } public void parseString XML { parseXmlFileXML; parseKolom; parseKolomG; parseData; parseGambar; } public String[] getKolom { return this.kolom; } public String[][] getData { return this.data; } public String[] getKolomG { return this.kolomG; } public String[][] getGambar { return this.gambar; } private void parseXmlFileString XML{ get the factory DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance; try { Using factory get an instance of document builder DocumentBuilder db = dbf.newDocumentBuilder; B-40 Universitas Kristen Maranatha parse using builder to get DOM representation of the XML file InputSource is = new InputSource; is.setCharacterStreamnew StringReaderXML; dom = db.parseis; }catchParserConfigurationException pce { System.out.printlnsatu; pce.printStackTrace; }catchSAXException se { System.out.printlndua; se.printStackTrace; }catchIOException ioe { System.out.printlntiga; ioe.printStackTrace; } } private void parseKolom { Element docEle = dom.getDocumentElement; get a nodelist of employee elements NodeList nl = docEle.getElementsByTagNameisi; ifnl = null nl.getLength 0 { Element el = Elementnl.item0; NodeList nl2 = el.getChildNodes; ifnl2 = null nl2.getLength 0 { kolom = new String[nl2.getLength]; forint i = 0 ; i nl2.getLength;i++ { Element el2 = Elementnl2.itemi; kolom[i] = el2.getTagName; } } } } private void parseData { get the root elememt Element docEle = dom.getDocumentElement; try { get a nodelist of employee elements NodeList nl = docEle.getElementsByTagNameisi; data = new String[nl.getLength][kolom.length]; ifnl = null nl.getLength 0 { forint i = 0 ; i nl.getLength;i++ { get the employee element Element el = Elementnl.itemi; get the Employee object Employee e = getEmployeeel; for int j =0 ;jkolom.length;j++{ data[i][j] = getTextValueel,kolom[j]; B-41 Universitas Kristen Maranatha } } } } catchException e { System.out.printlne; } } private String getTextValueElement ele, String tagName { String textVal = null; NodeList nl = ele.getElementsByTagNametagName; ifnl = null nl.getLength { Element el = Elementnl.item0; try { textVal = el.getFirstChild.getNodeValue; } catchException e { System.out.printlne; } } return textVal; } } Sinkronize.java package com.rika.kurir; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; public class Sinkronize { String str; static String[][] data,dataall; static String username,nama,email,telepon,institusi; static double longi,lati; public Sinkronize{ } public void setDataString[][] Username{ data = Username; } public String[][] getData{ return data; B-42 Universitas Kristen Maranatha } public void setDataAllString[][] Username{ dataall = Username; } public String[][] getDataAll{ return dataall; } public void setUsernameString Username{ username = Username; } public String getUsername{ return username; } public void setNamaString Nama{ nama = Nama; } public String getNama{ return nama; } public void setEmailString Email{ email = Email; } public String getEmail{ return email; } public void setTeleponString Telepon{ telepon = Telepon; } public String getTelepon{ return telepon; } public void setInstitusiString Institusi{ institusi = Institusi; } public String getInstitusi{ return institusi; } B-43 Universitas Kristen Maranatha public void setLOngdouble x{ longi= x; } public double getLong{ return longi; } public void setLatdouble y{ lati= y; } public double getLat{ return lati; } public String callString url { TODO Auto-generated method stub int BUFFER_SIZE = 2000; InputStream in = null; try { in = OpenHttpConnectionurl; } catch IOException e { TODO: handle exception e.printStackTrace; return ; } InputStreamReader isr = new InputStreamReaderin; int charRead; String str=; char[] inputBuffer = new char[BUFFER_SIZE]; try { whilecharRead = isr.readinputBuffer0{ String readString = String.copyValueOfinputBuffer,0,charRead; str += readString; inputBuffer = new char[BUFFER_SIZE]; } in.close; } catch IOException e { TODO: handle exception e.printStackTrace; return ; } return str; } public InputStream OpenHttpConnectionString urlString throws IOException { TODO Auto-generated method stub InputStream in =null; int response = -1; URL url = new URLurlString; URLConnection conn = url.openConnection; if conn instanceof HttpURLConnection throw new IOExceptionNot An HTTP connection; try { HttpURLConnection httpconn = HttpURLConnection conn; httpconn.setAllowUserInteractionfalse; httpconn.setInstanceFollowRedirectstrue; B-44 Universitas Kristen Maranatha httpconn.setRequestMethodGET; httpconn.connect; response = httpconn.getResponseCode; if response == HttpURLConnection.HTTP_OK{ in = httpconn.getInputStream; } } catch Exception e { TODO: handle exception throw new IOExceptionError connecting; } return in; } } C-0 Universitas Kristen Maranatha LAMPIRAN C DATABASE C-1 Universitas Kristen Maranatha LAMPIRAN C DATABASE

1. phpMyAdmin