Ciao lavoro su un'applicazione Android SMS in scala all va tutto bene aspettarsi che non riesco a trovare il modo di scrivere il seguente codice Java in scala. Qualsiasi aiuto apprezzatoLancio di un oggetto java su oggetto [] in Scala
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
Devo ammettere che non so come scrivere Object [] a Scala la sua non java.util.ArrayList [java.lang.Object] Ho provato con il Bundle.getStringArrayList per ottenere un List [String] e fare un getBytes sulle corde, ma che non funziona ... il mio ultimo tentativo è stato:
//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 <- bundle.getStringArrayList("pdus").toList } yield
SmsMessage.createFromPdu(pdu.getBytes())
else ret= List()
ret
codice Java viene da: http://mobiforge.com/developing/story/sms-messaging-android Grazie per qualsiasi aiuto
Grazie PST, questo è quello di cui avevo bisogno! – user433320