github.com/c-darwin/mobile@v0.0.0-20160313183840-ff625c46f7c9/app/work-cross/MainActivity.java (about) 1 package org.golang.app; 2 3 import android.app.Activity; 4 import android.content.Context; 5 import android.content.Intent; 6 import android.os.Bundle; 7 import android.view.View; 8 import android.view.View.OnClickListener; 9 import android.widget.Button; 10 import android.webkit.WebView; 11 import android.webkit.WebViewClient; 12 import org.xwalk.core.XWalkView; 13 import android.widget.LinearLayout; 14 import org.chromium.base.library_loader.LibraryLoader; 15 import android.util.Log; 16 import android.app.Service ; 17 18 public class MainActivity extends Activity { 19 20 private WebView webView; 21 private LinearLayout commentsLayout; 22 private XWalkView mXWalkView; 23 24 static { 25 try { 26 System.loadLibrary("xwalkcore"); 27 } catch (UnsatisfiedLinkError e) { 28 System.err.println("xwalkcore code library failed to load 02.\n" + e); 29 System.exit(1); 30 } 31 Log.d("Go", "xwalkcore loaded"); 32 33 try { 34 System.loadLibrary("xwalkdummy"); 35 } catch (UnsatisfiedLinkError e) { 36 System.err.println("xwalkdummy code library failed to load 03.\n" + e); 37 System.exit(1); 38 } 39 Log.d("Go", "xwalkdummy loaded"); 40 } 41 42 public void onCreate(Bundle savedInstanceState) { 43 44 super.onCreate(savedInstanceState); 45 46 Log.d("Go", "MainActivity onCreate"); 47 48 49 50 51 /*setContentView(R.layout.webview); 52 webView = (WebView) findViewById(R.id.webView1); 53 webView.getSettings().setJavaScriptEnabled(true); 54 webView.setWebViewClient(new WebViewClient()); 55 webView.loadUrl("http://www.google.com"); 56 */ 57 /*setContentView(R.layout.activity_xwalk_embed_lib); 58 commentsLayout=(LinearLayout)findViewById(R.id.principal); 59 xWalkWebView = new XWalkView(this, this); 60 //xWalkWebView.load("file:///android_asset/www/index.html", null); 61 final String html = "<html><body bgcolor=\"#090998\"><h1>Hello world!</h1></body></html>"; 62 xWalkWebView.load(null, html); 63 commentsLayout.addView(xWalkWebView);*/ 64 /* 65 setContentView(R.layout.activity_xwalk_embed_lib); 66 commentsLayout=(LinearLayout)findViewById(R.id.principal); 67 mXWalkView = new XWalkView(this.getApplicationContext(), this); 68 /*mXWalkView = (XWalkView) findViewById(R.id.activity_main); 69 mXWalkView.load("http://crosswalk-project.org/", null);*/ 70 71 72 setContentView(R.layout.activity_xwalk_embed_lib); 73 commentsLayout=(LinearLayout)findViewById(R.id.principal); 74 mXWalkView = new XWalkView(this, this); 75 //final String html = "<html><body bgcolor=\"#090998\"><h1>Hello world!</h1></body></html>"; 76 mXWalkView.load("http://google.com", null); 77 commentsLayout.addView(mXWalkView); 78 79 80 Runnable r = new Runnable() { 81 public void run() { 82 GoNativeActivity.load(); 83 } 84 }; 85 Thread t = new Thread(r); 86 t.start(); 87 88 89 } 90 91 }