在这里提问之前我做了很多搜索。
我无法在 Web View 中打开 pdf,出现以下错误:未找到可处理 Intent 错误的 Activity 。
这是 WebBrowser Activity 的代码:
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setProgress(progress * 100);
}
});
webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.endsWith("pdf")) {
Intent intentUrl = new Intent(android.content.Intent.ACTION_VIEW);
intentUrl.setDataAndType(Uri.parse(url),MIME_TYPE_PDF);
startActivity(intentUrl);
}
else{
view.loadUrl(url);
}
return true;
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//Users will be notified in case there's an error (i.e. no internet connection)
Toast.makeText(activity, "Oops! Connexion inexistante ou " + description, Toast.LENGTH_SHORT).show();
}
});
//This will load the webpage that we want to see
webview.setPictureListener(this);
webview.loadUrl(WebAddress);
}
这是 list xml:
<application android:icon="@drawable/icon" android:label="@string/VisitEnsta">
<activity android:name=".SplashScreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".main"
android:configChanges="locale"></activity>
<activity android:name=".Apropos"></activity>
<activity android:name=".Resultat"
android:configChanges="locale"></activity>
<activity android:name=".SyntheseVocale"
android:configChanges="locale"></activity>
<activity android:name=".Visite"
android:configChanges="locale"></activity>
<activity android:name=".RssActivity" android:theme="@style/ListTheme"></activity>
<activity android:name=".WebBrowser">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<activity android:name=".Utilities">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<activity android:name=".StudentsAccess">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA"/>
</manifest>
我的手机上安装了 adobe reader,并在真实设备 (Galaxy S) 上进行调试。
她是错误跟踪:
06-12 20:13:10.312: E/AndroidRuntime(3311): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://www.ensta-bretagne.fr/images/contenu//EspaceDocumentation/depliant_institutionnelle_fr_novembre2011_web.pdf typ=application/pdf }
请问您有什么解决办法吗?
最佳答案
这是我用来在 webview 中查看 pdf 文件的代码。 请检查一下 。
WebView webview=new WebView(SpecialityAllManuals.this);
webview.getSettings().setJavaScriptEnabled(true);
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdf);
关于android - 无法在 Webview 中打开 pdf,未找到处理 Intent 错误的 Activity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11003045/