2011-06-23 17 views
1

通常のテキストをリンクとして表示し、リンクをクリックすると、「TO」メールアドレスを含むメールページが自動的に表示されます。テキストをクリックして電子メールを送信する方法リンク

しかし、それは私のために働いていません。単語はリンクとして表示されますが、リンクをクリックしている間はメールの意図が表示されません。 Plsは私を助ける。

答えて

0

textViewで電子メールインテントとバインドonClickイベントを開くことができます。

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.setType("plain/text"); 
startActivity(emailIntent); 
-1

私はあなたの条件に応じて変更する必要があり、電子メールを送信するための休閑コードを使用しています。

public class ContactUSActivity extends MenuActivity { 
private HttpURLConnection conn; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.contactus); 

    final EditText nameText = (EditText) findViewById(R.id.contactnametextContectUS); 
    final EditText emailText = (EditText) findViewById(R.id.emailaddresstextContectUS); 
    final EditText commentText = (EditText) findViewById(R.id.commenttextContectUS); 

    Button submitBtn = (Button) findViewById(R.id.ButtonLoginContectUS); 

    submitBtn.setOnClickListener(new OnClickListener() 
    { 
     public void onClick(View v) 
     { 
      if (GUIStatiMethods.connectionCheck(ContactUSActivity.this)) { 
       String name = nameText.getText().toString(); 
       String email = emailText.getText().toString(); 
       String comment = commentText.getText().toString(); 
       Pattern pattern = Pattern.compile("[email protected]+\\.[a-z]+"); 
       Matcher matcher = pattern.matcher(email); 
       boolean matchFound = matcher.matches(); 
       if (name.equalsIgnoreCase("")) { 
        GUIStatiMethods.showMessageDialog(
          ContactUSActivity.this, "Please enter name"); 
       } else if (name.length() > 20) { 
        GUIStatiMethods.showMessageDialog(
          ContactUSActivity.this, 
          "Name should be less then 20 character"); 
       } else if (email.equalsIgnoreCase("")) { 
        GUIStatiMethods.showMessageDialog(
          ContactUSActivity.this, "Please enter email"); 
       } else if (!(matchFound)) { 
        GUIStatiMethods.showMessageDialog(
          ContactUSActivity.this, 
          "Invalid email address."); 
       } else if (comment.equalsIgnoreCase("")) { 
        GUIStatiMethods.showMessageDialog(
          ContactUSActivity.this, "Please enter comment"); 
       } else { 
        try { 
         URL url = new URL(UrlStatics.BASEURL_MAIN_SERVER 
           + "IGA_ADD_CONTACTUS&contactName=" + name 
           + "&email=" + email + "&comments=" 
           + comment); 
         conn = (HttpURLConnection) url.openConnection(); 
         conn.setDoInput(true); 
         conn.setDoOutput(true); 
         conn.setRequestMethod("POST"); 
         conn.setRequestProperty("Connection", "Keep-Alive"); 
         OutputStreamWriter out = new OutputStreamWriter(
           conn.getOutputStream()); 
         out.write("Content-Disposition: post-data;&contactName=" 
           + name 
           + "&email=" 
           + email 
           + "&comments=" 
           + comment); 
         out.close(); 
         BufferedReader rd = new BufferedReader(
           new InputStreamReader(conn.getInputStream())); 
         String decodedString; 
         while ((decodedString = rd.readLine()) != null) { 
          Log.v("TAG", "Contact is Added" + decodedString); 
         } 
         AlertDialog.Builder dialog = new Builder(
           ContactUSActivity.this); 
         dialog.setTitle("Thank You!!"); 
         dialog.setMessage("We will contact you shortly"); 
         dialog.setCancelable(false); 
         dialog.setPositiveButton("Ok", 
           new DialogInterface.OnClickListener() { 
            public void onClick(
              DialogInterface dialog, 
              int which) { 
             nameText.setText(""); 
             emailText.setText(""); 
             commentText.setText(""); 
             finish(); 
            } 
           }); 
         dialog.show(); 
         rd.close(); 

        } catch (MalformedURLException e) { 
         e.printStackTrace(); 
        } catch (ProtocolException e) { 
         e.printStackTrace(); 
        } catch (IOException e) { 
         e.printStackTrace(); 
        } 
       } 
      } 
     } 
    }); 
} 

}

私はそれはあなたに完全なヘルプであると思います。

6

あなたのレイアウトでのTextViewで「オートリンク」プロパティを設定した場合、それが動作し、はるかに簡単になります。

アンドロイド:オートリンクは=「電子メール」

+0

リンクの色を変更するには...これを使用http://stackoverflow.com/questions/6763111/how-to-change-color-of-textview-hyperlink – Swapnil

関連する問題