當前位置: 首頁>>代碼示例>>Java>>正文


Java SmsManager.RESULT_ERROR_NO_SERVICE屬性代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:24,代碼來源:SmsSentJob.java

示例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);
}
 
開發者ID:if710,項目名稱:2017.2-codigo,代碼行數:22,代碼來源:SmsSendDirectActivity.java

示例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;
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:41,代碼來源:Texting.java

示例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;
    }

}
 
開發者ID:webianks,項目名稱:HatkeMessenger,代碼行數:25,代碼來源:SentReceiver.java

示例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;			
	}
}
 
開發者ID:roadlabs,項目名稱:alternate-java-bridge-library,代碼行數:20,代碼來源:Texting.java

示例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;
            }
        }
    };
}
 
開發者ID:CesarValiente,項目名稱:PermissionsSample,代碼行數:25,代碼來源:SMSReceiver.java

示例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;
    }
}
 
開發者ID:tral,項目名稱:GPS2SMS,代碼行數:23,代碼來源:ThreadSendSMS.java

示例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";
    }
}
 
開發者ID:CommonQ,項目名稱:sms_DualCard,代碼行數:20,代碼來源:SmsReceiverService.java

示例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);
	}
}
 
開發者ID:ProjectMAXS,項目名稱:maxs,代碼行數:16,代碼來源:SMSPendingIntentReceiver.java

示例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;
        }
    }
}
 
開發者ID:google,項目名稱:mobly-bundled-snippets,代碼行數:36,代碼來源:SmsSnippet.java

示例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;
    }
}
 
開發者ID:VictorGil,項目名稱:phoneVerifier,代碼行數:38,代碼來源:SmsSentBroadcastReceiver.java

示例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;
}
 
開發者ID:strang3quark,項目名稱:remotedroid,代碼行數:28,代碼來源:SMSUtils.java

示例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);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:33,代碼來源:SmsSentJob.java

示例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);
  }
}
 
開發者ID:Agilitum,項目名稱:TextSecureSMP,代碼行數:33,代碼來源:SmsSentJob.java

示例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);
  }
}
 
開發者ID:SilenceIM,項目名稱:Silence,代碼行數:33,代碼來源:SmsSentJob.java


注:本文中的android.telephony.SmsManager.RESULT_ERROR_NO_SERVICE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。