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...")
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
https://www.youtube.com/watch?v=Z0o3VodAiWU
 
 
  
 +
Hier eine der zahlreichen Anleitungen auf [https://www.youtube.com/watch?v=Z0o3VodAiWU YouTube]
  
 +
<br>
  
 +
'''Manifest'''
  
 
Im Manifest oben gleich hinter der Pagacke=... Zeile:
 
Im Manifest oben gleich hinter der Pagacke=... Zeile:
  
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
+
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
  
 
...und hinter <Application
 
...und hinter <Application
  
android:supportsRtl="true"
+
android:supportsRtl="true"
 
+
 
+
  
 +
<br>
  
 +
== MainActivity ==
  
 
MainActivity.java
 
MainActivity.java
  
package com.example.t2much;
+
<pre>
 +
package com.example.myName;
  
 
import android.graphics.Bitmap;
 
import android.graphics.Bitmap;
Line 28: Line 30:
 
import android.webkit.WebViewClient;
 
import android.webkit.WebViewClient;
  
<pre>
 
 
public class MainActivity extends AppCompatActivity {
 
public class MainActivity extends AppCompatActivity {
 
     private WebView mywebview;
 
     private WebView mywebview;
Line 36: Line 37:
 
         super.onCreate(savedInstanceState);
 
         super.onCreate(savedInstanceState);
 
         setContentView(R.layout.activity_main);
 
         setContentView(R.layout.activity_main);
         mywebview = (WebView) findViewById(R.id.myPage);
+
         mywebview = (WebView) findViewById(R.id.'''myPage''');
 
         WebSettings webSettings=mywebview.getSettings();
 
         WebSettings webSettings=mywebview.getSettings();
         mywebview.loadUrl("http://projects.olafval.de/touch2much/");
+
         '''mywebview.loadUrl("http://projects.olafval.de/touch2much/");'''
 
         webSettings.setJavaScriptEnabled(true);
 
         webSettings.setJavaScriptEnabled(true);
 
     }
 
     }
Line 66: Line 67:
 
</pre>
 
</pre>
  
 +
<br>
  
 +
== WWW Dateien einbinden ==
  
 
 
WWW Dateien einbinden
 
 
Diese Zeile
 
Diese Zeile
mywebview.loadUrl("http://projects.olafval.de/touch2much/");
+
 
 +
mywebview.loadUrl("http://projects.olafval.de/touch2much/");
  
 
ersetzen durch
 
ersetzen durch
  
mywebview.loadUrl("file:///android_assest/*");
+
mywebview.loadUrl("file:///android_assest/*");
 +
 
 +
<br>

Revision as of 17:29, 12 September 2019

Hier eine der zahlreichen Anleitungen auf YouTube


Manifest

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

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

...und hinter <Application

android:supportsRtl="true"


MainActivity

MainActivity.java

package com.example.myName;

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/*");