Advertising (This ad goes away for registered users. You can Login or Register)

[tutorial]html5 assets in android apk (portals to apk)

Discuss about your favorite (gaming...or not) devices here. The most popular ones will end up getting their own categories
Programming discussions for your favorite Device
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Post Reply
ivo2376
Posts: 27
Joined: Wed Jan 14, 2015 10:17 pm

[tutorial]html5 assets in android apk (portals to apk)

Post by ivo2376 » Sat Sep 15, 2018 11:53 pm

// You can build your application using
// - Android Studio

//MainActivity.java
package com.example.nick.glidematrixwebgl;

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 webiew= (WebView)
findViewById(R.id.webiew);
webiew.loadUrl("file:///android_asset/index.html");
webiew.getSettings().setJavaScriptEnabled(true);
}
}
//go stand on the first webiew en press alt-eneter for binding java to xml ...

//activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">


<WebView
android:id="@+id/webView"

android:layout_width="match_parent"
android:layout_height="match_parent" >
</WebView>

</android.support.constraint.ConstraintLayout>

//heres the rest of the read
In the learn section on ios mobile insololearn app quoted
press learn press view more open android webview
::quoted::
You can convert your HTML/CSS/JS code below as required in steps
first develop/download all the html js css u need
so it works in a browser or in codeplayground

1)Create a new project in android Studio choose empty activity
(correct me if im wrong)
2)Observer the structure of your project
Create an assets folder in the root app
Then create 3 files index.html index.js and index.js in the assets folder as file
Right Click assets => Click new => Click File to do that
3)Add the corresponding HTML/CSS/JS code to the newly created files
4)Use <link> and <script> elements to link the .css .js files in the .html file
5)Open your main activity XML file (activity_main.xml)
if you didnt change any names during project creation
in the layout (app/main/res/layout) folder.
Insert the below code inside the parent layout element:

<WebView
android:id="@+id/webView"

android:layout_width="match_parent"
android:layout_height="match_parent" >
</WebView>

This will create a WebView, that will stretch the entire screen

6)Open your main activity JAVA file(MainActivity.java)
if you didnt change any names during project creation
within the java (app/main/java) folder.
insert the below code inside the onCreate() method

WebView webView= (WebView)
findViewById(R.id.webView);
webView.loadUrl("file:///android_asset/index.html");
webView.getSettings().setJavaScriptEnabled(true);


Replace myHtml.html or inde.html with ur linkings in html naming
7)Optional Customize your WebView
8)Build The APK. Build an APK.

Thats it! You just converted your webcode into an android app!
Now go code ur favorite app again in html and export it to an APK.

now for the assets dir there a separete read.

https://stackoverflow.com/questions/183 ... oid-studio

intresting read about questions about assets folder

and a youtube video if ur not convinced
video guide of the above underneeth

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

Converting a HTML+CSS+JS Code into an Android App using Android Studio!
This video demonstrates how to create an android app from a HTML+CSS+JS code using Android Studio IDE.

https://www.sendspace.com/file/eeyr3b
demo project (jslinux_mobile_for_ios) html5 shows browser agent is not ios problem for html5 portal jlinux-mobile-for-ios

https://www.sendspace.com/file/aj84fr
working remake rebuilded with grepple dubbed JSLinux-mobile-online(since its an apk directly using the internetlink)
(without assets)

jslinux-mobile working url https://jm.iq.pl/jslinux-mobile/gT8vSX/ ... &options=1
Advertising

Post Reply

Return to “Programming and Security”