Where is this sample from?
Cheers,
Justin
Android Team @ Google
On May 20, 12:20 am, "Analdin Judy" <[EMAIL PROTECTED]> 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>
>
> --
> Thanks & Regards
>
> Analdin Judy.M
> InfoWave
> Knowledgeware. Beyond Multimedia
> Chennai | INDIA
> M: +91.98416.64705www.i-waves.com
>
> "The information contained in this e-mail (including any attachments) is
> intended by InfoWave for the use of the named individual or entity to which
> it is directed and is CONFIDENTIAL or PRIVILEGED. If you have received this
> e-mail (including any attachments) in error, please do not review, disclose,
> disseminate, distribute or copy this e-mail and attachments. As Electronic
> and Internet communications can be interfered with or affected by viruses
> and other defects, please scan this message and any attachments"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---