Framework7 inside webview pages not loading
Asked Answered
I

1

8

I am new to framework7 and I am trying to make it work inside on android.

Here's what I did, Created project in android studio, with webview to load index.html and it works. But the link to the pages "about", "services" and "form" doesn't work.

I saw that framework7 uses ajax to call those pages.

So I think it doesn't work in webview that way correct?

Do I need to change the way framework7 initializes to load pages using javascript or what?

It is possible to make it work that way? Load the contents of another html file as page and not using "inline" pages?

Some advice?

Update with my code (using android studio):

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="atlasdb.atlasdatabase.MainActivity">

    <WebView
        android:id="@+id/atlasdatabase"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />
</RelativeLayout>

MainActivity.java:

package app.apptest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class MainActivity extends AppCompatActivity {

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

        WebView myWebView = (WebView) findViewById(R.id.apptest);
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        webSettings.setAppCacheEnabled(true);
        webSettings.setDatabaseEnabled(true);
        myWebView.loadUrl("file:///android_asset/index.html");

    }
}

AndroidManifest.xml:

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

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

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

</manifest>
Ixia answered 25/8, 2016 at 14:46 Comment(6)
I also got same problem. Please, leave a comment when you will find the solutionYammer
can you share code done so far along with error if any in logs?Zoubek
I added the code that I am using, and the index.html is the file provided with framework7, using a webbrowser in wamp it works fine, but in android it doesn't work. I know that it can work offline because there's an app in playstore called framework7 demo, that works offline, even the Ajax page transitions.Ixia
It's work perfect! I have download the latest Framework7 start kit. and put it the assets folder the load the same as your code above, and it works.Chukker
The pages about and contact load? Because Here it doesn't.Ixia
I solved this by allowing access for filesChukker
C
4

Allow file access to your webview by adding these lines to webSettings:

webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);

Example project:

Andorid-Framework7-StartKit at Github

Chukker answered 7/9, 2016 at 17:55 Comment(1)
Thank you so much! It Works!Ixia

© 2022 - 2024 — McMap. All rights reserved.