I am building an .aar library with activities inside built using Ionic. The platform is migrated over from Ionic platform build to Android Studio to build the aar.
The MainActivity in the .aar is extending class android.app.Activity instead of CordovaActivity. This is to allow external android app using the .aar to invoke the activity embedded in the .aar.
I am having difficulties invoking the Ionic activity because the index.html is displayed static. How do I invoke the Ionic pages from MainActivity using WebView that still allows it to flow like Ionic pages?
I’ve tried invoking the index.html but it displays a static empty page. I tried to put in Javascript to load the home page but it doesn’t work as well. I tried using deep linking, but because it is in an .aar, it could not be found.
My Codes:
import android.os.Bundle;
import org.apache.cordova.*;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.WebSettings;
import android.app.Activity;
public class MainActivity extends Activity //this is changed from CordovaActivity
{
String launchUrl = “”;
WebView mWebview = null;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
launchUrl = "file:///android_asset/www/index.html"; //call the page
mWebview = new WebView(this);
mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript
WebSettings webSetting = mWebview.getSettings();
webSetting.setBuiltInZoomControls(true);
webSetting.setJavaScriptEnabled(true);
mWebview.setWebViewClient(new WebViewClient());
mWebview.loadUrl(launchUrl); //this just displays static empty index.html
setContentView(mWebview );
}
}