1

私は活動をしましたここに画像の説明を入力してください

サブスクライブボタンで、コードが次のデフォルトの電子メールに電子メールを送信する必要があります。package sditm.app;

import android.R.string;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class subscribeActivity extends Activity {
/** Called when the activity is first created. */
EditText name,age,address;
databaseforsubscribe addressBook;

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

    Button store = (Button)findViewById(R.id.button1);


    name=(EditText)findViewById(R.id.editText1);
    age=(EditText)findViewById(R.id.editText2);
    address=(EditText)findViewById(R.id.editText3);


    addressBook = new databaseforsubscribe(this,"addressDB",null,2);

    store.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            String s=new String();
            String m=new String();
            String n=new String();
            s=name.getText().toString();
            m=age.getText().toString();
            n=address.getText().toString();
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");

            i.putExtra(Intent.EXTRA_EMAIL, "aman4251@gmail.com");
        //  i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"aman4251@gmail.com"});
            i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
            i.putExtra(Intent.EXTRA_TEXT   ,"NAME: "+s+" ; MOBILE: "+m+" ; EMAIL: "+n);
            try {
                startActivity(Intent.createChooser(i, "Send mail..."));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(subscribeActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
            }
        }
    });
}

}

このような意図を開くここに画像の説明を入力してください

ここで、電子メールIDを「宛先」テキストボックスに設定する(そして編集不可にする)か、ユーザーがこのインテントを表示せずに電子メールがバックグラウンドで送信されるように、その「送信」ボタンを自動的にクリックする必要があります。

4

3 に答える 3

0

このコードを試してください:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
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();
    }
于 2012-05-15T06:08:12.407 に答える
0

こんにちは、このコードを試してください

    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    // Add attributes to the intent
    sendIntent.putExtra(Intent.EXTRA_EMAIL, "");
    sendIntent.putExtra(Intent.EXTRA_CC, "");
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "");
    sendIntent.putExtra(Intent.EXTRA_TEXT, "");
    sendIntent.setType("text/plain");

    PackageManager pm = getPackageManager();
    List<ResolveInfo> activityList = pm
            .queryIntentActivities(sendIntent, 0);
    Iterator<ResolveInfo> it = activityList.iterator();
    boolean isEmailSetUp = false;
    while (it.hasNext()) {
        ResolveInfo info = it.next();
        if ("com.android.email.activity.MessageCompose"
                .equalsIgnoreCase(info.activityInfo.name)) {
            isEmailSetUp = true;
            sendIntent.setClassName(info.activityInfo.packageName,
                    info.activityInfo.name);
        }
    }
    if (isEmailSetUp) {
        startActivity(sendIntent);
    } else {
        AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
        dlgAlert.setMessage("No Mail Accounts");
        dlgAlert.setTitle("Please set up a Mail account in order to send email");
        dlgAlert.setPositiveButton(getResources().getString(R.string.ok),
                null);
        dlgAlert.setCancelable(true);
        dlgAlert.create().show();
    }
于 2012-05-15T06:26:45.963 に答える
0

メールID編集テキストを編集不可にすることが可能かどうかわかりません

ただし、ボタンをクリックするとバックグラウンドでメールを送信できます

そのためには、このリンクを参照してください

于 2012-05-15T06:38:43.977 に答える