Galera blz?
Meu receiver não está funcionando no emulador, recebo o sms e nada acontece, alguém tem alguma idéia?
Androimanifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.alura.agenda">
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ListaAlunosActivity"
android:label="Agenda">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".FormularioActivity"
android:label="Formulario">
</activity>
<receiver android:name="br.com.alura.agenda.receiver.SMSReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
SMSReceiver:
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object[] messages = (Object[]) bundle.get("pdus");
byte[] message = (byte[]) messages[0];
SmsMessage sms = SmsMessage.createFromPdu(message);
String telefone = sms.getOriginatingAddress();
AlunoDAO dao = new AlunoDAO(context);
boolean ehAluno = dao.isAluno(telefone);
if(ehAluno) {
Toast.makeText(context, "Chegou um SMS!!!", Toast.LENGTH_LONG).show();
//MediaPlayer mp = MediaPlayer.create(context, R.raw.msg);
//mp.start();
}
dao.close();
}
Desde já obrigado,