pemrograman mobile android # 9dinus.ac.id/repository/docs/ajar/pemromobile_9.pdf · ajib susanto...
TRANSCRIPT
![Page 1: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/1.jpg)
ajib susanto fik Udinus 1
Pemrograman Mobile
Android # 9
Android, PHP, MySQL
![Page 2: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/2.jpg)
ajib susanto fik Udinus 2
TIK
Mahasiswa dapat memahami cara kerja Android
dengan PHP dan MySQL
Mahasiswa mampu menampilkan hasil query ke
dalam tampilan yg berbeda
![Page 3: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/3.jpg)
ajib susanto fik Udinus 3
Konsep Dasar
![Page 4: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/4.jpg)
ajib susanto fik Udinus 4
Tabel Kota
![Page 5: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/5.jpg)
ajib susanto fik Udinus 5
Tampil PHP
<?php
mysql_connect("localhost","root","");
mysql_select_db(“penjualan”);
$q = mysql_query("SELECT * FROM kota");
while($r = mysql_fetch_assoc($q))
$output[] = $r;
print(json_encode($output));
mysql_close();
?>
![Page 6: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/6.jpg)
ajib susanto fik Udinus 6
Hasil
![Page 7: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/7.jpg)
ajib susanto fik Udinus 7
APP MySQL Activitypublic class APP_MYSQLActivity extends ListActivity {
int idkota;
String[] kota= null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String hasil = null;
InputStream is = null;
StringBuilder sb = null;
// httppost
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://10.0.2.2/android/tampil.php");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch(Exception e) {
Log.e("log_tag", "Error in http connection"+
e.toString());
}
![Page 8: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/8.jpg)
ajib susanto fik Udinus 8
APP MySQL Activity#2// convert response to string
try{
BufferedReader reader = new BufferedReader(new
InputStreamReader(is, "iso-8859-1"), 8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line = "0";
while((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
hasil = sb.toString();
} catch(Exception e) {
Log.e("log_tag", "Error converting result "+e.toString());
}
![Page 9: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/9.jpg)
APP MySQL Activity#3
ajib susanto fik Udinus 9
// parsing data
JSONArray jArray;
try{
jArray = new JSONArray(hasil);
JSONObject json_data = null;
kota= new String[jArray.length()];
for(int i = 0; i < jArray.length(); i++) {
json_data = jArray.getJSONObject(i);
idkota= json_data.getInt("id");
kota[i] = json_data.getString("kota");
}
} catch(JSONException e1) {
Toast.makeText(getBaseContext(), "No Id
Found", Toast.LENGTH_LONG).show();
} catch(ParseException e1) {
e1.printStackTrace();
}
![Page 10: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/10.jpg)
ajib susanto fik Udinus 10
APP MySQL Activity#4//tampilkan
setListAdapter(new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_
1, kota));
ListView lv;
lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new
OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0,
View arg1, int arg2,long arg3) {
// TODOAuto-generated method stub
Toast.makeText(getApplicationContext(),
kota[arg2] + " wasClicked",
Toast.LENGTH_SHORT).show();
}
});
}
}
![Page 11: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/11.jpg)
ajib susanto fik Udinus 11
Hasil
![Page 12: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/12.jpg)
ajib susanto fik Udinus 12
Referensi FelkerD.; Dobbs J, 2011, Android Application Development For
Dummies, Wiley Publishing Inc., USA
Official Android Developer Documentation
http://developer.android.com/.
Esposito, Dino, Architecting Mobile Solutions for the Enterprise,
2012, O’Reilly Media.
Iversen, Jakob & Eierman, Michael, Learning Mobile App
Development A Hands-on Guide to Building Apps with iOS and
Android , 2014, Pearson Education.
Meier, Reto, Professional Android 4 Application Development,
2012, John Wiley and Sons.
McWherter, Jeff & Gowell, Scott, Professional Mobile Application
Development, 2012, John Wiley & Sons
![Page 13: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/13.jpg)
ajib susanto fik Udinus 13
Ada Pertanyaan
![Page 14: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/14.jpg)
ajib susanto fik Udinus 14
Tugas 9 Buat program dari tabel barang
Menu
Tambah Data
Edit Data
Hapus Data
Tampil Data
KdBrg NmBrg HrgBeli HrgJual Stok
B0001 Buku 5000 6000 100
B0002 Spidol 3500 4000 50
![Page 15: Pemrograman Mobile Android # 9dinus.ac.id/repository/docs/ajar/PemroMobile_9.pdf · ajib susanto fik Udinus 1 Pemrograman Mobile Android # 9 Android, PHP, MySQL](https://reader034.vdokumen.com/reader034/viewer/2022052215/5ccd6d8788c9932b558daea6/html5/thumbnails/15.jpg)
Rehat Sejenak
WOW
ajib susanto fik Udinus 15