我在我的android應用程序中有一個webview。
我已經加載了網址:https://imsnsit.org/imsnsit/notifications.php
有鏈接到各種通知。當我點擊它們時,我的WebView無所事事。 它正在處理所有其他事情 - Chrome(Android),Chrome(桌面)。鏈接很好。我注意到的一件事情是使用PHP文件的href。只是導航到該鏈接不起作用。我得到無效操作。此外,鏈接不是靜態的,每次刷新頁面時都會更改(僅限plum_url.php的參數)。
我已經在使用這些功能。沒什麼幫助。
webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setDomStorageEnabled(true);
點擊無法在WebView中工作
回答
你可以在網頁視圖在新窗口打開這樣
WebView webviewContact=(WebView)findViewById(R.id.webviewcontact);
webviewContact.loadUrl("https://imsnsit.org/imsnsit/notifications.php");
webviewContact.clearCache(true);
webviewContact.clearHistory();
//webviewContact.getSettings().setDomStorageEnabled(true);
//webviewContact.getSettings().setSupportMultipleWindows(true);
webviewContact.getSettings().setJavaScriptEnabled(true); webviewContact.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webviewContact.setWebViewClient(new WebViewClient(){
/*For open new window in webview*/
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { Toast.makeText(getApplicationContext(),url,Toast.LENGTH_SHORT).show();
view.loadUrl(url);
return false;
}
});
我建議你開始使用自定義選項卡的更快,更好。具體實施是在https://developer.chrome.com/multidevice/android/customtabs
// Use a CustomTabsIntent.Builder to configure CustomTabsIntent.
// Once ready, call CustomTabsIntent.Builder.build() to create a CustomTabsIntent
// and launch the desired Url with CustomTabsIntent.launchUrl()
String url = ¨https://paul.kinlan.me/¨;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(url));
自定義選項卡,如果你是從你的Web視圖計劃沒有重定向的應用程序將是一個很好的解決方案。 webview的問題對你的實現非常具體,所以不能在這裏提出soln。請粘貼您如何打開網頁視圖的實施,以及您嘗試打開的php內容或鏈接是什麼。
其實我有我的應用程序中的通知列表。我想在用戶點擊時打開通知。事情是我想用Javascript來打開第一個通知(讓我們說),所以自定義選項卡不是選項 –
我檢查了您的鏈接,並且所有鏈接都打開了一個pdf文件,該文件在android web視圖中不受支持。您可以在Google文檔中打開這些鏈接,或者在您的設備中打開某些應用。 實現shouldOverrideUrlLoading像這樣。
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (urlIsPDF(url)){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "application/pdf");
try{
view.getContext().startActivity(intent);
} catch (ActivityNotFoundException e) {
//user does not have a pdf viewer installed
}
} else {
webview.loadUrl(url);
}
return true;
}
https://www.mkyong.com/android/android-webview-example/
創建兩個Android的佈局文件 - 「RES /佈局/ main.xml中」和「RES /佈局/網頁流量.XML「。
文件:RES /佈局/ main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/buttonUrl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Go to http://www.google.com" />
</LinearLayout>
文件:RES /佈局/ main.xml中 - 例如web視圖
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
兩個活動類,活動顯示一個按鈕,另一個活動使用預定義的URL顯示WebView。
文件:MainActivity.java
package com.mkyong.android;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
private Button button;
public void onCreate(Bundle savedInstanceState) {
final Context context = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.buttonUrl);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, WebViewActivity.class);
startActivity(intent);
}
});
}
}
文件:WebViewActivity.java
package com.mkyong.android;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebViewActivity extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.com");
}
}
的WebView要求INTERNET權限,下面加入到AndroidManifest.xml中。
<uses-permission android:name="android.permission.INTERNET" />
File:AndroidManifest.xml - 請參閱完整示例。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mkyong.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".WebViewActivity"
android:theme="@android:style/Theme.NoTitleBar" />
<activity
android:label="@string/app_name"
android:name=".MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
它會幫助你。
你試圖打開目標=「_空白」中的Android的WebView鏈接,以便嘗試下面的代碼。
首先補充一點:
webView.setWebChromeClient(webChromeClient);
webView.getSettings().setSupportMultipleWindows(true);
WebChromeClient webChromeClient = new WebChromeClient() {
@Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, Message resultMsg) {
WebView.HitTestResult result = view.getHitTestResult();
String data = result.getExtra();
Context context = view.getContext();
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(data));
context.startActivity(browserIntent);
return false;
}
};
使用這個你可以打開默認的瀏覽器該鏈接。
- 1. clearInterval無法在點擊上工作
- 2. 在點擊無法正常工作jquery
- 3. HTML5 navigator.online無法在WebView中工作
- 4. webview無法正常工作?
- 5. 無法加載按鈕點擊的WebView
- 6. android - 捏縮放無法正常工作,雙擊是。在webview
- 7. 無法獲得點擊=「{myTabNavigator.selectedIndex = 3}」工作
- 8. jQuery的點擊無法正常工作
- 9. 事件點擊無法正常工作
- 10. JavaScript - 點擊jQuery無法正常工作?
- 11. JS - EventListener點擊無法正常工作
- 12. 點擊jquery無法正常工作
- 13. recycleview中的webview無法正常工作
- 14. dblclick無法在Android WebView上工作
- 15. onLongClickListener無法在WebView上工作
- 16. 在WebView中進行雙擊工作
- 17. jQuery的。點擊()事件不會在Android的WebView中工作
- 18. 當點擊替換CSS無法正常工作,快速點擊
- 19. jQuery觸發器點擊無法在IE中工作
- 20. 點擊功能在移動設備中無法正常工作
- 21. UIButton在UIScrollView中無法正常工作/可點擊
- 22. 在模擬器中點擊Textfield無法工作
- 23. Xamarin Webview無法正常工作
- 24. android webview將無法正常工作
- 25. Android 4.1 webview JavaScript無法正常工作。
- 26. WebView上的TapDetectingWindow無法正常工作
- 27. 斷點無法在Xcode 3.2.5中工作
- 28. Android Webview點擊
- 29. Webview不會在圖像上工作點擊
- 30. 部分點擊功能無法在第一次點擊上工作
已經試過這個,沒有工作 –
你正在得到什麼問題? – MageNative
當我點擊鏈接它什麼也沒有,這就是問題 –