title: Println needs a message
body: <p>i am trying the following application but when i run it, i get an exception "println  needs a megssage" .can anyone help. following are the classes.</p>
  
  <p><strong>Receiver class</strong></p>
  
  <pre><code>package com.sms;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.database.Cursor;
  import android.net.Uri;
  import android.os.Bundle;
  import android.provider.ContactsContract.PhoneLookup;
  import android.telephony.SmsMessage;
  import android.widget.Toast;
  
  public class SMSReceiver extends BroadcastReceiver
  {
       String name=null;
      private Context mContext;
  
  
      @Override
      public void onReceive(Context context, Intent intent)
      {   
          // TODO Auto-generated method stub
  
          int n;
          Bundle bundle = intent.getExtras();
          Object pdus[] = (Object[]) bundle.get("pdus");
          SmsMessage smsMessage[] = new SmsMessage[pdus.length];
          for (n = 0; n &lt; pdus.length; n++)
          {
              smsMessage[n] = SmsMessage.createFromPdu((byte[]) pdus[n]);
          }
          // show first message
          String sms1 = smsMessage[0].getMessageBody();
          String from = smsMessage[0].getOriginatingAddress();
          //String name = getDisplayNameFromPhoneNo( from);
          Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(from));
          Cursor c = context.getContentResolver().query(lookupUri, new String[]{PhoneLookup.DISPLAY_NAME}, null, null, null);
           while(c.moveToNext()){ 
                  /* If we find a match we put it in a String.*/ 
                 name = c.getString(c.getColumnIndexOrThrow(PhoneLookup.DISPLAY_NAME));  
                   }
  
          //Toast toast = Toast.makeText(context, "SMS Received from: " + from, Toast.LENGTH_LONG);
          //toast.show();
  
          System.out.println("!!!!"+name);
          //Toast.makeText(context, "name: " + name, Toast.LENGTH_LONG).show();
           Intent sIntent=new Intent(context,SMSTalk.class);
              sIntent.putExtra("stringdata",name);
              context.startService(sIntent);
  
          /*SMSTalk smsTalk = new SMSTalk();
          smsTalk.readName(name);*/
          //context.startService(new Intent(context,SMSTalk.class));
      }
  
  
  }
  </code></pre>
  
  <p><strong>Service class</strong> </p>
  
  <pre><code>package com.sms;
  
  import java.util.Locale;
  
  import android.app.Service;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.os.IBinder;
  import android.speech.tts.TextToSpeech;
  import android.speech.tts.TextToSpeech.OnInitListener;
  import android.speech.tts.TextToSpeech.OnUtteranceCompletedListener;
  import android.widget.Toast;
  
  public class SMSTalk extends Service implements OnInitListener, OnUtteranceCompletedListener {
          public static TextToSpeech mTts;
          private String spokenText;
          public String msg=null;
          int flag=0;
          String temp;
          Context context;
  
          @Override
          public void onCreate() {
  
              // This is a good place to set spokenText
              System.out.println("SERVICE CREATED");
              //Toast.makeText(this,"...&gt;&gt;&gt;"+msg,Toast.LENGTH_LONG ).show();
  
          }
  
          @Override
          public int onStartCommand(final Intent intent, int flags, int startId) 
          {
                       mTts=new TextToSpeech(this, this);                
                      String msg=intent.getStringExtra("stringdata");
                      //Toast.makeText(this, "service starting "+ msg, Toast.LENGTH_SHORT).show();
                      System.out.println("$$$***"+msg);      
  
                        Toast.makeText(this, "service starting message from: "+ msg, Toast.LENGTH_SHORT).show();
  
                         //mTts.speak(msg,0, null);
  
              return  START_STICKY;       
  
          }      
  
          @Override
          public void onInit(final int status) {
  
                  // TODO Auto-generated method stub
                  if (status == TextToSpeech.SUCCESS) {
  
                             mTts.setLanguage(Locale.UK);
                            Toast.makeText(getApplicationContext(), "SUCCESSFULLY INITIALIZED",Toast.LENGTH_LONG).show();
                            mTts.speak(msg,0, null);
                          }
                      }
  
  
          @Override
          public void onUtteranceCompleted(String uttId) {
              stopSelf();
              System.out.println("onUtteranceCompleted"+msg);
          }
  
          @Override
          public void onDestroy() {
              if (mTts != null) {
                  mTts.stop();
                  mTts.shutdown();
              }
              super.onDestroy();
          }
  
          @Override
          public IBinder onBind(Intent arg0) {
              return null;
          }
  
         /* public void readName(String temp)
          {
               msg=temp;
               System.out.println("HHHHHHHHHHHHHHHHHHH"+msg);
               mTts.speak(msg, TextToSpeech.QUEUE_ADD, null);
  
          }*/
  
         }
  </code></pre>
  
  <p><strong>manifest file</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.sms"
        android:versionCode="1"
        android:versionName="1.0"&gt;
      &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
  
           &lt;receiver android:name=".SMSReceiver" android:enabled="true"&gt;              
            &lt;intent-filter&gt;                   
             &lt;action android:name="android.provider.Telephony.SMS_RECEIVED"/&gt;               
             &lt;/intent-filter&gt;         
              &lt;/receiver&gt;
              &lt;service android:name=".SMSTalk"
  
  
              &gt;&lt;/service&gt;
  
      &lt;/application&gt;
      &lt;uses-sdk android:minSdkVersion="5" /&gt;    
      &lt;uses-permission android:name="android.permission.RECEIVE_SMS"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.READ_CONTACTS"&gt;&lt;/uses-permission&gt;
  
  
  &lt;/manifest&gt; 
  </code></pre>
  
  <p><strong>logcat trace</strong></p>
  
  <pre><code>09-16 15:35:19.015: ERROR/AndroidRuntime(1148): FATAL EXCEPTION: main
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148): java.lang.NullPointerException: println needs a message
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.util.Log.println_native(Native Method)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.util.Log.i(Log.java:158)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.speech.tts.TextToSpeech.speak(TextToSpeech.java:720)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at com.sms.SMSTalk.onInit(SMSTalk.java:56)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.speech.tts.TextToSpeech$1.onServiceConnected(TextToSpeech.java:451)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1064)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1081)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.os.Handler.handleCallback(Handler.java:587)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.os.Handler.dispatchMessage(Handler.java:92)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.os.Looper.loop(Looper.java:123)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at android.app.ActivityThread.main(ActivityThread.java:3647)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at java.lang.reflect.Method.invokeNative(Native Method)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at java.lang.reflect.Method.invoke(Method.java:507)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  09-16 15:35:19.015: ERROR/AndroidRuntime(1148):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>