I am trying to install an app that only contains an SMS intent
receiver, but I cannot get it to fire when I send the device a test
message. If I try to run an intent receiver in Eclipse, it
gives me an error "The Manifest defines no activity! Launch aborted!"

I tried installing the program manually using the adb tool, but when I
tried to trigger the intent (via SMS message) it still didn't fire my
code.
Here is the code I am trying to run:

Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android";
package="org.androidforgods.smsparser">
<application
android:icon="@drawable/icon">
<receiver
android:permission="android.permission.RECEIVE_SMS"
android:enabled="true" android:name="SMSParser">
<intent-filter>
<action
android:name="android.intent.action.MAIN"
android:value="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
------------------------
SMSParser.java

package org.androidforgods.smsparser;

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

public class SMSParser extends IntentReceiver {

static final String ACTION =
"android.provider.Telephony.SMS_RECEIVED";

@Override
public void onReceiveIntent(Context context, Intent intent) {
// Check if intent deals with SMS.
if(intent.getAction().equals(ACTION))
{
Log.i("test", "TEST TEST TEST");
SmsMessage[] messages =
Telephony.Sms.Intents.getMessagesFromIntent(intent);
NotificationManager nm = (NotificationManager)
context.getSystemService(
Context.NOTIFICATION_SERVICE);
for (SmsMessage currentMessage : messages){
Parcel p = Parcel.obtain();
p.writeString(currentMessage.getDisplayMessageBody());
Notification n = new Notification(p);
nm.notify(123,n);
}
}
}
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to