Emmm.. Salam Informatika, Sekarang gw baru nulis artikel lagi nih, setelah lulus kuliah. kesibukan kerja buat gw lupa akan blogger gw..
Sekarang gw mau kasi source tentang pembuatan launcher Aplikasi web dengan Android. seperti launcher detik.com dan kompas.com, atau sebagainya. Berikut Tampilan dari launcher android Nya.
Gambar 1. Splash Screen Android |
Gambar 2. Nih Gambar webview |
aplikasi ini sudah tersedia, imei, serta progress bar, untuk scriptnya bisa di lihat di bawah ini..
package com.ais.arsenal; import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.Window; import android.webkit.WebSettings; import android.webkit.WebSettings.ZoomDensity; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; import android.telephony.TelephonyManager; public class Main extends Activity { private WebView webview; private static final String TAG = "Main"; private ProgressDialog progressBar; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); String numbEmei = tm.getDeviceId(); String numberHp = getMyPhoneNumber(); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); this.webview = (WebView)findViewById(R.id.webview); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); //final AlertDialog alertDialog = new AlertDialog.Builder(this).create(); progressBar = ProgressDialog.show(Main.this, "", "Loading..."); webview.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.i(TAG, "Processing webview url click..."); Toast.makeText(getApplicationContext(),"Loading", Toast.LENGTH_SHORT).show(); view.loadUrl(url); return true; } public void onPageFinished(WebView view, String url) { Log.i(TAG, "Finished loading URL: " +url); if (progressBar.isShowing()) { progressBar.dismiss(); } } public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.e(TAG, "Error: " + description); setContentView(R.layout.gagalkonek); } }); //setWebViewClient webview.loadUrl("http://sezuka.com/"); webview.getSettings().setDefaultZoom(ZoomDensity.FAR); } public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.e(TAG, "Error: " + description); startActivity(new Intent(this, gagalkonek.class)); } public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.opt_menu, menu); return true; } public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.ubuntu: Toast.makeText(getApplicationContext(),"Loading", Toast.LENGTH_SHORT).show(); webview.loadUrl("http://poca-apps.com:9000/ais/macanbola.php"); return true; case R.id.arc: Toast.makeText(getApplicationContext(),"Loading", Toast.LENGTH_SHORT).show(); webview.loadUrl("http://poca-apps.com:9000/ais/index.php"); return true; case R.id.fedora: Toast.makeText(getApplicationContext(),"Loading", Toast.LENGTH_SHORT).show(); webview.loadUrl("http://poca-apps.com:9000/ais/wallpp.php"); return true; case R.id.gento: Toast.makeText(getApplicationContext(),"Loading", Toast.LENGTH_SHORT).show(); webview.loadUrl("http://poca-apps.com:9000/ais/PMA.php"); return true; case R.id.gnome: Toast.makeText(getApplicationContext(),"Loading", Toast.LENGTH_SHORT).show(); System.exit(0); return true; default: return super.onOptionsItemSelected(item); } } //onOptionsItemSelected public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK){ if(webview.canGoBack()){ webview.goBack(); return true; } } return super.onKeyDown(keyCode, event); } private String getMyPhoneNumber(){ TelephonyManager mTelephonyMgr; mTelephonyMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); return mTelephonyMgr.getSimSerialNumber(); } }
Berikut Link DownloadNya
1 komentar:
ane nyoba projrk ini kok yang tampil halaman gagal konek gan, gimana solusinya gan ? thanks
Posting Komentar