Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
其他活动Android Studio的Webview有问题吗?_Android_Android Activity_Webview_Android Studio - Fatal编程技术网

其他活动Android Studio的Webview有问题吗?

其他活动Android Studio的Webview有问题吗?,android,android-activity,webview,android-studio,Android,Android Activity,Webview,Android Studio,我有一个名为PubliComidas的项目,在我的项目中有3项活动。第一个是SplashScreen,第二个是我的MainActivity,第三个是在MainActivity中单击按钮时加载的WebView,问题是WebView没有像我预期的那样工作 当我运行我的应用程序并点击按钮时,它会显示:网页不可用net::ERR_CACHE_MISS,然而这很奇怪,因为我试图在另一个项目中测试相同的代码,p.D,当你第一次启动一个新项目时,它仅在一个空白活动中测试,相同的步骤和它的作品完美,但不是在这个

我有一个名为PubliComidas的项目,在我的项目中有3项活动。第一个是SplashScreen,第二个是我的MainActivity,第三个是在MainActivity中单击按钮时加载的WebView,问题是WebView没有像我预期的那样工作

当我运行我的应用程序并点击按钮时,它会显示:网页不可用net::ERR_CACHE_MISS,然而这很奇怪,因为我试图在另一个项目中测试相同的代码,p.D,当你第一次启动一个新项目时,它仅在一个空白活动中测试,相同的步骤和它的作品完美,但不是在这个应用程序中,所以这是一个问题与此活动?或者webview不能显示很多活动,我的第一个和第二个活动很好,但第三个不行,我的想法是显示google。我的目标是显示twitter提要,但首先,如果它不能与谷歌合作,即使它不能与twitter合作。非常感谢您的帮助,谢谢

这是我的密码

Twitter.java

MyWebViewClient.java

AndroidManifest.xml

activity_twitter.xml


权限声明应在应用程序标记之外。像这样:

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

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.json.publicomidas.Twitter"
            android:label="@string/twitter" >
        </activity>
        <activity
            android:name="com.example.json.publicomidas.MainActivity"
            android:label="@string/app_name" >

        </activity>

        <activity
            android:name="com.example.json.publicomidas.Splash_Screen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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


        </activity>

    </application>

</manifest>
package com.example.json.publicomidas;

import android.content.Intent;
import android.net.Uri;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class MyWebViewClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url){
        if (Uri.parse(url).getHost().endsWith("www.google.co.cr")){
            return false;

        }

        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        view.getContext().startActivity(intent);
        view.loadUrl(url);
        return true;


    }


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

    <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.json.publicomidas.Twitter"
            android:label="@string/twitter" >
        </activity>
        <activity
            android:name="com.example.json.publicomidas.MainActivity"
            android:label="@string/app_name" >

        </activity>

        <activity
            android:name="com.example.json.publicomidas.Splash_Screen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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


        </activity>

        <uses-permission android:name="android.permission.INTERNET" />


    </application>

</manifest>
<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"
    android:background="@drawable/images"
    tools:context="com.example.json.publicomidas.Twitter">

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

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

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.json.publicomidas.Twitter"
            android:label="@string/twitter" >
        </activity>
        <activity
            android:name="com.example.json.publicomidas.MainActivity"
            android:label="@string/app_name" >

        </activity>

        <activity
            android:name="com.example.json.publicomidas.Splash_Screen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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


        </activity>

    </application>

</manifest>