Created
May 15, 2015 05:06
-
-
Save rudyryk/77ccd0e06e815a09c761 to your computer and use it in GitHub Desktop.
Silver - basic sample for WebView on Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.example.hellofire"> | |
<!-- the android:debuggable="true" attribute is overwritten by the compiler when the debug info option is set --> | |
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<application | |
android:label="@string/app_name" | |
android:icon="@drawable/icon" | |
android:debuggable="true"> | |
<activity android:label="@string/app_name" android:name="com.example.hellofire.MainActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
</application> | |
<uses-sdk android:minSdkVersion="4" /> | |
</manifest> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" > | |
<WebView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/webview" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
/> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util | |
import android.app | |
import android.content | |
import android.os | |
import android.util | |
import android.view | |
import android.widget | |
import android.webkit | |
public class MainActivity: Activity { | |
public override func onCreate(savedInstanceState: Bundle!) { | |
super.onCreate(savedInstanceState) | |
ContentView = R.layout.main | |
let web: WebView = findViewById(R.id.webview) as! WebView | |
web.setWebViewClient(MyWebViewClient()) | |
web.loadUrl("http://httpbin.org/get") | |
} | |
} | |
public class MyWebViewClient : WebViewClient { | |
public override func onPageStarted(_ view: WebView!, _ url: String!, _ favicon: android.graphics.Bitmap!) { | |
Log.d("onpage " , url) | |
} | |
public override func shouldOverrideUrlLoading(_ view: WebView!, _ url: String!) -> Bool { | |
Log.d("Loading" , url) | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment