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>
RogerHN
  • 584
  • 1
  • 11
  • 31
  • I also got same problem. Please, leave a comment when you will find the solution – moonvader Aug 30 '16 at 12:01
  • can you share code done so far along with error if any in logs? – Amod Gokhale Sep 02 '16 at 08:47
  • 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. – RogerHN Sep 02 '16 at 20:29
  • 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. – David Antoon Sep 07 '16 at 17:45
  • The pages about and contact load? Because Here it doesn't. – RogerHN Sep 07 '16 at 17:48
  • I solved this by allowing access for files – David Antoon Sep 07 '16 at 18:01

1 Answers1

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

David Antoon
  • 815
  • 6
  • 18