mailto link Eclipse

  • Antworten:2
  • Bentwortet
Jan J.
  • Forum-Beiträge: 18

08.04.2013, 18:13:16 via Website

Hallo Community,

ich habe leider ein Problem mit den "mailto" links meiner website. Ich möchte diese, wenn sie in meinem webview angeklickt werden, über ein mail App erreichen, dies klappt leider nicht. Ich habe nun schon viel rum probiert und gegoogelt, aber keine der Lösungen hat mir geholfen.
Hier mal meine Projektdateien, vlt finfdet ja einer von euch meinen fehler und kann mir helfen, ich wäre seht dankbar.

mfg Jan



Manifest Datei:

1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.example.TEST"
4 android:versionCode="1"
5 android:versionName="1.5" android:installLocation="auto">
6
7 <uses-permission android:name="android.permission.INTERNET" />
8 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
9 <uses-permission android:name="android.permission.ACCESS_GPS" />
10 <uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
11 <uses-permission android:name="android.permission.ACCESS_LOCATION" />
12 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
13
14 <uses-sdk
15 android:minSdkVersion="8"
16 android:targetSdkVersion="17" />
17
18 <application
19 android:allowBackup="true"
20 android:icon="@drawable/ic_launcher"
21 android:label="@string/app_name"
22 android:theme="@style/AppTheme" >
23 <activity
24 android:name="com.example.lauffinderpro.MainActivity"
25 android:label="@string/app_name" >
26 <intent-filter>
27 <action android:name="android.intent.action.MAIN" />
28
29 <category android:name="android.intent.category.LAUNCHER" />
30 </intent-filter>
31 </activity>
32 </application>
33
34</manifest>

Main.xml:

1<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 xmlns:tools="http://schemas.android.com/tools"
3 android:id="@+id/FrameLayout1"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 android:paddingBottom="@dimen/vertical"
7 android:paddingLeft="@dimen/horizontal"
8 android:paddingRight="@dimen/horizontal"
9 android:paddingTop="@dimen/vertical"
10 tools:context=".MainActivity" >
11
12 <LinearLayout
13 android:layout_width="match_parent"
14 android:layout_height="match_parent"
15 android:orientation="vertical" >
16
17 <WebView
18 android:id="@+id/webView1"
19 android:layout_width="match_parent"
20 android:layout_height="0dp"
21 android:layout_weight="0.05" />
22
23 <FrameLayout
24 android:layout_width="match_parent"
25 android:layout_height="wrap_content"
26 android:layout_weight="0.00" >
27
28 <LinearLayout
29 android:layout_width="match_parent"
30 android:layout_height="wrap_content"
31 android:baselineAligned="true" >
32
33
34 <Button
35 android:id="@+id/button1"
36 android:layout_width="0dp"
37 android:layout_weight="2"
38 android:layout_height="match_parent"
39 android:background="@drawable/upgradetest"
40 android:onClick="button1click" />
41
42 <Button
43 android:id="@+id/button2"
44 style="?android:attr/buttonStyleSmall"
45 android:layout_width="0dp"
46 android:layout_weight="2"
47 android:layout_height="match_parent"
48 android:background="@drawable/globaltest"
49 android:onClick="button2click" />
50
51 <Button
52 android:id="@+id/button3"
53 style="?android:attr/buttonStyleSmall"
54 android:layout_width="0dp"
55 android:layout_weight="2"
56 android:layout_height="match_parent"
57 android:background="@drawable/datetest"
58 android:onClick="button3click" />
59
60 <Button
61 android:id="@+id/button5"
62 style="?android:attr/buttonStyleSmall"
63 android:layout_width="0dp"
64 android:layout_weight="2"
65 android:layout_height="match_parent"
66 android:layout_gravity="right"
67 android:background="@drawable/mehrtest"
68 android:onClick="button5click" />
69 </LinearLayout>
70
71 </FrameLayout>
72
73 </LinearLayout>
74
75</FrameLayout>

Main.java:

1package com.example.lauffinderpro;
2
3import java.net.URISyntaxException;
4
5import android.net.MailTo;
6import android.net.Uri;
7import android.os.Bundle;
8import android.annotation.SuppressLint;
9import android.app.Activity;
10import android.app.AlertDialog;
11import android.content.Context;
12import android.content.DialogInterface;
13import android.content.Intent;
14import android.util.Log;
15import android.view.KeyEvent;
16import android.view.Menu;
17import android.view.View;
18import android.view.View.OnClickListener;
19import android.webkit.GeolocationPermissions;
20import android.webkit.WebChromeClient;
21import android.webkit.WebView;
22import android.webkit.WebViewClient;
23import android.widget.Button;
24import android.widget.ImageButton;
25
26public class MainActivity extends Activity {
27
28
29 protected void onCreate(Bundle savedInstanceState) {
30 super.onCreate(savedInstanceState);
31 setContentView(R.layout.activity_main);
32
33
34 //startet Upgrade als Standard
35
36 @SuppressLint("SetJavaScriptEnabled")
37
38
39 WebView myWebView = (WebView) findViewById (R.id.webView1);
40 myWebView.getSettings().setJavaScriptEnabled(true);
41 myWebView.loadUrl("WEBSITE");
42 myWebView.setWebViewClient(new WebViewClient());
43
44
45 }
46
47
48
49 /*public boolean onCreateOptionsMenu(Menu menu) {
50 // Inflate the menu; this adds items to the action bar if it is present.
51 getMenuInflater().inflate(R.menu.main, menu);
52 return true;
53 }
54 */
55
56
57 public boolean shouldOverrideUrlLoading(WebView view, String url) {
58 if (url.startsWith("mailto:")) {
59 Intent intent = new Intent(Intent.ACTION_VIEW,
60 Uri.parse(url));
61 startActivity(intent);
62 }else if(url.startsWith("http:") || url.startsWith("https:")) {
63 view.loadUrl(url);
64 }
65 return true;
66 }
67
68
69 public void button1click (View view) {
70
71 Code
72
73 }
74
75
76 public void button2click (View view) {
77
78 Code
79
80 }
81
82
83
84 public void button3click (View view) {
85
86 Code
87
88 }
89
90
91
92 public void button5click (View view) {
93
94 Code
95
96 }
97
98
99
100}

Antworten
impjor
  • Forum-Beiträge: 1.793

09.04.2013, 14:07:59 via App

Ich weiß nicht, ob ein normaler mailto -Link nicht reicht (ohne die URL zu kontrollieren), denke aber, dass hasst du schon ausprobiert.
Versuche mal folgendes:
Ließ aus dem mailto-Link Sachen wie Empfänger und Co. über RegularExpression aus, dann erstelle einen neuen Intent, wie hier beschrieben:
http://www.androidsnippets.com/start-email-activity-with-preset-data-via-intents

Gruß

Liebe Grüße impjor.

Für ein gutes Miteinander: Unsere Regeln
Apps für jeden Einsatzzweck
Stellt eure App vor!

Antworten
Jan J.
  • Forum-Beiträge: 18

09.04.2013, 19:20:36 via Website

Hey, vielen Dank für die Antwort.
Ich habe es mir mal angeguckt und die Erstellung des Intents verstehe ich auch, aber das anwenden der RegularExpression ist für mich vollkommen unverständlich. Hab dies vorher noch nie benutzt und mir ein paar Sachen durchgelesen, auch Beispiel Skripte, aber leider verstehe ich nur Bahnhof =/

Könntest du mir evtl. versuchen es zu erklären oder gibt es vlt. noche ien andere Möglichkeit?

LG

Antworten