Friday, April 11, 2014

SMART SMS : SMS COMPRESSION USING LZW COMPRESSION ALGORITHM IN ANDROID

        In this work we investigate the possibility of reliably sending a small file via Short Message Service (SMS) by using data compression for a more effective mobile data exchange in which basic GSM is the only available data communication option.
        The Short Message Service (SMS) is a fundamental facility in the GSM communication standard. It is also the simplest form of data communication and sometimes also the cheapest when a terminal has no CSD data channel. Every day, billions of SMSes are sent and received all over the world, bringing SMS to be one of the most used applications in the mobile communication arena. Usually SMS is used for private conversation, but many other applications use it, as for example online banking, mobile payment, etc.. A typical SMS is composed at most of 160 symbols (by using 7 bits per symbol in the GSM standard) or up to 140 bytes (for binary messages). This is a relevant limitation essentially due to the need to support the service also on devices with very limited hardware capabilities.
          So the SMS I am imported the LZW Algorithm in the SMS application. before sending the SMS, which is compressed by the LZW Based compression and Send to the recipient. The SMS is then decompressed  using the Same App.

        This is the Encryption function,which takes the input string as arguments and returns the List of integers, which is the compressed string.
 /** Compress a string to a list of output symbols. */
    public static List compress(String uncompressed) {
        // Build the dictionary.
        int dictSize = 256;
        Map dictionary = new HashMap();
        for (int i = 0; i < 256; i++)
            dictionary.put("" + (char)i, i);
 
        String w = "";
        List result = new ArrayList();
        for (char c : uncompressed.toCharArray()) {
            String wc = w + c;
            if (dictionary.containsKey(wc))
                w = wc;
            else {
                result.add(dictionary.get(w));
                // Add wc to the dictionary.
                dictionary.put(wc, dictSize++);
                w = "" + c;
            }
        }
 
        // Output the code for w.
        if (!w.equals(""))
            result.add(dictionary.get(w));
        return result;
    }
This is the Decryption function,which takes the List of integers as arguments and returns the string, which is the uncompressed from the argument.
/** Decompress a list of output ks to a string. */
    public static String decompress(List<Integer> compressed) {
        // Build the dictionary.
        int dictSize = 256;
        Map<Integer,String> dictionary = new HashMap<Integer,String>();
        for (int i = 0; i < 256; i++)
            dictionary.put(i, "" + (char)i);

        String w = "" + (char)(int)compressed.remove(0);
        StringBuffer result = new StringBuffer(w);
        for (int k : compressed) {
            String entry;
            if (dictionary.containsKey(k))
                entry = dictionary.get(k);
            else if (k == dictSize)
                entry = w + w.charAt(0);
            else
                throw new IllegalArgumentException("Bad compressed k: " + k);

            result.append(entry);

            // Add w+entry[0] to the dictionary.
            dictionary.put(dictSize++, w + entry.charAt(0));

            w = entry;
        }
        return result.toString();
    }




      In Android, you can use SmsManager API or device’s Built-in SMS application to send a SMS message.Here i used SmsManager API to send sms. 

try{
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);
}
catch (exception e)
{
     Log.d("smsAppErrormsg",e.toString();
}


      For sending SMS You needs the Permission. Add this permission to the "AndroidManifest.xml" file. 






Download full project code

3 comments:

  1. Hello, can you please send me the full project code? The download link seems to be broken.
    You can send it to mhaikalazaim@gmail.com
    Thanks :)

    ReplyDelete
  2. Hello, thank you for sharing.
    Please fix the download link: I am also interested in testing this

    ReplyDelete
  3. You can take your messages one step ahead simply by attaching videos, documents, PDF files, and images. Even discount coupons and event flyers can easily and quickly be distributed to target customers by sending them in the form of SMS attachments. You can even distribute the promotional brochures and materials of your company through Send SMS Attachment. This will not only help you in getting good returns on investment but will also give you the chance to stay ahead of your competitors.

    ReplyDelete