title: Casting a java Object to Object[] in Scala
body: <p>Hi working on an Android SMS application in scala alls going fine expect I just cant find the way to write the following java code in scala. Any help appreciated</p>
  
  <pre><code>//---retrieve the SMS message received---
      Object[] pdus = (Object[]) bundle.get("pdus");  
      msgs = new SmsMessage[pdus.length];             
          for (int i=0; i&lt;msgs.length; i++){  
              msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);   
  </code></pre>
  
  <p>I must admit I dont know how to write Object[] in scala its not java.util.ArrayList[java.lang.Object] 
  I have tried using the Bundle.getStringArrayList to get a List[String] and the do a getBytes on the strings but that not working ...
  My last attempt was:</p>
  
  <pre><code>//I know I should be using an Option ...  
  def getSmsListFromIntent(intent:Intent):List[SmsMessage]= {  
      val bundle = intent.getExtras()  
      var ret:List[SmsMessage]= null  
      if (bundle != null)   
          ret= for { pdu &lt;- bundle.getStringArrayList("pdus").toList } yield  
  SmsMessage.createFromPdu( pdu.getBytes())
      else ret= List()  
      ret  
  </code></pre>
  
  <p>java code comes from: <a href="http://mobiforge.com/developing/story/sms-messaging-android" rel="noreferrer">http://mobiforge.com/developing/story/sms-messaging-android</a>
  Thanks for any help</p>