Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

MainActivity.java: uses or overrides a deprecated API. Recompile with -Xlint:deprecation for details

package com.founderwm.braderhud; import android.app.ProgressDialog; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.NavigationView; import android.support.design.widget.Snackbar; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { private WebView wv; @RequiresApi(api = Build.VERSION_CODES.ECLAIR_MR1) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); DrawerLayout drawer = findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); wv = findViewById(R.id.webView1); WebSettings settings = wv.getSettings(); settings.setJavaScriptEnabled(true); wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH); wv.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); wv.getSettings().setAppCacheEnabled(true); wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); settings.setDomStorageEnabled(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); settings.setUseWideViewPort(true); settings.setSavePassword(true); settings.setSaveFormData(true); wv.loadUrl("https://www.braderhud.com/register/ref/081312662637"); wv.setWebViewClient(new MywebViewClient()); wv.setWebViewClient(new webView1()); } private class webView1 extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } @Override public void onBackPressed() { DrawerLayout drawer = findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_home) { // Handle the camera action wv.loadUrl("https://www.braderhud.com/register/ref/081312662637"); } else if (id == R.id.nav_registrasi) { wv.loadUrl("https://www.braderhud.com/register/ref/081312662637"); } else if (id == R.id.nav_facebook) { wv.loadUrl("https://web.facebook.com/"); } else if (id == R.id.nav_google) { wv.loadUrl("https://www.google.co.id/"); } DrawerLayout drawer = findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; } private class MywebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading (WebView view, String url) { if (Uri.parse(url).getHost().equals("https://www.braderhud.com/register/ref/081312662637")){ return false; } else { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } } ProgressDialog pd = null; @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { pd = new ProgressDialog(MainActivity.this); pd.setTitle("please wait..."); pd.setMessage("Website is loading.."); pd.show(); super.onPageStarted(view, url, favicon); } @Override public void onPageFinished (WebView view, String url) { pd.dismiss(); super.onPageFinished(view, url); } } @Override public boolean onKeyDown (int keyCode, KeyEvent event) { if (event.getAction()== KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (wv.canGoBack()) { wv.goBack(); } else { finish(); } return true; } } return super.onKeyDown(keyCode, event); } }
Sign In or Register to comment.