1

固定されている特定のメールIDにメールを送信する必要があるための連絡フォームを開発しています....助けてください...

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    buttonSend = (Button) findViewById(R.id.buttonSend);
    textTo = (EditText) findViewById(R.id.editTextTo);
    textSubject = (EditText) findViewById(R.id.editTextSubject);
    textMessage = (EditText) findViewById(R.id.editTextMessage);

    buttonSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            String to = textTo.getText().toString();
            String subject = textSubject.getText().toString();
            String message = textMessage.getText().toString();
            Intent email = new Intent(Intent.ACTION_SEND);
            email.putExtra(Intent.EXTRA_EMAIL, new String[]{"abcdk@gmail.com"});          
            email.putExtra(Intent.EXTRA_SUBJECT, "subject");
            email.putExtra(Intent.EXTRA_TEXT, "message");
            email.setType("text/plain");
            startActivity(Intent.createChooser(email, "Choose an Email client :"));


        }
    });

しかし、それは機能していません...

 08-14 09:11:21.559: E/ActivityThread(552): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d4ad38 that was originally bound here
08-14 09:11:21.559: E/ActivityThread(552): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d4ad38 that was originally bound here
08-14 09:11:21.559: E/ActivityThread(552):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
08-14 09:11:21.559: E/ActivityThread(552):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
08-14 09:11:21.559: E/ActivityThread(552):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
08-14 09:11:21.559: E/ActivityThread(552):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
08-14 09:11:21.559: E/ActivityThread(552):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
08-14 09:11:21.559: E/ActivityThread(552):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
08-14 09:11:21.559: E/ActivityThread(552):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
08-14 09:11:21.559: E/ActivityThread(552):  at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
08-14 09:11:21.559: E/ActivityThread(552):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
08-14 09:11:21.559: E/ActivityThread(552):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
08-14 09:11:21.559: E/ActivityThread(552):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
08-14 09:11:21.559: E/ActivityThread(552):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
08-14 09:11:21.559: E/ActivityThread(552):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
08-14 09:11:21.559: E/ActivityThread(552):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
08-14 09:11:21.559: E/ActivityThread(552):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
08-14 09:11:21.559: E/ActivityThread(552):  at java.lang.Thread.run(Thread.java:856)
08-14 09:11:21.620: E/StrictMode(552): null
08-14 09:11:21.620: E/StrictMode(552): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d4ad38 that was originally bound here
08-14 09:11:21.620: E/StrictMode(552):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
08-14 09:11:21.620: E/StrictMode(552):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
08-14 09:11:21.620: E/StrictMode(552):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
08-14 09:11:21.620: E/StrictMode(552):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
08-14 09:11:21.620: E/StrictMode(552):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
08-14 09:11:21.620: E/StrictMode(552):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
08-14 09:11:21.620: E/StrictMode(552):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
08-14 09:11:21.620: E/StrictMode(552):  at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
08-14 09:11:21.620: E/StrictMode(552):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
08-14 09:11:21.620: E/StrictMode(552):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
08-14 09:11:21.620: E/StrictMode(552):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
08-14 09:11:21.620: E/StrictMode(552):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
08-14 09:11:21.620: E/StrictMode(552):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
08-14 09:11:21.620: E/StrictMode(552):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
08-14 09:11:21.620: E/StrictMode(552):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
08-14 09:11:21.620: E/StrictMode(552):  at java.lang.Thread.run(Thread.java:856)
4

4 に答える 4

0

送信済みメールの場合、次のコードを使用します。

final Intent emailIntent = new Intent(
                    android.content.Intent.ACTION_SEND);
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                    new String[] { vendoremail });
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                    _productList.get(0).ProductName);

            startActivity(Intent.createChooser(emailIntent, "Send mail..."));

ここ..

vendoremail= メール ID、
_productList.get(0).ProductName= メールの説明

編集 :

ファイルに許可を与える必要がありAndroidManifest.xmlます。

 <uses-permission android:name="android.permission.INTERNET" />
于 2013-08-14T09:10:58.753 に答える
0

これを試して

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent .setType("text/plain");
emailIntent .putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipientemail@example.com"});
emailIntent .putExtra(Intent.EXTRA_SUBJECT, "subject");
emailIntent .putExtra(Intent.EXTRA_TEXT   , "body");
startActivity(Intent.createChooser(emailIntent , "Email:"));
于 2013-08-14T09:41:52.877 に答える
0

setType() を変更する

この行を使用してください

email.setType("message/rfc822");

それ以外の

email.setType("text/plain");
于 2013-08-14T09:21:06.727 に答える
0

最良の (そして最も簡単な) 方法は、Intent を使用することです。

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

それ以外の場合は、独自のクライアントを作成する必要があります。

于 2013-08-14T09:14:00.417 に答える