本文整理汇总了Java中android.telephony.SmsManager.RESULT_ERROR_NO_SERVICE属性的典型用法代码示例。如果您正苦于以下问题:Java SmsManager.RESULT_ERROR_NO_SERVICE属性的具体用法?Java SmsManager.RESULT_ERROR_NO_SERVICE怎么用?Java SmsManager.RESULT_ERROR_NO_SERVICE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.telephony.SmsManager
的用法示例。
在下文中一共展示了SmsManager.RESULT_ERROR_NO_SERVICE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleSentResult
private void handleSentResult(MasterSecret masterSecret, long messageId, int result) {
try {
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
SmsMessageRecord record = database.getMessage(masterSecret, messageId);
switch (result) {
case Activity.RESULT_OK:
database.markAsSent(messageId, false);
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
case SmsManager.RESULT_ERROR_RADIO_OFF:
Log.w(TAG, "Service connectivity problem, requeuing...");
ApplicationContext.getInstance(context)
.getJobManager()
.add(new SmsSendJob(context, messageId, record.getIndividualRecipient().getNumber()));
break;
default:
database.markAsSentFailed(messageId);
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
}
} catch (NoSuchMessageException e) {
Log.w(TAG, e);
}
}
示例2: onReceive
@Override
public void onReceive(Context context, Intent intent) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS enviado", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Falha geral", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "Sem serviço", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off", Toast.LENGTH_SHORT).show();
break;
}
unregisterReceiver(this);
}
示例3: handleSentMessage
/**
* Callback method to handle the result of attempting to send a message.
* Each message is assigned a Broadcast receiver that is notified by
* the phone's radio regarding the status of the sent message. The
* receivers call this method. (See transmitMessage() method below.)
*
* @param context
* The context in which the calling BroadcastReceiver is running.
* @param receiver
* Currently unused. Intended as a special BroadcastReceiver to
* send results to. (For instance, if another plugin wanted to do
* its own handling.)
* @param resultCode, the code sent back by the phone's Radio
* @param seq, the message's sequence number
* @param smsMsg, the message being processed
*/
private synchronized void handleSentMessage(Context context,
BroadcastReceiver receiver, int resultCode, String smsMsg) {
switch (resultCode) {
case Activity.RESULT_OK:
Log.i(TAG, "Received OK, msg:" + smsMsg);
Toast.makeText(activity, "Message sent", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Log.e(TAG, "Received generic failure, msg:" + smsMsg);
Toast.makeText(activity, "Generic failure: message not sent", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Log.e(TAG, "Received no service error, msg:" + smsMsg);
Toast.makeText(activity, "No Sms service available. Message not sent.", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Log.e(TAG, "Received null PDU error, msg:" + smsMsg);
Toast.makeText(activity, "Received null PDU error. Message not sent.", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Log.e(TAG, "Received radio off error, msg:" + smsMsg);
Toast.makeText(activity, "Could not send SMS message: radio off.", Toast.LENGTH_LONG).show();
break;
}
}
示例4: onReceive
@Override
public void onReceive(Context context, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(context, "SMS Sent", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(context, "Generic failure",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(context, "No service",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(context, "Null PDU", Toast.LENGTH_SHORT)
.show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(context, "No network",
Toast.LENGTH_SHORT).show();
break;
}
}
示例5: onReceive
@Override
public void onReceive(Context context, Intent intent) {
switch (getResultCode()) {
case Activity.RESULT_OK:
msgReceivedOk(intent);
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
msgNotSent(intent, "Generic Error.");
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
msgNotSent(intent, "Error: No Service.");
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
msgNotSent(intent, "Error: Null PDU.");
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
msgNotSent(intent, "Error: Radio off.");
break;
}
}
示例6: getSMSSentReceiver
public static BroadcastReceiver getSMSSentReceiver() {
// For when the SMS has been sent
return new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(context, R.string.sms_sent, Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(context, R.string.sms_generic_failure, Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(context, R.string.sms_no_service, Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(context, R.string.sms_no_pdu, Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(context, R.string.sms_radio_turned_off, Toast.LENGTH_SHORT).show();
break;
}
}
};
}
示例7: onReceive
@Override
public void onReceive(Context context, Intent arg1) {
setSendRecFired(send_receiver_fired + 1);
switch (getResultCode()) {
case Activity.RESULT_OK:
setResSend(context.getString(R.string.info_sms_sent));
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
setResSend(context.getString(R.string.info_sms_generic));
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
setResSend(context.getString(R.string.info_sms_noservice));
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
setResSend(context.getString(R.string.info_sms_nullpdu));
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
setResSend(context.getString(R.string.info_sms_radioof));
break;
}
}
示例8: translateResultCode
private static String translateResultCode(int resultCode) {
switch (resultCode) {
case Activity.RESULT_OK:
return "Activity.RESULT_OK";
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
return "SmsManager.RESULT_ERROR_GENERIC_FAILURE";
case SmsManager.RESULT_ERROR_RADIO_OFF:
return "SmsManager.RESULT_ERROR_RADIO_OFF";
case SmsManager.RESULT_ERROR_NULL_PDU:
return "SmsManager.RESULT_ERROR_NULL_PDU";
case SmsManager.RESULT_ERROR_NO_SERVICE:
return "SmsManager.RESULT_ERROR_NO_SERVICE";
case SmsManager.RESULT_ERROR_LIMIT_EXCEEDED:
return "SmsManager.RESULT_ERROR_LIMIT_EXCEEDED";
case SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE:
return "SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE";
default:
return "Unknown error code";
}
}
示例9: smsResultToChar
private static char smsResultToChar(int res) {
switch (res) {
case Activity.RESULT_OK:
return RESULT_NO_ERROR_CHAR;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
return RESULT_ERROR_GENERIC_FAILURE_CHAR;
case SmsManager.RESULT_ERROR_NO_SERVICE:
return RESULT_ERROR_NO_SERVICE_CHAR;
case SmsManager.RESULT_ERROR_NULL_PDU:
return RESULT_ERROR_NULL_PDU_CHAR;
case SmsManager.RESULT_ERROR_RADIO_OFF:
return RESULT_ERROR_RADIO_OFF_CHAR;
default:
throw new IllegalStateException("unknown res=" + res);
}
}
示例10: onReceive
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (SMS_SENT_ACTION.equals(action)) {
SnippetEvent event = new SnippetEvent(mCallbackId, SMS_SENT_EVENT_NAME);
switch (getResultCode()) {
case Activity.RESULT_OK:
if (mExpectedMessageCount == 1) {
event.getData().putBoolean("sent", true);
mEventCache.postEvent(event);
mContext.unregisterReceiver(this);
}
if (mExpectedMessageCount > 0) {
mExpectedMessageCount--;
}
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
case SmsManager.RESULT_ERROR_NO_SERVICE:
case SmsManager.RESULT_ERROR_NULL_PDU:
case SmsManager.RESULT_ERROR_RADIO_OFF:
event.getData().putBoolean("sent", false);
event.getData().putInt("error_code", getResultCode());
mEventCache.postEvent(event);
mContext.unregisterReceiver(this);
break;
default:
event.getData().putBoolean("sent", false);
event.getData().putInt("error_code", -1 /* Unknown */);
mEventCache.postEvent(event);
mContext.unregisterReceiver(this);
break;
}
}
}
示例11: onReceive
@Override
public void onReceive(Context context, Intent intent) {
switch (getResultCode()){
case Activity.RESULT_OK:
Toast.makeText(context, context.getResources().getString(R.string.SMS_sent),
Toast.LENGTH_SHORT).show();
Log.d(TAG, "SmsSentBroadcastReceiver: SMS has been sent");
String phoneNumber = intent.getStringExtra(PHONE_NUMBER_EXTRA);
String verificationCode = intent.getStringExtra(VERIFICATION_CODE_EXTRA);
Log.d(TAG, "phoneNumber from intent: " + phoneNumber);
Log.d(TAG, "verification code from intent: " + verificationCode);
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(context, context.getResources().getString(R.string.generic_failure),
Toast.LENGTH_SHORT).show();
Log.d(TAG, "SMS has not been sent, there was a generic failure");
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(context, context.getResources().getString(R.string.no_service),
Toast.LENGTH_SHORT).show();
Log.d(TAG, "SMS has not been sent, there is no service");
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(context, context.getResources().getString(R.string.null_pdu),
Toast.LENGTH_SHORT).show();
Log.d(TAG, "SMS has not been sent, there is no PDU");
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(context, context.getResources().getString(R.string.radio_off),
Toast.LENGTH_SHORT).show();
Log.d(TAG, "SMS has not been sent, radio is off");
break;
}
}
示例12: lastSentSmsStatus
public HashMap<String, String> lastSentSmsStatus(){
HashMap<String,String> ret = new HashMap<String,String>();
switch (lastSentSMSStatus) {
case Activity.RESULT_OK:
ret.put("STATUS","SENT");
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
ret.put("STATUS","ERROR");
ret.put("DESCRIPTION","GENERIC");
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
ret.put("STATUS","ERROR");
ret.put("DESCRIPTION","NO SERVICE");
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
ret.put("STATUS","ERROR");
ret.put("DESCRIPTION","NULL PDU");
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
ret.put("STATUS","ERROR");
ret.put("DESCRIPTION","RADIO OFF");
break;
default:
ret.put("STATUS","UNKNOWN");
break;
}
return ret;
}
示例13: handleSentResult
private void handleSentResult(MasterSecret masterSecret, long messageId, int result) {
try {
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
SmsMessageRecord record = database.getMessage(masterSecret, messageId);
switch (result) {
case Activity.RESULT_OK:
database.markAsSent(messageId);
if (record != null && record.isEndSession()) {
Log.w(TAG, "Ending session...");
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
sessionStore.deleteAllSessions(record.getIndividualRecipient().getRecipientId());
SecurityEvent.broadcastSecurityUpdateEvent(context, record.getThreadId());
}
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
case SmsManager.RESULT_ERROR_RADIO_OFF:
Log.w(TAG, "Service connectivity problem, requeuing...");
ApplicationContext.getInstance(context)
.getJobManager()
.add(new SmsSendJob(context, messageId, record.getIndividualRecipient().getNumber()));
break;
default:
database.markAsSentFailed(messageId);
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
}
} catch (NoSuchMessageException e) {
Log.w(TAG, e);
}
}
示例14: handleSentResult
private void handleSentResult(MasterSecret masterSecret, long messageId, int result) {
try {
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
SmsMessageRecord record = database.getMessage(masterSecret, messageId);
switch (result) {
case Activity.RESULT_OK:
database.markAsSent(messageId);
if (record != null && record.isEndSession()) {
Log.w(TAG, "Ending session...");
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
sessionStore.deleteAllSessions(record.getIndividualRecipient().getNumber());
SecurityEvent.broadcastSecurityUpdateEvent(context, record.getThreadId());
}
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
case SmsManager.RESULT_ERROR_RADIO_OFF:
Log.w(TAG, "Service connectivity problem, requeuing...");
ApplicationContext.getInstance(context)
.getJobManager()
.add(new SmsSendJob(context, messageId, record.getIndividualRecipient().getNumber()));
break;
default:
database.markAsSentFailed(messageId);
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
}
} catch (NoSuchMessageException e) {
Log.w(TAG, e);
}
}
示例15: handleSentResult
private void handleSentResult(MasterSecret masterSecret, long messageId, int result) {
try {
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
SmsMessageRecord record = database.getMessage(masterSecret, messageId);
switch (result) {
case Activity.RESULT_OK:
database.markAsSent(messageId, record.isSecure());
if (record != null && record.isEndSession()) {
Log.w(TAG, "Ending session...");
SessionStore sessionStore = new SilenceSessionStore(context, masterSecret);
sessionStore.deleteAllSessions(record.getIndividualRecipient().getNumber());
SecurityEvent.broadcastSecurityUpdateEvent(context, record.getThreadId());
}
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
case SmsManager.RESULT_ERROR_RADIO_OFF:
Log.w(TAG, "Service connectivity problem, requeuing...");
ApplicationContext.getInstance(context)
.getJobManager()
.add(new SmsSendJob(context, messageId, record.getIndividualRecipient().getNumber()));
break;
default:
database.markAsSentFailed(messageId);
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
}
} catch (NoSuchMessageException e) {
Log.w(TAG, e);
}
}