在问这里之前我做了很多搜索。
我无法在我的 Webview 中打开 pdf,出现以下错误:No Activity found to handle Intent 错误。
这是 WebBrowser 活动的代码:
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);
}
这是清单 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 }
请问您有什么解决办法吗?