我正在寫一個應用程序,我正在試圖發送短信給接收者,但每當我點擊發送,得到消息: - 短信展示,請稍後再試!發送短信給接收者
請參考下面的屏幕截圖,就像你看到的,這裏我試圖將消息發送到拉胡爾 ...
的Manifest.xml:
<uses-permission android:name="android.permission.SEND_SMS" />
請檢查以下代碼:
private TextView name;
private ListView list;
private Database db;
private Contact contact;
Button buttonSend;
EditText textSMS;
private Map<String, AuthenticatorDescription> map = new LinkedHashMap<String, AuthenticatorDescription>();
@Override
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 = (Button) findViewById(R.id.buttonSend);
textSMS = (EditText) findViewById(R.id.editTextSMS);
buttonSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String recepient = name.getText().toString();
String sms = textSMS.getText().toString();
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(recepient, 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();
}
}
});
}
所以什麼是你的堆棧跟蹤? – John3136 2013-02-25 05:12:10
@ John3136我無法發送消息給Rahul,並得到消息:SMS faild,請稍後再試! ... – ASMUIRTI 2013-02-25 05:14:32
這是你寫的錯誤信息。不是堆棧跟蹤。 – John3136 2013-02-25 05:16:10