well, the webview now only shows my pages. thats nice and works fine. right
now I want to correspond to some special links in my <a href>. I'd like to
write an email (with mailto:) and the composer should be opended
automatically. and the same with a telephone number (with tel: I suppose)
and finally I want to open another activity when clicking on a certain link
(like news:). therefor I used intent filters.

the webpage is shown. but every link shows an error page: "Web page not
available..."


 *XML:*

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
     package="android.project.app" android:versionCode="1"
     android:versionName="1.0">

     <uses-permission android:name="android.permission.INTERNET" />

     <application android:icon="@drawable/sz">

          <activity android:name=".NewsActivity" android:label="News">
               <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="news"/>
               </intent-filter>
          </activity>

          <activity android:name=".WebViewActivity" android:label="Internet"
>
               <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name=
"android.intent.category.LAUNCHER" />
               </intent-filter>
          </activity>

     </application>

</manifest>



 *Java:*

package android.project.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebViewActivity extends Activity {

     private WebView webview;

     @Override
     public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);

        setContentView(R.layout.internet);
        webview = (WebView)findViewById(R.id.sz);
        webview.setWebViewClient(new HelloWebViewClient());
        webview.getSettings().setJavaScriptEnabled(true);

        String html =
          "<html>" +
               "<body>" +
                    "mail to <a href='mailto:[email protected]'>Ma Baker</a>" +
                    "<br/>" +
                    "phone to <a href='tel:345345'>345345</a>" +
                    "<br/>" +
                    "news to <a href='news://bg.png'>0231 345345</a>" +
               "</body>" +
          "</html>";

        webview.loadData(html, "text/html", "utf-8");
    }

     private class HelloWebViewClient extends WebViewClient {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url)
{
               view.loadUrl(url);
               return true;
          }
     }
}

greetings,
marco

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to