पर कई लोगों को प्रोग्रामेटिक रूप से एसएमएस भेजना मैं वर्तमान में एक एसएमएस एप्लिकेशन विकसित करने की कोशिश कर रहा हूं और उपयोगकर्ता को कई लोगों को एसएमएस भेजने की अनुमति देता हूं।जेनेरिक त्रुटि
एसएमएस जब तक मैं sendMultipartTextMessage जो नीचे
private void sendSMS(final String phoneNumber, String message) {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";
SmsManager sms = SmsManager.getDefault();
ArrayList<String> parts = sms.divideMessage(message);
int messageCount = parts.size();
Log.i("Message Count", "Message Count: " + messageCount);
ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
for (int j = 0; j < messageCount; j++) {
sentIntents.add(sentPI);
deliveryIntents.add(deliveredPI);
}
// ---when the SMS has been sent---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service",
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;
}
}
}, new IntentFilter(SENT));
// ---when the SMS has been delivered---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS delivered",
Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS not delivered",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(DELIVERED));
sms.sendMultipartTextMessage(phoneNumber, null, parts, sentIntents, deliveryIntents);
}
है जब मैं इस तरह एक पाश में एक से अधिक लोगों को भेजने के लिए प्रयास मैं एक सामान्य त्रुटि का सामना करना होगा उपयोग करने के लिए है और संदेश जीता ' टी भेजा जाएगा। मुझे संदेह है कि यह संदेश इसलिए है क्योंकि संदेश शायद 3-4 भागों है और एंड्रॉइड सिस्टम 3000 मिलीसेकंड देरी के साथ भी समय में संदेश नहीं भेज सकता है।
for (int t = 0; t < array.length; t++) {
System.out.println("temp: " + array[t].toString());
try {
sendSMS(array[t].toString(), message);
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
संपादित करें: उपर्युक्त कोड एक AsyncTask में है जो किसी सेवा के अंदर निष्पादित किया जाता है।
अपना लॉककैट दिखाएं –
कोई लॉगकट त्रुटि नहीं है, यह केवल 'SmsManager.RESULT_ERROR_GENERIC_FAILURE' के लिए टोस्ट दिखाएगी, जेनेरिक त्रुटि दो बार जब मैं इसे 2 संपर्कों में भेजने की कोशिश करता हूं। – dythe
आपको यह त्रुटि एमुलेटर या डिवाइस में मिली है? –