Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid SMS receiver not working
    text
    copied!<p>I'm trying to write a simple application that attempts to receive SMS messages and handle them. I've followed several tutorials but I'm getting nowhere, when I send a SMS to the emulator, the Intent never seems to get fired.</p> <p>Here is my intent:</p> <pre><code>package com.neocodenetworks.smsfwd; import android.content.*; import android.os.Bundle; import android.telephony.*; import android.util.Log; public class SmsReciever extends BroadcastReceiver { private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED"; private static final String TAG = "smsfwd"; @Override public void onReceive(Context context, Intent intent) { Log.i(TAG, "Intent recieved: " + intent.getAction()); if (intent.getAction() == SMS_RECEIVED) { Bundle bundle = intent.getExtras(); if (bundle != null) { Object[] pdus = (Object[])bundle.get("pdus"); final SmsMessage[] messages = new SmsMessage[pdus.length]; for (int i = 0; i &lt; pdus.length; i++) { messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]); } if (messages.length &gt; -1) { Log.i(TAG, "Message recieved: " + messages[0].getMessageBody()); NetComm.SendMessage("me", messages[0].getOriginatingAddress(), messages[0].getMessageBody()); } } } } } </code></pre> <p>and here is my AndroidManifest.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.neocodenetworks.smsfwd" android:versionCode="1" android:versionName="1.0"&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"&gt; &lt;receiver android:name=".SmsReciever"&gt; &lt;intent-filter&gt; &lt;action android:name="android.provider.telephony.SMS_RECIEVED"&gt;&lt;/action&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;/application&gt; &lt;uses-sdk android:minSdkVersion="6" /&gt; &lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt; &lt;uses-permission android:name="android.permission.RECEIVE_SMS"&gt;&lt;/uses-permission&gt; &lt;/manifest&gt; </code></pre> <p>I'd really appreciate some guidance with what's going wrong. I'm just getting into Android development but I think I have my head wrapped around (most of) it. While monitoring the emulator's logcat, the log events never come up, and debugging breakpoints are never hit, so I have a feeling it's somewhere in my intent filter.</p> <p>I'm running this on Android 2.0.1.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload