Difference between revisions of "Build App with Android-Studio"

From Digipool-Wiki
Jump to: navigation, search
(Created page with "https://www.youtube.com/watch?v=Z0o3VodAiWU Im Manifest oben gleich hinter der Pagacke=... Zeile: <uses-permission android:name="android.permission.INTERNET"></uses-perm...")
(No difference)

Revision as of 18:22, 12 September 2019

https://www.youtube.com/watch?v=Z0o3VodAiWU



Im Manifest oben gleich hinter der Pagacke=... Zeile:

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

...und hinter <Application

android:supportsRtl="true"



MainActivity.java

package com.example.t2much;

import android.graphics.Bitmap; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {
    private WebView mywebview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mywebview = (WebView) findViewById(R.id.myPage);
        WebSettings webSettings=mywebview.getSettings();
        mywebview.loadUrl("http://projects.olafval.de/touch2much/");
        webSettings.setJavaScriptEnabled(true);
    }

    public class myWebClient extends WebViewClient{
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon){
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url){
            view.loadUrl(url);
            return true;
        }
    }

    @Override
    public void onBackPressed(){
        if(mywebview.canGoBack()){
            mywebview.goBack();
        }else{
            super.onBackPressed();
        }
    }
}



WWW Dateien einbinden Diese Zeile mywebview.loadUrl("http://projects.olafval.de/touch2much/");

ersetzen durch

mywebview.loadUrl("file:///android_assest/*");