Android App for AppGini

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
sathukorala
AppGini Super Hero
AppGini Super Hero
Posts: 121
Joined: 2020-02-16 16:29

Android App for AppGini

Post by sathukorala » 2020-07-05 13:42

This is for people who know Android Studio https://developer.android.com/studio This uses simple webview to load your app which is very useful because you need not to access any browser in your mobile device.
Yet if you don't know Android Studio this is very simple to pick up
If you really cannot do this I will help you (send me the public url for your project without any passwords) I will send you the apk file. :D :D :D

activity_main.xml

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"/>

</RelativeLayout>


MainActivity.java

Code: Select all

package YOUR PACKAGE NAME;

import androidx.appcompat.app.AppCompatActivity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {

    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webView = (WebView) findViewById(R.id.webview);
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("YOUR PUBLIC URL");

        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
    }

    @Override
    public void onBackPressed() {
        if (webView.canGoBack()){
            webView.goBack();
        }
        else {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage("Are you sure you want to exit?")
                    .setCancelable(false)
                    .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            MainActivity.super.onBackPressed();
                        }
                    })
                    .setNegativeButton("No", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.cancel();
                        }
                    });
            AlertDialog alertDialog = builder.create();
            alertDialog.show();
        }
    }
}
AndroidManifest.xml

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="YOUR PACKAGE NAME">

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:usesCleartextTraffic="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Android App for AppGini

Post by jsetzer » 2020-07-06 07:26

That's awesome, thanks a lot!!!

Screenshot_20200706-092217_OCMS Mobile-1.jpg
Screenshot_20200706-092217_OCMS Mobile-1.jpg (40.17 KiB) Viewed 3547 times
Screenshot_20200706-092358_OCMS Mobile.jpg
Screenshot_20200706-092358_OCMS Mobile.jpg (40.98 KiB) Viewed 3547 times
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

sathukorala
AppGini Super Hero
AppGini Super Hero
Posts: 121
Joined: 2020-02-16 16:29

Re: Android App for AppGini

Post by sathukorala » 2020-07-06 08:09

jsetzer wrote:
2020-07-06 07:26
That's awesome, thanks a lot!!!


Screenshot_20200706-092217_OCMS Mobile-1.jpg


Screenshot_20200706-092358_OCMS Mobile.jpg

So happy to see it's been successful.
Thanks Jan

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Android App for AppGini

Post by jsetzer » 2020-07-06 08:51

It was a bit of a hassle to install Android Studio and fix the build errors (change package name, import R), but finally it works.
It opens up new perspectives and raises new ideas.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: Android App for AppGini

Post by D Oliveira » 2020-07-06 10:38

corona sdk has a "one liner" that will work on both iOS and Android, check it out

https://coronalabs.com/

https://docs.coronalabs.com/api/library ... bView.html

sathukorala
AppGini Super Hero
AppGini Super Hero
Posts: 121
Joined: 2020-02-16 16:29

Re: Android App for AppGini

Post by sathukorala » 2020-07-07 02:33

jsetzer wrote:
2020-07-06 08:51
It was a bit of a hassle to install Android Studio and fix the build errors (change package name, import R), but finally it works.
It opens up new perspectives and raises new ideas.

Glad it worked Jan.
Yes it's a bit of a process to work with Android Studio because it is designed for advance users.
I can provide the Android studio package file but a new user have to install the software first.

I only wanted to open up new perspectives as now more and more mobile devices are becoming popular than PCs

New commers can test the apk file designed to run AppGini demo application in any Android device


Post Reply