如何在android webview中处理特定网址?

时间:2017-03-19 23:53:42

标签: android android-studio webview android-webview intentfilter

我想打开链接" https://appear.in/terochat-t192f"在我的应用程序中的自定义webview中。当我开始一个包含这个webview的新活动时,我面对这个页面:

enter image description here

当我点击按钮"加入对话" ,我突然面对没有找到这样的页面:

enter image description here

当我在互联网上搜索时,我发现我应该使用AndroidManifest.xml中的intent-filter处理Url:

<activity android:name=".MainSegment.Team.Team_Profile.Chatroom.VideoChatroomActivity">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:scheme="https"
                android:host="appear.in"/>
        </intent-filter>
    </activity>

但它还没有解决我的问题!

这是包含此WebView的活动中的JAVA代码:

public class VideoChatroomActivity extends AppCompatActivity implements AdvancedWebView.Listener{
private AdvancedWebView teamChatWebView;

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

    teamChatWebView = (AdvancedWebView) findViewById(R.id.webview_team_video_chat);
    teamChatWebView.setListener(this, this);
    teamChatWebView.addPermittedHostname("appear.in");
    teamChatWebView.loadUrl("https://appear.in/terochat-t192f");
}

@SuppressLint("NewApi")
@Override
protected void onResume() {
    super.onResume();
    teamChatWebView.onResume();
}

@SuppressLint("NewApi")
@Override
protected void onPause() {
    teamChatWebView.onPause();
    // ...
    super.onPause();
}

@Override
protected void onDestroy() {
    teamChatWebView.onDestroy();
    // ...
    super.onDestroy();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    teamChatWebView.onActivityResult(requestCode, resultCode, intent);
    // ...
}

@Override
public void onBackPressed() {
    if (!teamChatWebView.onBackPressed()) { return; }
    // ...
    super.onBackPressed();
}


@Override
public void onPageStarted(String url, Bitmap favicon) {
}

@Override
public void onPageFinished(String url) {

}

@Override
public void onPageError(int errorCode, String description, String failingUrl) {

}

@Override
public void onDownloadRequested(String url, String suggestedFilename, String mimeType, long contentLength, String contentDisposition, String userAgent) {

}

@Override
public void onExternalPageRequest(String url) {

}

}

请帮我解决,谢谢先进!

0 个答案:

没有答案