Get the App
SLTechnology News&Howtos  ›  Development  › 

How to encapsulate HTML into APP

Shulou Source: shulou.com Published: 2022-06-01 06:02:50 10月04日 Update

This article mainly shows you "how to encapsulate HTML into APP", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to encapsulate HTML into APP" this article.

1. Android is used for testing here to ensure that the Java and Android environments are OK.

2. Start the platform. My platform is implemented by Django+python. So start the service first.

Note: to start the service here, you are required to use an IP address other than 127.0.0.1. I found that if I used it, the link could not be opened on the phone (on the same LAN). I used ifconfig to check the local IP address, using python manage.py runserver * (* represents your IP address, as well as a non-collision port number).

3. Fill in the address in the Android project you built.

4. Create an Android project and use webview to display the web page.

Newly built

Fill in the name yourself.

Version

If you choose the version of SDK, you can also check the coverage of the version, which does not require a direct default.

Blank activity

Select the blank activity here.

Fill in the name

The name is customized here.

5. Open the MainActivity.java program file and add the following to the onCreate () method:

Import android.support.v7.app.AppCompatActivity

Import android.os.Bundle

Import android.webkit.WebView;?

Public class MainActivity extends AppCompatActivity {??

@ Override

Protected void onCreate (Bundle savedInstanceState) {?

Super.onCreate (savedInstanceState);?

SetContentView (R.layout.activity_main);?

WebView wv = (WebView) findViewById (R.id.wv)

Wv.loadUrl ("*")

}

}

If you report an error here, you need to modify the version in gradle, * for your address.

6. Open AndroidManifest.xml and set to allow programs to access the Internet:

Xml version= "1.0"? encoding=" utf-8 "? >

7. Connect a real machine or a virtual machine to run the test.

Desktop display

Virtual display

There is no adaptation here, so the presentation is a little out of shape.

8. Export Android to apk

Using Android Studio with its own build, just choose build apk.

The above is all the contents of the article "how to encapsulate HTML into APP". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Address content version package name article selection platform program blank project learning help service activity test representative slogan Internet world Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Tech Info Apple macOS MariaDB