Autore Topic: Re-invio SMS  (Letto 1125 volte)

Offline teo_

  • Utente junior
  • **
  • Post: 72
  • Respect: +1
    • Github
    • Mostra profilo
  • Dispositivo Android:
    Nexus 4
  • Sistema operativo:
    Windows 7 - Ubuntu 12.10
Re-invio SMS
« il: 11 Settembre 2011, 00:54:39 CEST »
0
salve a tutti, sono sempre io che sto sviluppando la mia app di messaggistica, ho un problema nel momento in cui cerco di re-inviare un messaggio dopo il fallimento di quest'ultimo (ad esempio quando mando un messaggio in modalità offline, o sono senza rete sul telefono vorrei che riprovasse a rimandare il messaggio per un tot di volte), sono riuscito a fare rimandare il messaggio fino a che non riesce ad avere un risultato positivo (fino a che non riceve RESULT_OK), ma dopo un po' di tempo il sistema crasha e mi fa un force close per poi tornare all'activity precedente, riporto qui il codice con il quale mando un messaggio e se non ricevo un risultato positivo cerco di rimandarlo dopo 5 secondi:
Codice (Java): [Seleziona]
private void sendSMS (String phoneNumber,String message)
        {
                String SENT="SMS_SENT";
                String DELIVERED="SMS_DELIVERED";
               
               
                final PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
                final PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
               
               
                smsSender = new BroadcastReceiver() {
                        @Override
                        public void onReceive(Context arg0, Intent arg1) {
                                Cursor cur = getContentResolver().query(Uri.parse("content://sms"), null, null, null,null);
                                long id=0;
                                Timer timer = new Timer();
                        long startUp = 5000;     // millisecondi di attesa per fare partire il timer
                        long periodo = 5000;     // millisecondi di attesa per la ripetizione del timer
                       
                                switch(getResultCode())
                                {
                                        case Activity.RESULT_OK:
                                                Toast.makeText(getBaseContext(), "SMS Sent", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("SMS sent");
                                               
                                                cur.moveToFirst();
                                            id=cur.getLong(0);
                                               
                                                ContentValues values = new ContentValues();
                                                values.put("type", 2);
                                               
                                                getContentResolver().update(Uri.parse("content://sms/inbox/"+id), values, null, null);
                                               
                                                break;
                                        case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                                                Toast.makeText(getBaseContext(), "Generic Failure", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("Generic Failure");
                                                break;
                                        case SmsManager.RESULT_ERROR_NO_SERVICE:
                                                Toast.makeText(getBaseContext(), "No Service", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("No Service");
                                                break;
                                        case SmsManager.RESULT_ERROR_NULL_PDU:
                                                Toast.makeText(getBaseContext(), "Null PDU", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("Null PDU");
                                                break;
                                        case SmsManager.RESULT_ERROR_RADIO_OFF:
                                                Toast.makeText(getBaseContext(), "Radio Off ", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("Radio Off");
                                                //maxSend=maxSend-1;
                                               
                                                timer.scheduleAtFixedRate(new TimerTask() {
                                                               
                                                        Cursor cur = getContentResolver().query(Uri.parse("content://sms"), null, null, null,null);
                                                        @Override
                                                        public void run() {
                                                                // TODO Auto-generated method stub
                                                               
                                                                if(cur.moveToFirst()){
                                                               
                                                                        if(cur.getString(8).equals("6")) {
                                                                                sendSms(cur.getString(2), cur.getString(11), sentPI, null);
                                                                        }
                                                                }
                                                                //Toast.makeText(getBaseContext(), "prova n° "+maxSend, Toast.LENGTH_SHORT).show();
                                                                       
                                                        }
                                                },startUp,periodo);
                                                       
                                                barraNotifiche.setText("sending SMS...");
                                               
                                                break; 
                                        }
                                               
                                               
                                }
                       
                };
               
                registerReceiver(smsSender, new IntentFilter(SENT));
               
                        sendSms(phoneNumber, message, sentPI, null);
                       
                        ContentValues values = new ContentValues();
                        values.put("address",phoneNumber);
                        values.put("body", message);
                        values.put("type", 6);
                        values.put("read", 1);
                        values.put("seen", 1);
                       
                        getContentResolver().insert(Uri.parse("content://sms"), values);
                       
                       
                        updateSMS("Me: "+message);
               
        }
       
        public void sendSms(String phoneNumber,String message,PendingIntent sentPI, PendingIntent deliveredPI) {
                SmsManager sms=SmsManager.getDefault();
                sms.sendTextMessage(phoneNumber, null, message, sentPI, null);
               
        }

ovviamente ho implementato il codice per rimandare il messaggio solo per il caso in cui sia in modalità offliine, ma una volta corretto basterà fare un copia-incolla per gli altri risultati

questo è il logcat:
Codice: [Seleziona]
09-10 22:21:56.023: INFO/ActivityManager(58): Displayed activity com.dev.SMSMessaging/.SmsAppActivity: 1583 ms (total 1583 ms)
09-10 22:21:59.354: INFO/ActivityManager(58): Starting activity: Intent { cmp=com.dev.SMSMessaging/.SMSConversation (has extras) }
09-10 22:22:00.103: INFO/ActivityManager(58): Displayed activity com.dev.SMSMessaging/.SMSConversation: 709 ms (total 709 ms)
09-10 22:22:02.993: DEBUG/dalvikvm(117): GC_FOR_MALLOC freed 1481 objects / 215104 bytes in 81ms
09-10 22:22:03.443: DEBUG/dalvikvm(117): GC_EXTERNAL_ALLOC freed 940 objects / 63416 bytes in 87ms
09-10 22:22:04.262: WARN/KeyCharacterMap(117): No keyboard for id 0
09-10 22:22:04.262: WARN/KeyCharacterMap(117): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-10 22:22:04.592: WARN/KeyCharacterMap(274): No keyboard for id 0
09-10 22:22:04.592: WARN/KeyCharacterMap(274): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-10 22:22:15.483: DEBUG/dalvikvm(117): GC_EXTERNAL_ALLOC freed 6714 objects / 371680 bytes in 79ms
09-10 22:22:16.353: DEBUG/dalvikvm(117): GC_EXTERNAL_ALLOC freed 2250 objects / 112440 bytes in 78ms
09-10 22:22:17.543: WARN/KeyCharacterMap(117): No keyboard for id 0
09-10 22:22:17.543: WARN/KeyCharacterMap(117): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-10 22:22:24.953: VERBOSE/Telephony(122): getOrCreateThreadId uri: content://mms-sms/threadID?recipient=15555215556
09-10 22:22:24.983: VERBOSE/Telephony(122): getOrCreateThreadId cursor cnt: 1
09-10 22:22:25.303: DEBUG/dalvikvm(122): GREF has increased to 201
09-10 22:22:35.803: DEBUG/dalvikvm(274): GC_FOR_MALLOC freed 7744 objects / 331968 bytes in 94ms
09-10 22:22:40.983: DEBUG/dalvikvm(274): GREF has increased to 201
09-10 22:22:45.993: DEBUG/dalvikvm(122): GREF has increased to 301
09-10 22:22:46.503: DEBUG/dalvikvm(122): GC_EXPLICIT freed 2232 objects / 121984 bytes in 74ms
09-10 22:22:46.853: DEBUG/dalvikvm(58): GREF has increased to 401
09-10 22:22:51.243: DEBUG/dalvikvm(274): GREF has increased to 301
09-10 22:22:51.803: DEBUG/dalvikvm(58): GC_EXPLICIT freed 7733 objects / 397624 bytes in 143ms
09-10 22:22:51.813: DEBUG/dalvikvm(122): GREF has increased to 401
09-10 22:22:53.293: DEBUG/dalvikvm(274): GC_EXPLICIT freed 2939 objects / 116992 bytes in 90ms
09-10 22:22:55.794: DEBUG/dalvikvm(122): GC_EXPLICIT freed 1218 objects / 63048 bytes in 72ms
09-10 22:22:56.402: DEBUG/dalvikvm(122): GREF has increased to 501
09-10 22:22:57.002: DEBUG/dalvikvm(58): GREF has increased to 501
09-10 22:22:57.142: DEBUG/dalvikvm(274): GREF has increased to 401
09-10 22:22:57.902: DEBUG/dalvikvm(122): GREF has increased to 601
09-10 22:22:58.683: DEBUG/dalvikvm(122): GC_EXPLICIT freed 1230 objects / 64448 bytes in 71ms
09-10 22:22:59.223: DEBUG/dalvikvm(274): GREF has increased to 501
09-10 22:22:59.443: DEBUG/dalvikvm(122): GREF has increased to 701
09-10 22:22:59.583: DEBUG/dalvikvm(274): GC_EXPLICIT freed 2459 objects / 107344 bytes in 85ms
09-10 22:22:59.963: DEBUG/dalvikvm(58): GREF has increased to 601
09-10 22:23:00.433: DEBUG/dalvikvm(58): GC_EXPLICIT freed 3296 objects / 147848 bytes in 106ms
09-10 22:23:01.983: DEBUG/dalvikvm(122): GREF has increased to 801
09-10 22:23:02.323: DEBUG/dalvikvm(122): GC_EXPLICIT freed 1282 objects / 65864 bytes in 101ms
09-10 22:23:02.893: DEBUG/dalvikvm(274): GREF has increased to 601
09-10 22:23:03.793: DEBUG/dalvikvm(122): GREF has increased to 901
09-10 22:23:04.003: DEBUG/dalvikvm(58): GREF has increased to 701
09-10 22:23:04.303: DEBUG/dalvikvm(274): GC_EXPLICIT freed 1922 objects / 73704 bytes in 83ms
09-10 22:23:05.353: DEBUG/dalvikvm(122): GC_EXPLICIT freed 1158 objects / 59744 bytes in 82ms
09-10 22:23:05.883: DEBUG/dalvikvm(274): GREF has increased to 701
09-10 22:23:05.893: DEBUG/dalvikvm(122): GREF has increased to 1001
09-10 22:23:07.473: DEBUG/dalvikvm(58): GREF has increased to 801
09-10 22:23:07.743: DEBUG/dalvikvm(58): GC_EXPLICIT freed 2774 objects / 126984 bytes in 114ms
09-10 22:23:07.823: DEBUG/dalvikvm(122): GREF has increased to 1101
09-10 22:23:09.043: DEBUG/dalvikvm(274): GREF has increased to 801
09-10 22:23:09.163: DEBUG/dalvikvm(122): GC_EXPLICIT freed 2041 objects / 100152 bytes in 90ms
09-10 22:23:09.348: DEBUG/dalvikvm(274): GC_EXPLICIT freed 1940 objects / 79432 bytes in 89ms
09-10 22:23:10.553: DEBUG/dalvikvm(122): GREF has increased to 1201
09-10 22:23:12.103: DEBUG/dalvikvm(58): GREF has increased to 901
09-10 22:23:12.543: DEBUG/dalvikvm(122): GREF has increased to 1301
09-10 22:23:12.622: DEBUG/dalvikvm(274): GREF has increased to 901
09-10 22:23:12.763: DEBUG/dalvikvm(122): GC_EXPLICIT freed 2142 objects / 103144 bytes in 118ms
09-10 22:23:14.232: DEBUG/dalvikvm(274): GC_EXPLICIT freed 2160 objects / 82600 bytes in 89ms
09-10 22:23:14.972: DEBUG/dalvikvm(122): GREF has increased to 1401
09-10 22:23:15.933: DEBUG/dalvikvm(58): GC_EXPLICIT freed 3530 objects / 160448 bytes in 230ms
09-10 22:23:16.403: DEBUG/dalvikvm(58): GREF has increased to 1001
09-10 22:23:16.603: DEBUG/dalvikvm(274): GREF has increased to 1001
09-10 22:23:16.713: DEBUG/dalvikvm(122): GC_EXPLICIT freed 2452 objects / 116952 bytes in 114ms
09-10 22:23:17.583: DEBUG/dalvikvm(122): GREF has increased to 1501
09-10 22:23:19.443: DEBUG/dalvikvm(122): GREF has increased to 1601
09-10 22:23:19.603: DEBUG/dalvikvm(274): GREF has increased to 1101
09-10 22:23:19.793: DEBUG/dalvikvm(274): GC_EXPLICIT freed 2240 objects / 84440 bytes in 88ms
09-10 22:23:20.513: DEBUG/dalvikvm(122): GC_EXPLICIT freed 2572 objects / 122032 bytes in 104ms
09-10 22:23:20.803: DEBUG/dalvikvm(58): GREF has increased to 1101
09-10 22:23:22.603: DEBUG/dalvikvm(122): GREF has increased to 1701
09-10 22:23:23.923: DEBUG/dalvikvm(274): GREF has increased to 1201
09-10 22:23:24.813: DEBUG/dalvikvm(122): GC_EXPLICIT freed 3377 objects / 157520 bytes in 121ms
09-10 22:23:24.903: DEBUG/dalvikvm(122): GREF has increased to 1801
09-10 22:23:25.383: DEBUG/dalvikvm(58): GC_EXPLICIT freed 4630 objects / 211000 bytes in 144ms
09-10 22:23:26.333: DEBUG/dalvikvm(58): GREF has increased to 1201
09-10 22:23:26.543: DEBUG/dalvikvm(274): GC_EXPLICIT freed 2808 objects / 104344 bytes in 101ms
09-10 22:23:28.673: DEBUG/dalvikvm(122): GREF has increased to 1901
09-10 22:23:29.413: DEBUG/dalvikvm(274): GREF has increased to 1301
09-10 22:23:30.273: DEBUG/dalvikvm(122): GC_EXPLICIT freed 4478 objects / 208296 bytes in 113ms
09-10 22:23:31.705: DEBUG/dalvikvm(122): GREF has increased to 2001
09-10 22:23:31.705: WARN/dalvikvm(122): Last 10 entries in JNI global reference table:
09-10 22:23:31.712: WARN/dalvikvm(122):  1991: 0x44fbaab0 cls=Ljava/lang/ref/WeakReference; (28 bytes)
09-10 22:23:31.712: WARN/dalvikvm(122):  1992: 0x44fb5df0 cls=Ljava/lang/ref/WeakReference; (28 bytes)
09-10 22:23:31.712: WARN/dalvikvm(122):  1993: 0x44fb5e58 cls=Ljava/lang/ref/WeakReference; (28 bytes)
09-10 22:23:31.712: WARN/dalvikvm(122):  1994: 0x44f99270 cls=Landroid/database/ContentObserver$Transport; (28 bytes)
09-10 22:23:31.712: WARN/dalvikvm(122):  1995: 0x44f99290 cls=Landroid/database/CursorToBulkCursorAdaptor; (44 bytes)
09-10 22:23:31.712: WARN/dalvikvm(122):  1996: 0x44f99290 cls=Landroid/database/CursorToBulkCursorAdaptor; (44 bytes)
09-10 22:23:31.712: WARN/dalvikvm(122):  1997: 0x44fab378 cls=Ljava/lang/ref/WeakReference; (28 bytes)
09-10 22:23:31.712: WARN/dalvikvm(122):  1998: 0x44f9d608 cls=Ljava/lang/ref/WeakReference; (28 bytes)
09-10 22:23:31.712: WARN/dalvikvm(122):  1999: 0x44fc21d8 cls=Landroid/database/ContentObserver$Transport; (28 bytes)
09-10 22:23:31.712: WARN/dalvikvm(122):  2000: 0x44fc21f8 cls=Landroid/database/CursorToBulkCursorAdaptor; (44 bytes)
09-10 22:23:31.762: WARN/dalvikvm(122): JNI global reference table summary (2001 entries):
09-10 22:23:31.762: WARN/dalvikvm(122):    97 of Ljava/lang/Class; 164B (52 unique)
09-10 22:23:31.762: WARN/dalvikvm(122):     2 of Ldalvik/system/VMRuntime; 12B (1 unique)
09-10 22:23:31.772: WARN/dalvikvm(122):     1 of Ljava/lang/String; 28B
09-10 22:23:31.772: WARN/dalvikvm(122):   804 of Ljava/lang/ref/WeakReference; 28B (804 unique)
09-10 22:23:31.772: WARN/dalvikvm(122):    28 of Ljava/lang/ref/WeakReference; 36B (28 unique)
09-10 22:23:31.772: WARN/dalvikvm(122):     1 of Landroid/app/ActivityThread$ApplicationThread; 28B
09-10 22:23:31.772: WARN/dalvikvm(122):     5 of Landroid/content/ContentProvider$Transport; 28B (5 unique)
09-10 22:23:31.793: WARN/dalvikvm(122):   628 of Landroid/database/CursorToBulkCursorAdaptor; 44B (412 unique)
09-10 22:23:31.793: WARN/dalvikvm(122):    12 of Landroid/database/CursorToBulkCursorAdaptor; 52B (8 unique)
09-10 22:23:31.793: WARN/dalvikvm(122):     1 of Landroid/app/ActivityThread$ProviderRecord; 28B
09-10 22:23:31.793: WARN/dalvikvm(122):     7 of Landroid/app/ActivityThread$PackageInfo$ReceiverDispatcher$InnerReceiver; 28B (7 unique)
09-10 22:23:31.793: WARN/dalvikvm(122):   401 of Landroid/database/ContentObserver$Transport; 28B (401 unique)
09-10 22:23:31.793: WARN/dalvikvm(122):     9 of Landroid/database/ContentObserver$Transport; 36B (9 unique)
09-10 22:23:31.793: WARN/dalvikvm(122):     1 of Lcom/android/internal/telephony/IccSmsInterfaceManagerProxy; 28B
09-10 22:23:31.793: WARN/dalvikvm(122):     1 of Lcom/android/internal/telephony/IccPhoneBookInterfaceManagerProxy; 28B
09-10 22:23:31.793: WARN/dalvikvm(122):     1 of Lcom/android/internal/telephony/PhoneSubInfoProxy; 28B
09-10 22:23:31.793: WARN/dalvikvm(122):     1 of Lcom/android/phone/PhoneInterfaceManager; 36B
09-10 22:23:31.793: WARN/dalvikvm(122):     1 of Landroid/telephony/PhoneStateListener$1; 28B
09-10 22:23:31.793: WARN/dalvikvm(122): Memory held directly by tracked refs is 62724 bytes
09-10 22:23:31.793: ERROR/dalvikvm(122): Excessive JNI global references (2001)
09-10 22:23:31.793: ERROR/dalvikvm(122): VM aborting
09-10 22:23:31.962: INFO/DEBUG(30): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-10 22:23:31.962: INFO/DEBUG(30): Build fingerprint: 'generic/sdk/generic/:2.2/FRF91/43546:eng/test-keys'
09-10 22:23:31.962: INFO/DEBUG(30): pid: 122, tid: 425  >>> com.android.phone <<<
09-10 22:23:31.962: INFO/DEBUG(30): signal 11 (SIGSEGV), fault addr deadd00d
09-10 22:23:31.962: INFO/DEBUG(30):  r0 00000374  r1 0000000c  r2 0000000c  r3 deadd00d
09-10 22:23:31.962: INFO/DEBUG(30):  r4 00000026  r5 80887fc4  r6 fffe91e1  r7 000007d1
09-10 22:23:31.972: INFO/DEBUG(30):  r8 598b1b80  r9 430c6dfc  10 430c6de4  fp 004f43b0
09-10 22:23:31.972: INFO/DEBUG(30):  ip 808881ec  sp 598b1ac8  lr afd154c5  pc 8083b162  cpsr 20000030
09-10 22:23:32.342: INFO/DEBUG(30):          #00  pc 0003b162  /system/lib/libdvm.so
09-10 22:23:32.342: INFO/DEBUG(30):          #01  pc 0003f032  /system/lib/libdvm.so
09-10 22:23:32.342: INFO/DEBUG(30):          #02  pc 0003f0c6  /system/lib/libdvm.so
09-10 22:23:32.352: INFO/DEBUG(30):          #03  pc 0002ebf2  /system/lib/libdvm.so
09-10 22:23:32.352: INFO/DEBUG(30):          #04  pc 0002f152  /system/lib/libandroid_runtime.so
09-10 22:23:32.362: INFO/DEBUG(30):          #05  pc 00044fb2  /system/lib/libandroid_runtime.so
09-10 22:23:32.372: INFO/DEBUG(30):          #06  pc 00045052  /system/lib/libandroid_runtime.so
09-10 22:23:32.372: INFO/DEBUG(30):          #07  pc 00013974  /system/lib/libdvm.so
09-10 22:23:32.372: INFO/DEBUG(30):          #08  pc 0003de3c  /system/lib/libdvm.so
09-10 22:23:32.382: INFO/DEBUG(30):          #09  pc 00037216  /system/lib/libdvm.so
09-10 22:23:32.382: INFO/DEBUG(30):          #10  pc 00018714  /system/lib/libdvm.so
09-10 22:23:32.382: INFO/DEBUG(30):          #11  pc 0001e8c4  /system/lib/libdvm.so
09-10 22:23:32.382: INFO/DEBUG(30):          #12  pc 0001d790  /system/lib/libdvm.so
09-10 22:23:32.402: INFO/DEBUG(30):          #13  pc 00053eec  /system/lib/libdvm.so
09-10 22:23:32.402: INFO/DEBUG(30):          #14  pc 00040ee8  /system/lib/libdvm.so
09-10 22:23:32.402: INFO/DEBUG(30):          #15  pc 0003584a  /system/lib/libdvm.so
09-10 22:23:32.412: INFO/DEBUG(30):          #16  pc 00045152  /system/lib/libandroid_runtime.so
09-10 22:23:32.423: INFO/DEBUG(30):          #17  pc 00045468  /system/lib/libandroid_runtime.so
09-10 22:23:32.423: INFO/DEBUG(30):          #18  pc 000132dc  /system/lib/libbinder.so
09-10 22:23:32.423: INFO/DEBUG(30):          #19  pc 0001652c  /system/lib/libbinder.so
09-10 22:23:32.423: INFO/DEBUG(30):          #20  pc 00016700  /system/lib/libbinder.so
09-10 22:23:32.432: INFO/DEBUG(30):          #21  pc 0001bf08  /system/lib/libbinder.so
09-10 22:23:32.432: INFO/DEBUG(30):          #22  pc 0001b474  /system/lib/libutils.so
09-10 22:23:32.432: INFO/DEBUG(30):          #23  pc 0002c87a  /system/lib/libandroid_runtime.so
09-10 22:23:32.432: INFO/DEBUG(30):          #24  pc 0001b8ca  /system/lib/libutils.so
09-10 22:23:32.452: INFO/DEBUG(30):          #25  pc 0001103c  /system/lib/libc.so
09-10 22:23:32.452: INFO/DEBUG(30):          #26  pc 00010b20  /system/lib/libc.so
09-10 22:23:32.452: INFO/DEBUG(30): code around pc:
09-10 22:23:32.452: INFO/DEBUG(30): 8083b140 1861447c 200618a2 e878f7d8 f7d82000
09-10 22:23:32.452: INFO/DEBUG(30): 8083b150 4808e9e4 6bdb5823 d0002b00 4b064798
09-10 22:23:32.452: INFO/DEBUG(30): 8083b160 701c2426 ea5cf7d8 0004ce80 fffe4ae0
09-10 22:23:32.452: INFO/DEBUG(30): 8083b170 fffe801c 00000374 deadd00d b510b40e
09-10 22:23:32.452: INFO/DEBUG(30): 8083b180 4c0a4b09 447bb083 aa05591b 6b5bca02
09-10 22:23:32.462: INFO/DEBUG(30): code around lr:
09-10 22:23:32.462: INFO/DEBUG(30): afd154a4 b0834a0d 589c447b 26009001 686768a5
09-10 22:23:32.462: INFO/DEBUG(30): afd154b4 220ce008 2b005eab 1c28d003 47889901
09-10 22:23:32.462: INFO/DEBUG(30): afd154c4 35544306 d5f43f01 2c006824 b003d1ee
09-10 22:23:32.462: INFO/DEBUG(30): afd154d4 bdf01c30 0002ae7c 000000d4 1c0fb5f0
09-10 22:23:32.462: INFO/DEBUG(30): afd154e4 43551c3d a904b087 1c16ac01 604d9004
09-10 22:23:32.462: INFO/DEBUG(30): stack:
09-10 22:23:32.472: INFO/DEBUG(30):     598b1a88  00000015 
09-10 22:23:32.472: INFO/DEBUG(30):     598b1a8c  afd1453b  /system/lib/libc.so
09-10 22:23:32.482: INFO/DEBUG(30):     598b1a90  afd405a0  /system/lib/libc.so
09-10 22:23:32.482: INFO/DEBUG(30):     598b1a94  afd4054c  /system/lib/libc.so
09-10 22:23:32.482: INFO/DEBUG(30):     598b1a98  00000000 
09-10 22:23:32.482: INFO/DEBUG(30):     598b1a9c  afd154c5  /system/lib/libc.so
09-10 22:23:32.482: INFO/DEBUG(30):     598b1aa0  44fbea88  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
09-10 22:23:32.492: INFO/DEBUG(30):     598b1aa4  afd1450d  /system/lib/libc.so
09-10 22:23:32.492: INFO/DEBUG(30):     598b1aa8  00000000 
09-10 22:23:32.492: INFO/DEBUG(30):     598b1aac  80887fc4  /system/lib/libdvm.so
09-10 22:23:32.492: INFO/DEBUG(30):     598b1ab0  80887fc4  /system/lib/libdvm.so
09-10 22:23:32.492: INFO/DEBUG(30):     598b1ab4  fffe91e1 
09-10 22:23:32.502: INFO/DEBUG(30):     598b1ab8  000007d1 
09-10 22:23:32.502: INFO/DEBUG(30):     598b1abc  afd1456b  /system/lib/libc.so
09-10 22:23:32.502: INFO/DEBUG(30):     598b1ac0  df002777 
09-10 22:23:32.502: INFO/DEBUG(30):     598b1ac4  e3a070ad 
09-10 22:23:32.502: INFO/DEBUG(30): #00 598b1ac8  fffe9069 
09-10 22:23:32.502: INFO/DEBUG(30):     598b1acc  8083f037  /system/lib/libdvm.so
09-10 22:23:32.502: INFO/DEBUG(30): #01 598b1ad0  8086caa4  /system/lib/libdvm.so
09-10 22:23:32.502: INFO/DEBUG(30):     598b1ad4  44fc21f8  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
09-10 22:23:32.502: INFO/DEBUG(30):     598b1ad8  8086d04c  /system/lib/libdvm.so
09-10 22:23:32.502: INFO/DEBUG(30):     598b1adc  80887fc4  /system/lib/libdvm.so
09-10 22:23:32.502: INFO/DEBUG(30):     598b1ae0  44fc21f8  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
09-10 22:23:32.502: INFO/DEBUG(30):     598b1ae4  004f5e60  [heap]
09-10 22:23:32.502: INFO/DEBUG(30):     598b1ae8  8086d04c  /system/lib/libdvm.so
09-10 22:23:32.512: INFO/DEBUG(30):     598b1aec  8083f0cb  /system/lib/libdvm.so
09-10 22:23:42.283: INFO/BootReceiver(58): Copying /data/tombstones/tombstone_09 to DropBox (SYSTEM_TOMBSTONE)
09-10 22:23:42.353: DEBUG/Zygote(32): Process 122 terminated by signal (11)
09-10 22:23:42.403: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.413: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.413: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.423: INFO/ActivityThread(274): Removing dead content provider: sms
09-10 22:23:42.433: INFO/ServiceManager(27): service 'isms' died
09-10 22:23:42.433: INFO/ServiceManager(27): service 'simphonebook' died
09-10 22:23:42.433: INFO/ServiceManager(27): service 'iphonesubinfo' died
09-10 22:23:42.433: INFO/ServiceManager(27): service 'phone' died
09-10 22:23:42.463: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.463: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.463: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.473: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.473: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.473: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.483: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.483: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.493: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.493: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.503: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.503: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.503: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.503: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.513: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.513: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.533: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.533: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.533: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.533: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.553: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.553: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.563: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.563: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.573: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.573: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.583: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.583: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.603: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.603: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.613: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.613: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.623: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.623: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.633: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.633: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.653: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.693: WARN/BinderNative(203): Uncaught exception from death notification
09-10 22:23:42.693: WARN/BinderNative(203): java.lang.NullPointerException
09-10 22:23:42.693: WARN/BinderNative(203):     at android.app.ActivityThread.removeDeadProvider(ActivityThread.java:4442)
09-10 22:23:42.693: WARN/BinderNative(203):     at android.app.ActivityThread$ProviderRecord.binderDied(ActivityThread.java:1353)
09-10 22:23:42.693: WARN/BinderNative(203):     at android.os.BinderProxy.sendDeathNotice(Binder.java:346)
09-10 22:23:42.693: WARN/BinderNative(203):     at dalvik.system.NativeStart.run(Native Method)
09-10 22:23:42.843: DEBUG/dalvikvm(274): GREF has decreased to 1199
09-10 22:23:42.863: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:42.913: DEBUG/dalvikvm(274): GREF has decreased to 1099
09-10 22:23:43.023: DEBUG/dalvikvm(274): GREF has decreased to 999
09-10 22:23:43.063: DEBUG/dalvikvm(274): GREF has decreased to 899
09-10 22:23:43.083: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:43.143: DEBUG/dalvikvm(274): GREF has decreased to 799
09-10 22:23:43.293: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:43.363: DEBUG/dalvikvm(58): GC_FOR_MALLOC freed 4333 objects / 324952 bytes in 1026ms
09-10 22:23:43.363: INFO/ActivityManager(58): Process com.android.phone (pid 122) has died.
09-10 22:23:43.535: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:43.683: DEBUG/dalvikvm(58): GREF has decreased to 1099
09-10 22:23:43.713: DEBUG/dalvikvm(58): GC_FOR_MALLOC freed 1089 objects / 299664 bytes in 248ms
09-10 22:23:43.713: INFO/dalvikvm-heap(58): Grow heap (frag case) to 5.965MB for 196628-byte allocation
09-10 22:23:43.779: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:43.973: DEBUG/dalvikvm(58): GREF has decreased to 999
09-10 22:23:43.983: ERROR/BulkCursor(274): Unable to get window because the remote process is dead
09-10 22:23:44.033: DEBUG/dalvikvm(58): GC_FOR_MALLOC freed 253 objects / 6816 bytes in 253ms
09-10 22:23:44.033: INFO/ActivityManager(58): Kill com.android.mms (pid 203): provider com.android.providers.telephony.SmsProvider in dying process com.android.phone
09-10 22:23:44.043: DEBUG/dalvikvm(58): GREF has decreased to 899
09-10 22:23:44.283: DEBUG/dalvikvm(58): GREF has decreased to 799
09-10 22:23:44.323: DEBUG/dalvikvm(58): GC_FOR_MALLOC freed 244 objects / 509992 bytes in 282ms
09-10 22:23:44.333: INFO/Process(58): Sending signal. PID: 203 SIG: 9
09-10 22:23:44.333: INFO/ActivityManager(58): Kill com.dev.SMSMessaging (pid 274): provider com.android.providers.telephony.SmsProvider in dying process com.android.phone
09-10 22:23:44.333: INFO/Process(58): Sending signal. PID: 274 SIG: 9
09-10 22:23:44.463: INFO/ActivityManager(58): Start proc com.android.phone for restart com.android.phone: pid=509 uid=1001 gids={3002, 3001, 3003, 1015}
09-10 22:23:44.473: INFO/ActivityManager(58): Process com.android.mms (pid 203) has died.
09-10 22:23:44.504: DEBUG/dalvikvm(58): GREF has decreased to 699
09-10 22:23:44.593: INFO/WindowManager(58): WIN DEATH: Window{4505b4d0 com.dev.SMSMessaging/com.dev.SMSMessaging.SmsAppActivity paused=false}
09-10 22:23:44.603: INFO/ActivityManager(58): Process com.dev.SMSMessaging (pid 274) has died.
09-10 22:23:44.614: INFO/WindowManager(58): WIN DEATH: Window{4507c0e8 com.dev.SMSMessaging/com.dev.SMSMessaging.SMSConversation paused=false}
09-10 22:23:44.623: INFO/WindowManager(58): WIN DEATH: Window{45085a50 Toast paused=false}
09-10 22:23:44.623: INFO/WindowManager(58): WIN DEATH: Window{4504f218 Toast paused=false}
09-10 22:23:44.683: INFO/WindowManager(58): WIN DEATH: Window{45008f70 Toast paused=false}
09-10 22:23:44.693: INFO/WindowManager(58): WIN DEATH: Window{4503ac48 Toast paused=false}
09-10 22:23:44.713: INFO/ActivityManager(58): Start proc com.dev.SMSMessaging for activity com.dev.SMSMessaging/.SmsAppActivity: pid=512 uid=10036 gids={}
09-10 22:23:44.743: DEBUG/dalvikvm(58): GREF has decreased to 599
09-10 22:23:45.233: INFO/UsageStats(58): Unexpected resume of com.dev.SMSMessaging while already resumed in com.dev.SMSMessaging
09-10 22:23:45.373: WARN/NotificationService(58): Object died trying to hide notification android.app.ITransientNotification$Stub$Proxy@44f42878 in package com.dev.SMSMessaging
09-10 22:23:45.373: WARN/ActivityManager(58): setProcessForeground called on unknown pid: 274
09-10 22:23:45.373: WARN/NotificationService(58): Object died trying to show notification android.app.ITransientNotification$Stub$Proxy@44f36590 in package com.dev.SMSMessaging
09-10 22:23:45.383: WARN/ActivityManager(58): setProcessForeground called on unknown pid: 274

avreste consigli anche su come fare a fargli riprovare un tot di volte? ho provato con una semplice variabile che si decremente ogni volta che riprovo a mandare un messaggio in questo modo, ma non va:

Codice (Java): [Seleziona]
                                        case SmsManager.RESULT_ERROR_RADIO_OFF:
                                                Toast.makeText(getBaseContext(), "Radio Off "+maxSend, Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("Radio Off");
                                                //maxSend=maxSend-1;
                                               
                                                timer.scheduleAtFixedRate(new TimerTask() {
                                                               
                                                        Cursor cur = getContentResolver().query(Uri.parse("content://sms"), null, null, null,null);
                                                        int maxSend = 5;
                                                        @Override
                                                        public void run() {
                                                                // TODO Auto-generated method stub
                                                               
                                                                if(cur.moveToFirst()){
                                                               
                                                                        if(cur.getString(8).equals("6") && maxSend>0) {
                                                                                maxSend-=1;
                                                                                sendSms(cur.getString(2), cur.getString(11), sentPI, null);
                                                                        }
                                                                }
                                                                //Toast.makeText(getBaseContext(), "prova n° "+maxSend, Toast.LENGTH_SHORT).show();
                                                                       
                                                        }
                                                },startUp,periodo);
                                                       
                                                barraNotifiche.setText("sending SMS..."+maxSend);
                                               
                                                break;

ultima domanda.. secondo voi il processo d'invio è meglio farlo in background? cioè quando clicco il pulsante Invia faccio tutto in backgroud o cosa??

grazie mille in anticipo delle risposte!!
« Ultima modifica: 11 Settembre 2011, 01:00:23 CEST da teo_ »

Offline teo_

  • Utente junior
  • **
  • Post: 72
  • Respect: +1
    • Github
    • Mostra profilo
  • Dispositivo Android:
    Nexus 4
  • Sistema operativo:
    Windows 7 - Ubuntu 12.10
Re:Re-invio SMS
« Risposta #1 il: 12 Settembre 2011, 01:23:50 CEST »
0
up

Offline Ricky`

  • Amministratore
  • Utente storico
  • *****
  • Post: 3489
  • Respect: +507
    • Github
    • Google+
    • rciovati
    • Mostra profilo
Re: Re-invio SMS
« Risposta #2 il: 12 Settembre 2011, 07:09:31 CEST »
0
Non serve uppare dopo così poco tempo ;)

Sent from my HTC Desire

Offline teo_

  • Utente junior
  • **
  • Post: 72
  • Respect: +1
    • Github
    • Mostra profilo
  • Dispositivo Android:
    Nexus 4
  • Sistema operativo:
    Windows 7 - Ubuntu 12.10
Re:Re-invio SMS
« Risposta #3 il: 13 Settembre 2011, 13:59:21 CEST »
0
hai ragione scusa.. comunque non c'è proprio  nessuno che sappia come aiutarmi????

Offline teo_

  • Utente junior
  • **
  • Post: 72
  • Respect: +1
    • Github
    • Mostra profilo
  • Dispositivo Android:
    Nexus 4
  • Sistema operativo:
    Windows 7 - Ubuntu 12.10
Re:Re-invio SMS
« Risposta #4 il: 14 Settembre 2011, 15:22:17 CEST »
0
ho risolto la prima domanda.. sbagliavo a fargli un timer che si ripetesse ogni tot millisecondi, devo semplicemente usare un timer per aspettare una sola volta, e poi eseguire le istruzioni. l'invio dell'sms se non andrà a buon fine richiamerà automaticamente lo stesso timer..
ho fatto così, correggetemi se sbaglio qualcosa:
Codice (Java): [Seleziona]
case SmsManager.RESULT_ERROR_RADIO_OFF:
        Toast.makeText(getBaseContext(), "Radio Off", Toast.LENGTH_SHORT).show();
        barraNotifiche.setText("Radio Off");
                                               
        timer.schedule(new TimerTask() {
                Cursor cur = getContentResolver().query(Uri.parse("content://sms"), null, null, null, null);
                                                       
                @Override
                public void run() {
                        // TODO Auto-generated method stub
                                                               
                        if(cur.moveToFirst() && cur.getString(8).equals("6")) {
                                SmsManager sms=SmsManager.getDefault();
                                sms.sendTextMessage(cur.getString(2), null, cur.getString(11), sentPI, null);
                        }
                        cur.close();
                }
        }, periodo);
                                               
        barraNotifiche.setText("Re-sending SMS...");
                                               
        break;

in questo modo l'app cerca di reinviare il messaggio fino a che non va a buon fine, cioè fino a che non riceva come risultato RESULT_OK, però, se mentre sta tentando di reinviare il messaggio, lo schermo del telefono viene spento(cliccando una volta il tasto d'accensione) o viene cliccato il tasto home o peggio ancora viene cliccato il tasto indietro, l'app quando riuscirà a mandare l'sms lo invia una 20ina di volte (dipende non ho ben capito da cosa, forse dalle volte che ritenta l'invio, dato che una volta me l'ha inviato uguale 9 volte e un'altra volta 19)
avete idea del perchè di questo comportamento?

questo è il codice di sendSMS se può essere utile:

Codice (Java): [Seleziona]
private void sendSMS (String phoneNumber,String message)
        {
                String SENT="SMS_SENT";
                String DELIVERED="SMS_DELIVERED";
               
               
                final PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
                final PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
               
               
                smsSender = new BroadcastReceiver() {
                        @Override
                        public void onReceive(Context arg0, Intent arg1) {
                                Cursor cur = getContentResolver().query(Uri.parse("content://sms"), null, null, null,null);
                                long id=0;
                                Timer timer = new Timer();
                                long periodo = 5000;     // millisecondi di attesa per il timer
                                ContentValues values;
                               
                                switch(getResultCode())
                                {
                                        case Activity.RESULT_OK:
                                                Toast.makeText(getBaseContext(), "SMS Sent", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("SMS sent");
                                               
                                                cur.moveToFirst();
                                            id=cur.getLong(0);
                                               
                                                values = new ContentValues();
                                                values.put("type", 2);
                                               
                                                getContentResolver().update(Uri.parse("content://sms/inbox/"+id), values, null, null);
                                               
                                                break;
                                        case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                                                Toast.makeText(getBaseContext(), "Generic Failure", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("Generic Failure");
                                               
                                                cur.moveToFirst();
                                            id=cur.getLong(0);
                                               
                                                values = new ContentValues();
                                                values.put("type", 5);
                                               
                                                getContentResolver().update(Uri.parse("content://sms/inbox/"+id), values, null, null);

                                                //da inserire: codice per il reinvio uguale a quello in case SmsManager.RESULT_ERROR_RADIO_OFF
                                               
                                                break;
                                        case SmsManager.RESULT_ERROR_NO_SERVICE:
                                                Toast.makeText(getBaseContext(), "No Service", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("No Service");

                                                cur.moveToFirst();
                                            id=cur.getLong(0);
                                               
                                                values = new ContentValues();
                                                values.put("type", 5);
                                               
                                                getContentResolver().update(Uri.parse("content://sms/inbox/"+id), values, null, null);

                                                //da inserire: codice per il reinvio uguale a quello in case SmsManager.RESULT_ERROR_RADIO_OFF
                                               
                                                break;
                                        case SmsManager.RESULT_ERROR_NULL_PDU:
                                                Toast.makeText(getBaseContext(), "Null PDU", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("Null PDU");

                                                cur.moveToFirst();
                                            id=cur.getLong(0);
                                               
                                                values = new ContentValues();
                                                values.put("type", 5);
                                               
                                                getContentResolver().update(Uri.parse("content://sms/inbox/"+id), values, null, null);

                                                //da inserire: codice per il reinvio uguale a quello in case SmsManager.RESULT_ERROR_RADIO_OFF
                                               
                                                break;
                                        case SmsManager.RESULT_ERROR_RADIO_OFF:
                                                Toast.makeText(getBaseContext(), "Radio Off", Toast.LENGTH_SHORT).show();
                                                barraNotifiche.setText("Radio Off");
                                               
                                                timer.schedule(new TimerTask() {
                                                        Cursor cur = getContentResolver().query(Uri.parse("content://sms"), null, null, null, null);
                                                       
                                                        @Override
                                                        public void run() {
                                                                // TODO Auto-generated method stub
                                                               
                                                                if(cur.moveToFirst() && cur.getString(8).equals("6")) {
                                                                        SmsManager sms=SmsManager.getDefault();
                                                                        sms.sendTextMessage(cur.getString(2), null, cur.getString(11), sentPI, null);
                                                                }
                                                                cur.close();
                                                        }
                                                }, periodo);
                                               
                                                barraNotifiche.setText("Re-sending SMS...");
                                               
                                                break; 
                                        }//switch(getResultCode())
                                       
                                }//onReceive(Context arg0, Intent arg1)
                       
                };
               
                registerReceiver(smsSender, new IntentFilter(SENT));
                smsSenderRegistered=true;
               
                //sendSms(phoneNumber, message, sentPI, null);
               
                SmsManager sms=SmsManager.getDefault();
                sms.sendTextMessage(phoneNumber, null, message, sentPI, null);
                       
                ContentValues values = new ContentValues();
                values.put("address", phoneNumber);//numero del destinatario
                values.put("body", message); //testo del messaggio
                values.put("type", 6);//sms marcato come "sending..."
                values.put("read", 1);//sms marcato come letto
                values.put("seen", 1);//sms marcato come visto
                long date = System.currentTimeMillis();
                values.put("date", date);//ora in cui il messaggio viene inviato(ora corrente)
                       
                getContentResolver().insert(Uri.parse("content://sms"), values);
                       
                updateSMS(date+"§Me: "+message, true);//aggiorna la listView contenente i messaggi
               
        }

grazie in anticipo per le eventuali dritte