Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. package com.just.agentweb.advancedwebview;
  2.  
  3. import android.content.Intent;
  4. import android.net.Uri;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.view.ViewGroup;
  8. import android.webkit.WebView;
  9. import android.webkit.WebViewClient;
  10. import android.widget.FrameLayout;
  11. import com.just.agentweb.AgentWeb;
  12.  
  13. public class AgentActivity extends AppCompatActivity {
  14.  
  15. private AgentWeb mAgentWeb;
  16.  
  17. @Override
  18. protected void onCreate(Bundle savedInstanceState) {
  19. super.onCreate(savedInstanceState);
  20. setContentView(R.layout.activity_agent);
  21.  
  22. mAgentWeb = AgentWeb.with(this)
  23. .setAgentWebParent((ViewGroup) findViewById(R.id.framelayout), new FrameLayout.LayoutParams(-1, -1))
  24. .useDefaultIndicator()
  25. .setWebViewClient(mWebViewClient)
  26. .createAgentWeb()//
  27. .ready()
  28. .go("file:///android_asset/myweb.html");
  29.  
  30. }
  31.  
  32. protected WebViewClient mWebViewClient = new WebViewClient() {
  33.  
  34. @Override
  35. public boolean shouldOverrideUrlLoading(WebView view, String url) {
  36.  
  37. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
  38. startActivity(intent);
  39. return true;
  40. }
  41.  
  42. };
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement