Skip to content

Instantly share code, notes, and snippets.

@a1yama
Created January 20, 2016 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a1yama/211cc0d051297c66db81 to your computer and use it in GitHub Desktop.
Save a1yama/211cc0d051297c66db81 to your computer and use it in GitHub Desktop.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = getApplicationContext();
gcm = GoogleCloudMessaging.getInstance(this);
registerInBackground();
webView = (WebView) findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (!url.startsWith("file:") && !url.startsWith("http:") && !url.startsWith("https:")) {
webView.stopLoading();
Intent intent = new Intent(getApplication(), InfoActivity.class);
startActivity(intent);
return true;
}
return super.shouldOverrideUrlLoading(view, url);
}
});
webView.loadUrl("http://hoge.jp/");
webView.getSettings().setJavaScriptEnabled(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment