Error in sending and receving sms

by Analdin Judy » Tue, 20 May 2008 07:20:43 GMT


Sponsored Links
 ere 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_SERVICE);


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.ma



Error in sending and receving sms

by Justin (Google Employee) » Wed, 21 May 2008 21:27:46 GMT


 here is this sample from?

Cheers,
Justin
Android Team @ Google

On May 20, 12:20 am, "Analdin Judy" <[EMAIL PROTECTED]> wrote:
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Error in sending and receving sms

by Analdin Judy » Thu, 22 May 2008 05:23:30 GMT


 >From the below link i got the sample,




Other Threads

1. Intent is not properly returned through onActivityResult

I have 2 activities which I need to share data between. The data
passes from the first (parent) activity to the child properly using
the intent and unpacking the bundle in the child class. However when
the child activity ends and onActivityResult() is called in the parent
the returned intent is null. Here is a snippet of the code involved:

// In parent class Parent.java

/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        configureButtonFunctionality();
    }

    private void configureButtonFunctionality()
    {
        Button b = (Button) findViewById(R.id.UpdateVelocityButton);
        b.setOnClickListener(new View.OnClickListener() {

                        public void onClick(View v) {
                                // TODO Auto-generated method stub
                                
launchAviationActivity(Activities.Velocity.ordinal());

                        }
                });
    }

    private Intent setIntentDataForActivities(int activity)
    {
        currentVelocity = 123.0; // privately defined class member.
        Intent i = new Intent(this, Child.class);
        i.putExtra("Velocity", currentVelocity);
        return(i);
    }

    private void launchChildActivity(int a)
    {
        startActivityForResult(setIntentDataForActivities(a), a);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode,
Intent intent)
    {
 /////////////////////////////////////////////////// Here is where the
intent returns from the Child class but is null... /////////////////
        super.onActivityResult(requestCode, resultCode, intent);

        if(requestCode == Activities.Velocity.ordinal())
        {
            currentVelocity = intent.getDoubleExtra("Velocity", 0.0);
        }
    }

// In child class Child.java
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        Intent i = this.getIntent();
        Bundle b = i.getExtras();
        currentVelocity = b.getDouble("Velocity"); // value is passed
and received properly here.

       ...............
    }

    private void closeActivity()
    {
        clearFields();

        //Intent i = new Intent(); // Building the intent with either
constructor does not make a difference in behavior
        Intent i = new Intent(this, Parent.class);
        i.putExtra("Velocity", currentVelocity);
        setResult(RESULT_OK, i);
        finish();
    }

I am new with Android and have ran out of explanations for this. Any
assistance will be appreciated :).

Thanks!

--~--~---------~--~----~------------~-------~--~----~

2. ADB - error, device not found

I have just bought a t-mobile pulse, and am having a few issues with
it. One of which....

If I try to connect to adb shell (or any other adb function by that
matter)

I get the following:


C:\androidsdk\android-sdk-windows-1.5_r3\tools>adb shell
* daemon not running. starting it now *
* daemon started successfully *
error: device not found


I have had this on both 1.5_r3 and 1.6

As far as I am aware the device is installed as adb in devide manager
- adb interface -> t-mobile 3g phone adb interface.


I have windows xp, but can try this on vista, if it is thought to work
better, and the device runs on Android 1.5.


Any ideas?
Thanks

--~--~---------~--~----~------------~-------~--~----~

3. RNDIS USB driver for Android on Zoom

4. Trouble re-running an app in emulator

5. phone calls others

6. So.... Any news since 2008?

7. Activity managed indeterminate ProgressDialog problem