3 messages in com.googlegroups.android-beginners[android-beginners] Re: Error in send...
FromSent OnAttachments
Analdin Judy20 May 2008 00:20 
Justin (Google Employee)21 May 2008 14:27 
Analdin Judy21 May 2008 22:22 
Subject:[android-beginners] Re: Error in sending and receving sms
From:Justin (Google Employee) (j.@google.com)
Date:05/21/2008 02:27:15 PM
List:com.googlegroups.android-beginners

Where is this sample from?

Cheers, Justin Android Team @ Google

On May 20, 12:20 am, "Analdin Judy" <j.@i-waves.com> wrote:

Here is the code i got from group to send and receiving message

a)I want to know what is actualy in the "main.xml" b)How can i test this program?

package com.northvortex.sms;

import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.IntentReceiver; import android.os.Bundle; import android.provider.Telephony; import android.telephony.gsm.SmsMessage; import android.util.Log;

/public class SMSReceiver extends IntentReceiver { private static final String TAG_LOG = "SMSReceiver";

private static final int ID_NOTIFICACION = 0x1221;

private static final String ACCION = "android.provider.Telephony.SMS_RECEIVED";

@Override public void onReceiveIntent(Context parContext, Intent parIntent) { NotificationManager elNotificador = (NotificationManager)parContext.getSystemService(Context.NOTIFICATION_SERVI­CE);

if (parIntent.getAction().equals(ACCION) == true) { StringBuilder elContenido = new StringBuilder();

Bundle losDatosExtras = parIntent.getExtras(); if (losDatosExtras != null) { . SmsMessage[] losMensajesSMS = Telephony.Sms.Intents.getMessagesFromIntent(parIntent);

for (SmsMessage unMensaje : losMensajesSMS) { elContenido.append("Mensajes SMS\n"); elContenido.append("enviado por:");

elContenido.append(unMensaje.getDisplayOriginatingAddress() + "\n"); elContenido.append("Mensaje:\n");

elContenido.append(unMensaje.getDisplayMessageBody()); } }

// Registramos en la bitacora el evento. Log.i(TAG_LOG, "onReceiveIntent: " + elContenido);

// Mostramos el mensaje utilizando el administrador de notificaciones elNotificador.notifyWithText(ID_NOTIFICACION, elContenido.toString(), NotificationManager.LENGTH_LONG, null);

// Consumimos este Intent, de esa forma ninguna otra aplicacion lo notara. this.abortBroadcast();

// Ahora intentamos gatillar una actividad adicional. Intent elIntento = new Intent(parContext, SMSActivity.class); elIntento.setLaunchFlags(Intent.NEW_TASK_LAUNCH); parContext.startActivity(elIntento); } return; }

}

package com.northvortex.sms;

import android.app.Activity; import android.os.Bundle;

public class SMSActivity extends Activity { /** * Esta clase es llamada la vez que la actividad es creada. */ @Override public void onCreate(Bundle parICicle) { super.onCreate(parICicle);

setContentView(R.layout.main);

return; }

}

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.northvortex.sms"> <uses-permission id="android.permission.RECEIVE_SMS" /> <application android:icon="@drawable/icon"> <!-- The Main Activity that gets started by the IntentReceiver listed below --> <activity class=".SMSActivity" android:label="@string/ app_name"> <intent-filter> <action android:value="android.intent.action.MAIN" /> <category android:value="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- This class will react on the SMS show a notification and start the Main-App afterwards --> <receiver class=".SMSReceiver"> <intent-filter> <action android:value="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> </application> </manifest>

Analdin Judy.M InfoWave Knowledgeware. Beyond Multimedia Chennai | INDIA M: +91.98416.64705www.i-waves.com