Send multi-part SMS

It is the source code from Froyo, made small change. 
        SmsManager smsManager = SmsManager.getDefault();
        ArrayList<String> messages = null;
        
        messages = smsManager.divideMessage(content);
        int messageCount = messages.size();
        ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>(messageCount);

        for (int i = 0; i < messageCount; i++) {
            PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, 
                    new Intent(ACTION_SENT), 0);
            sentIntents.add(pendingIntent);
        }
        
        // When the SMS has been sent
        mHadRegisteredSmsReceiver = true;
        registerReceiver(mSmsReciever, new IntentFilter(ACTION_SENT));
        try {
            smsManager.sendMultipartTextMessage(Const.REGISTER_CENTER_SMS_NUMBER, null, messages, sentIntents, null);
        } catch (Exception e) {
            com.jsecode.police.util.LogUtil.logException(TAG, e);
        }


    /** Broadcast receiver for SMS sending result 
     * Remove the "First run" flag when SMS send successfully 
     * */
    private BroadcastReceiver mSmsReciever = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            switch (getResultCode()) {
                case Activity.RESULT_OK:
                    // Here we are successfully run application and registered
                    Preferences.setFirstRunFlag(false);
                    break;
                default:
                    break;
            }
        }
    };



你可能感兴趣的:(exception,null,application,action,sms)