SolidSnake87
SolidSnake87

Reputation: 343

Can't open pdf in Webview , No Activity found to handle Intent error

I made a lot of searching before asking here.

I cant open a pdf in my Webview , i had the following error : No Activity found to handle Intent error.

Here is the code of the 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);  
}

Here is the manifest 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> 

I have adobe reader installed on my phone, and i debug on a real device (Galaxy S).

Her is the error trace :

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 }

Please have you any solution ?

Upvotes: 2

Views: 4099

Answers (2)

itsrajesh4uguys
itsrajesh4uguys

Reputation: 4638

Here is the code which i have used to view the pdf file in webview. Please check it .

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);

Upvotes: 2

JWL
JWL

Reputation: 14221

Use Adobe Reader (or another installed pdf viewer) via an intent. See this solution on SO here

Upvotes: 0

Related Questions