0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

android WebView サンプル

Last updated at Posted at 2018-02-08

■インストール
android端末接続
  Android_SDK_Manager
    → installer_r24.4.1-windows
  → android-studio-ide-version-windows

※問題点
Android SDK エミュレータで 「Open HAX device failed」エラーが発生した。
エラー情報:
13:36 Emulator: Open the vm device error:\.\hax_vm00, ec:2
13:36 Emulator: Failed to open vm 0
13:36 Emulator: Failed to create HAX VM
13:36 Emulator: No accelerator found.
13:36 Emulator: failed to initialize HAX: Invalid argument

※対応方法
SDK Managerで HAXMのインストールは「not compatible with windows」といメッセージがあるため、ダウンロードできないそうです。
下記のページから、
https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm
haxm-windows_v7_0_0.zip (7.0.0)をダウンロードし、インストールして該当問題を解消しました。

■サンプル

WebViewを使ってサンプルを作成する。
1.レイアウト作成
app→res→layout→activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="25dp">
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    />
</RelativeLayout>

app→mainfests→AndroidManifest.xmlに下記ソースを追加する。

<uses-permission android:name="android.permission.INTERNET"/>
<application>
   略
</application>

2.WebViewを作成

app→java→leonbase.com.android→MainActivity

public class MainActivity extends AppCompatActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  WebView webView = (WebView)findViewById(R.id.mainView);
  webView.setWebViewClient(new WebViewClient());
  webView.loadUrl("www.google.co.jp");
  webView.getSettings().setJavaScriptEnabled(true);
  }
}

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?