Android 带下载网站的SplashScreen并将其传递给webview

Android 带下载网站的SplashScreen并将其传递给webview,android,webview,android-asynctask,Android,Webview,Android Asynctask,我想用splashscreen活动打开应用程序并下载我网站的主页。下载完成后,我想启动MainActivity,将网站传递到webview并显示它。 我尝试了一些不同的方法,但都不管用。。 我的当前版本在MainActivity启动时加载webview,而在加载网站时这看起来不太好。 你有什么想法吗 public class SplashScreen extends Activity { @Override protected void onCreate(Bundle saved

我想用splashscreen活动打开应用程序并下载我网站的主页。下载完成后,我想启动MainActivity,将网站传递到webview并显示它。 我尝试了一些不同的方法,但都不管用。。 我的当前版本在MainActivity启动时加载webview,而在加载网站时这看起来不太好。 你有什么想法吗

public class SplashScreen extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_screen_layout);
        try {
            url = new URL(link);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        new WczytywaczUrl().execute(url);
    }
    //asynctask class and methods
    @Override
        protected void onPostExecute(String result) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
            Log.d(TAG, result.toString());
            Intent intent = new Intent(SplashScreen.this, MainActivity.class);
            intent.putExtra("strona", result);
            startActivity(intent);
            finish();
        }


    public class MainActivity extends Activity implements OnClickListener{

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        Log.d(TAG, "metoda onCreate");
        setContentView(R.layout.activity_main);
        webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setUseWideViewPort(true);

        Intent i = getIntent();
        String strona = i.getStringExtra("strona");
        Log.d(TAG, "strona: " + strona.toString());
        webView.loadDataWithBaseURL(link, strona, "text/html", "UTF-8", null);
    }
    }
用另一个布局替换“活动”怎么样

<FrameLayout>
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <Layout1
        android:layout_width="match_parent"
        android:layout_height="match_parent">
           // Layout contents that origin from your splash activity layout
    </Layout1>
    <Layout2
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="invisible">
           // Layout contents that origin from your main activity layout
    </Layout2>
</FrameLayout>

android:layout\u width=“匹配父项”
android:layout\u height=“match\u parent”>
//源自初始活动布局的布局内容
//源自主活动布局的布局内容
WebViewClient具有“”回调

如果实现了更改该回调中Layout1和Layout2可见性的代码,
加载完成后,可能会显示webview。

发布的代码应该可以工作。在启动屏幕活动中,将下载网页。然后,主活动启动,页面通过intent传输并加载到webview中。什么不起作用?看起来splashScreen没有将所有html文件下载到字符串,所以它没有将所有数据传递到mainactivity,webview正在从internet(而不是字符串)下载。您的评论令人困惑。在您的代码中,web视图显示在
String strona
中下载的网页上。如果asynctask没有完全下载页面,那么您应该立即声明。什么是源html的不完整部分?当我在logcat中打印它时,它结束于“当MainActivity运行时,我必须等待几秒钟才能看到完全下载的webview