저는 수신자에게 SMS를 보내려고하는 앱을 작성하고 있지만, 보내기를 클릭 할 때마다 메시지를 받고 있습니다 : - SMS 실패, 나중에 다시 시도하십시오! 당신은 스크린 샷 아래에서 볼 수있는 것처럼 어느 내가 에뮬레이터 또는 안드로이드 장치를 사용하고안드로이드 장치를 통해 SMS를 보냈습니다.
....
, 여기에 내가 내 전화 번호부 연락처에 저장됩니다 Pratik에 메시지를 보내려고하고 있어요,하지만 때마다 나는 당신이 볼 수있는 것처럼 Pratik
에 메시지를 보낼 수 Pratik에 메시지에 노력하고 할 수없는 ... 여기 내가 라훌 메시지를 보내려고하고, 스크린 샷 아래
Manifest.xml를 참조하십시오
<uses-permission android:name="android.permission.SEND_SMS" />
,210
코드 아래에 확인하시기 바랍니다 :
private TextView name;
private ListView list;
private Database db;
private Contact contact;
ImageButton buttonSend;
EditText textSMS;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.editor);
// bind GUI components
this.name = (TextView) findViewById(R.id.editor_name);
this.list = (ListView) findViewById(R.id.editor_list);
// check if contact id is valid
this.db = new Database(getContentResolver());
int contactId = getIntent().getIntExtra(CONTACT_ID, NO_CONTACT_ID);
this.contact = this.db.getContact(contactId);
if (this.contact == null) {
finish();
}
this.name.setText(this.contact.getName());
// pre-load information about all account types
AuthenticatorDescription[] authTypes = AccountManager.get(this).getAuthenticatorTypes();
for (AuthenticatorDescription authDesc : authTypes) {
this.map.put(authDesc.type, authDesc);
}
// bind list events
this.list.setOnItemClickListener(this);
this.list.setOnCreateContextMenuListener(this);
// create the GUI
updateView();
saveGreeting = (ImageButton) findViewById(R.id.greeting);
saveGreeting.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
customGreeting(v);
}
});
buttonSend = (ImageButton) findViewById(R.id.buttonSend);
textSMS = (EditText) findViewById(R.id.editTextSMS);
buttonSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String sms = textSMS.getText().toString();
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(CONTACT_ID, null, sms, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
}
'recepient = name.getText()'어떻게 작동합니까? – njzk2