package com.example.apps;
import android.util.Log;
public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
public JSONParser() {}
String getIP() {
return "http://192.168.1.12/Master/masterPenjualan/";
}
public JSONObject makeHttpRequest(String url, String method,List<NameValuePair> params) {
try {
if(method == "POST"){
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
else if(method == "GET"){
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jObj;
}
}
Wednesday, April 24, 2019
Script Menu Utama Android
package com.example.apps;
import java.util.ArrayList;
public class menuutama extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menuutama);
//
ImageView btnbarang= (ImageView) findViewById(R.id.btnbarang);
btnbarang.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_barang.class);
startActivityForResult(i, 100);
}});
ImageView btncustomer= (ImageView) findViewById(R.id.btncustomer);
btncustomer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_customer.class);
startActivityForResult(i, 100);
}});
ImageView btnsupplier= (ImageView) findViewById(R.id.btnsupplier);
btnsupplier.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_supplier.class);
startActivityForResult(i, 100);
}});
ImageView btnorder= (ImageView) findViewById(R.id.btnorder);
btnorder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_order.class);
startActivityForResult(i, 100);
}});
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
import java.util.ArrayList;
public class menuutama extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menuutama);
//
ImageView btnbarang= (ImageView) findViewById(R.id.btnbarang);
btnbarang.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_barang.class);
startActivityForResult(i, 100);
}});
ImageView btncustomer= (ImageView) findViewById(R.id.btncustomer);
btncustomer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_customer.class);
startActivityForResult(i, 100);
}});
ImageView btnsupplier= (ImageView) findViewById(R.id.btnsupplier);
btnsupplier.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_supplier.class);
startActivityForResult(i, 100);
}});
ImageView btnorder= (ImageView) findViewById(R.id.btnorder);
btnorder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_order.class);
startActivityForResult(i, 100);
}});
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
Script Link ImageView Android
Script Link ImageView Android
ImageView btnbarang= (ImageView) findViewById(R.id.btnbarang);
btnbarang.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_barang.class);
startActivityForResult(i, 100);
}
});
ImageView btnbarang= (ImageView) findViewById(R.id.btnbarang);
btnbarang.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), List_barang.class);
startActivityForResult(i, 100);
}
});
Script Loading Android
Script Loading 1
public void setSplash(){
final ProgressDialog myProgressDialog = ProgressDialog.show(Loading1.this, "Loading", "Mohon Tunggu...", true);
new Thread() {
public void run() {
try{Thread.sleep(10000);}
catch (Exception e) {}
Intent i = new Intent(Loading1.this, menuutama.class);
myProgressDialog.dismiss();
finish();
startActivity(i);
} }.start();
}
Skript Loading 2
ProgressDialog progressBar;
private int progressBarStatus = 0;
private Handler progressBarHandler = new Handler();
int fileSize=0;
public void setSplash() {
progressBar = new ProgressDialog(this);
progressBar.setCancelable(true);
progressBar.setMessage("Progress ...");// STYLE_SPINNER
progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressBar.setProgress(0);
progressBar.setMax(100);
progressBar.show();
progressBarStatus = 0;
fileSize = 0;
new Thread(new Runnable() {
public void run() {
while (progressBarStatus < 100) {
// process some tasks
progressBarStatus = doSomeTasks();
// your computer is too fast, sleep 1 second
try {Thread.sleep(1000);}
catch (InterruptedException e) {e.printStackTrace();}
// Update the progress bar
progressBarHandler.post(new Runnable() {
public void run() {progressBar.setProgress(progressBarStatus);}});}
// ok, file is downloaded,
if (progressBarStatus >= 100) {
// sleep 2 seconds, so that you can see the 100%
try {Thread.sleep(2000);}
catch (InterruptedException e) {e.printStackTrace();}
progressBar.dismiss();
Intent i = new Intent(Loading2.this, menuutama.class);
finish();
startActivity(i);
}}}).start();
}
// file download simulator... a really simple
public int doSomeTasks() {
while (fileSize <= 1000000) {
fileSize++;
if (fileSize == 100000) {return 10;}
else if (fileSize == 200000) {return 20;}
else if (fileSize == 300000) {return 30;}
// ...add your own
}
return 100;
}
public void setSplash(){
final ProgressDialog myProgressDialog = ProgressDialog.show(Loading1.this, "Loading", "Mohon Tunggu...", true);
new Thread() {
public void run() {
try{Thread.sleep(10000);}
catch (Exception e) {}
Intent i = new Intent(Loading1.this, menuutama.class);
myProgressDialog.dismiss();
finish();
startActivity(i);
} }.start();
}
Skript Loading 2
ProgressDialog progressBar;
private int progressBarStatus = 0;
private Handler progressBarHandler = new Handler();
int fileSize=0;
public void setSplash() {
progressBar = new ProgressDialog(this);
progressBar.setCancelable(true);
progressBar.setMessage("Progress ...");// STYLE_SPINNER
progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressBar.setProgress(0);
progressBar.setMax(100);
progressBar.show();
progressBarStatus = 0;
fileSize = 0;
new Thread(new Runnable() {
public void run() {
while (progressBarStatus < 100) {
// process some tasks
progressBarStatus = doSomeTasks();
// your computer is too fast, sleep 1 second
try {Thread.sleep(1000);}
catch (InterruptedException e) {e.printStackTrace();}
// Update the progress bar
progressBarHandler.post(new Runnable() {
public void run() {progressBar.setProgress(progressBarStatus);}});}
// ok, file is downloaded,
if (progressBarStatus >= 100) {
// sleep 2 seconds, so that you can see the 100%
try {Thread.sleep(2000);}
catch (InterruptedException e) {e.printStackTrace();}
progressBar.dismiss();
Intent i = new Intent(Loading2.this, menuutama.class);
finish();
startActivity(i);
}}}).start();
}
// file download simulator... a really simple
public int doSomeTasks() {
while (fileSize <= 1000000) {
fileSize++;
if (fileSize == 100000) {return 10;}
else if (fileSize == 200000) {return 20;}
else if (fileSize == 300000) {return 30;}
// ...add your own
}
return 100;
}
Subscribe to:
Posts (Atom)
Mengganti Icon Marker Di Maps
Creating an icon https://leafletjs.com/examples.html var greenIcon = ...
-
Permission Internet < uses-permission android :name ="android.permission.ACCESS_FINE_LOCATION" /> < uses-permission a...
-
Button Add public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, 1, 0, "Add New").setIcon(R.drawable.add); ...
-
Link Ke Koordinat XML <EditText android:background="#dddddd" android:id="@+id/txttelepon...