2011-12-29 3 views
2

Action_Send를 사용하여 전자 메일을 보내기위한 작은 응용 프로그램을 작성했습니다. 보내기 버튼을 눌러 활동을 시작하면 Gmail 또는 Hotmail 앱 (hotmail + SEVEN)을 사용하여 이메일을 보낼 수있는 옵션이 표시됩니다. Gmail을 선택하면 활동이 강제 종료됩니다. Hotmail을 선택하면 사용자가 입력 한 이메일 주소가 NULL로 표시됩니다.전자 메일 gmail을 사용하여 전자 메일 주소가 충돌하고 hotmail에서 NULL로 표시됩니다.

아래 코드를 게시했습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 이 라인에서

package android.development.tutorial; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.EditText; 

public class EmailActivity extends Activity implements View.OnClickListener 
{ 
    String  receipantAddress,  subject, message; 
    EditText edtReceipantAddress, edtSubject, edtMessage; 
    Button  btnSend; 

    protected void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     this.setContentView(R.layout.email); 

     initUIComponents(); 
    } 

    private void initUIComponents() 
    { 
     this.edtReceipantAddress= (EditText) findViewById(R.id.edtReceipantAddress); 
     this.edtSubject   = (EditText) findViewById(R.id.edtSubject); 
     this.edtMessage   = (EditText) findViewById(R.id.edtMessage); 

     this.btnSend   = (Button) findViewById(R.id.btnSend); 
     btnSend.setOnClickListener(this); 
    } 

    private void setEmailParameters() 
    { 
     this.receipantAddress = this.edtReceipantAddress.getText().toString(); 
     this.subject   = this.edtSubject.getText().toString(); 
     this.message   = this.edtMessage.getText().toString(); 
    } 

    public void onClick(View v) 
    { 
     String emailAddresses []= {this.receipantAddress}; 
     setEmailParameters(); 

     Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
     emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,emailAddresses); 
     emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, this.subject); 
     emailIntent.setType("plain/text"); 
     emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, this.message); 
     this.startActivity(emailIntent); 
    } 

    protected void onPause() 
    { 
     super.onPause(); 
     EmailActivity.this.finish(); 
    } 

} 

답변

2

그냥 바보 같은 실수 : 당신이 setEmailParameters 내부 파라미터 설정을하고 있기 때문에이 아래와 같이해야

String emailAddresses []= {this.receipantAddress}; 
setEmailParameters(); 

().

setEmailParameters(); 
String emailAddresses []= {this.receipantAddress}; 
+1

+1 - 눈의 두 번째 세트가 항상 도움이됩니다. 그래서 쌍 프로그래밍을 좋아합니다. –

+0

@MatNadrofsky Thanx :) –

+0

당신은 하루를 보냈습니다. 완전히 간과 : :) –

관련 문제