0

私はAndroidにかなり慣れていないので、第3部のAPIを使用してメールを送信しようとしています.ほとんどすべてのコーディングを行った後、Android 3.0以降ではメインスレッドでネットワーク操作を実行できないことがわかりました。唯一の方法は、Async.Belowに追加することです.アクティビティをAsyncに拡張した後の私のコードです.しかし、「Voidは変数onCreateの無効なタイプです」というエラーが表示されます.変数onCreateの有効なタイプが何であるかわかりません.誰かが問題を解決できますか?ありがとう

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
//import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class ZZZ extends Activity{
public class done extends AsyncTask<Void, Void, Void>{
    @Override
    protected Void doInBackground(Void... params) {
public void onCreate(Bundle icicle) { 
  super.onCreate(icicle); 
  setContentView(R.layout.activity_main); 

  Button addImage = (Button) findViewById(R.id.send_email); 
  addImage.setOnClickListener(new View.OnClickListener() { 
    public void onClick(View view) { 
      Mail m = new Mail("my@domain.com", "password"); 

      String[] toArr = {"mail1@domain.com", "mail2@domain.com"}; 
      m.setTo(toArr);
      m.setFrom("mymail@gmail.com"); 
      m.setSubject("This is an email sent using my Android device."); 
      m.setBody("Email body."); 

      try { 
        m.addAttachment("/storage/somethinghere"); 

        if(m.send()) { 
          Toast.makeText(ZZZ.this, "Email was sent successfully.", Toast.LENGTH_LONG).show(); 
        } else { 
          Toast.makeText(ZZZ.this, "Email was not sent.", Toast.LENGTH_LONG).show(); 
        }
      } catch(Exception e) { 
        //Toast.makeText(MailApp.this, "There was a problem sending the email.", Toast.LENGTH_LONG).show(); 
        Log.e("MailApp", "Could not send email", e); 
      } 
    } 
  });


}}
}
}
4

1 に答える 1