Insert a Splashscreen or imageView into app crosswalk webview

Asked

Viewed 193 times

-1

I have a crosswalk webview application. as my site takes about 5 seconds to open on screen, I thought about inserting a splashscreen or imagemview ( I don’t know if there’s a difference between the two - I’m starting yet ) and letting it appear for 5 seconds on the screen.

I have also seen people entering the splashscreen or imagemview on the home screen and it disappears when the page is loaded.

both solutions would be great , but I can’t do it.

below I’ll leave my code.

Maindactivity.java

package com.ovortex.myapplication;

import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import org.xwalk.core.XWalkActivity;
import org.xwalk.core.XWalkView;

public class MainActivity extends XWalkActivity {



    private XWalkView xWalkWebView;

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

        xWalkWebView=(XWalkView)findViewById(R.id.xwalkWebView);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//<----verifica se o dipositivo é api 19 / Android 4.4

            getWindow().getDecorView().setSystemUiVisibility(

                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

                            | View.SYSTEM_UI_FLAG_LOW_PROFILE
                            | View.SYSTEM_UI_FLAG_FULLSCREEN // esconde a barra de status
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }

    }

    @Override
    protected void onXWalkReady() {
        // carregar uma url local
        xWalkWebView.loadUrl("http://xxxxxx.com");
    }


}

Activity.main.xml

<?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="com.ovortex.myapplication.MainActivity">

    <org.xwalk.core.XWalkView
        android:id="@+id/xwalkWebView"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#fff"
        />

</RelativeLayout>

Androidmanifest.xml

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

    <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:theme="@style/AppTheme">

        <activity android:name=".MainActivity" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

  • And that in order to ask an android app question the question will give credits? Chestnut part, if you want help put the code, Stackoverflow in Portuguese is different from Stackoverflow in English.

  • @Pedroferreira I edited the question and put the code inside.

  • It is necessary to rewrite enough, should not try to start two Activity at the same time, a possible solution would be to use Fragments, It is simple to start two Fragments simultaneously and only Splashfragment will be visible with a Handle.Delayed calling an Activity method that will close Splashfragment and make Fragment visible with Crosswalk Webview. But we’re not talking about solving a bug, but rewriting almost from scratch hence my -1 the question.

  • As a side note, with so many API’s and technology available, thinking of a mobile app as just a browser for a heavy site is crazy and do not take into account the user’s data plan.

  • I believe the solution to your problem is to leave everything on an Activity only, and hide the splashscreen view when the site is loaded. It’s not the best solution, by the way, but use a Framelayout with a view hiding all of Activity last. When you finish loading, hide that view and you’re done. But even giving this solution, take a look at the concepts of Fragment and hybrid applications designed in another way, can help you in another situation. I even had one that the customer just wanted a layer over the site as app and had to be just like his.

  • @group computer Cds can give me a north how to do ? You know where I can find a tutorial ?

  • I’ll comment as an answer to you ;)

  • @Grupocdsinformática I edited the question for better understanding.

  • @Pedroferreira I edited the question more clearly, about your opinion about user data - my audience will be people who listen to music on Youtube by mobile. then it will be trading six for half a dozen say, but my app will have a bigger and clean organization. vlw man

Show 4 more comments

1 answer

0


First of all, you should only have Mainactivity. Its layout will be as follows::

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/swipeContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            >

            <org.xwalk.core.XWalkView
                android:id="@+id/xwalkWebView"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#fff"
                >

            </org.xwalk.core.XWalkView>

        </android.support.v4.widget.SwipeRefreshLayout>

    </RelativeLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:id="@+id/splash">

        <!--Aqui vai qualquer elemento da sua splash, ou tema -->

    </LinearLayout>
</FrameLayout>

Then on your Mainactivity, what you’ll do: Once you upload the site, you’ll hide the splash view, more specifically on this piece (correct me if I’m wrong, I’ve never used Xwalk blzz)

mWebview.setResourceClient(new XWalkResourceClient(mWebview){
        public void onProgressChanged(XWalkView view, int progress) {
            if (progress == 100) {
                findViewById(R.id.splash).setVisibility(View.GONE);
            }
        }
    });

Test and give me feedback.

  • Computer Cds I’ll do the test here, the idea is while the splash is viewed the url is loaded in the background. , so when the splash is finished loading at the time set, the site will be loaded when the splash leaves the screen. I will test here and already pass the feedback

Browser other questions tagged

You are not signed in. Login or sign up in order to post.