Can't make a toast with a broadcastreceiver, never call onReceive

My question will be seem's stupid but I make a simple code to make a Toast when I receive a SMS, but impossible to see my toast.

My Android Manifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.romain.assistantvocal" >
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.READ_SMS" />

    <receiver class="com.example.romain.SMSReceiver" android:name=".SMSReceiver">
        <intent-filter android:priority="100">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
    </receiver>
    <activity
        android:name=".MyActivity"
        android:label="@string/app_name" >


        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>


    </activity>

    <receiver class="com.example.romain.SMSReceiver" android:name=".SMSReceiver">
        <intent-filter android:priority="100">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
    </receiver>
</application>

And here my class SMSReceiver :

package com.example.romain.assistantvocal;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.telephony.gsm.SmsMessage;
import android.widget.Toast;

import java.util.Locale;

/**
 * Created by romain on 26/09/2014.
 */
public class SMSReceiver extends BroadcastReceiver
{


    @Override
    public void onReceive(Context context, Intent intent)
    {

        Toast.makeText(context,"gg romstan",Toast.LENGTH_LONG).show();

    }

}

Thank you in advance for your answers.

Answers


replace
    <receiver class="com.example.romain.SMSReceiver" android:name=".SMSReceiver">
with
        <receiver android:name="com.example.romain.assistantvocal.SMSReceiver">

If ur aware of Ordered broadcasts then it says "As each receiver executes in turn, it can propagate a result to the next receiver, or it can completely abort the broadcast so that it won't be passed to other receivers. " So. If any broadcast has stopped passing data, u won't get the message. Try putting log in ur receiver and check. Whether ur receive message or not because ur toast message is correct. U can't keep priority more than 1000 as per android guidelines. so, give some thing near to 1000 or remove priority and check.


Try using this revicer:

<receiver android:name=".SmsReceiver" android:permission="android.permission.BROADCAST_SMS" android:exported="true">
    <intent-filter android:priority="6565" >
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
 </receiver>

Need Your Help

ResultSet.getNext() not working with PreparedStatement

java oracle jdbc plsql

I am trying to figure out why ResultSet.next() is never true in Java code that I am writing after I execute a SQL query that returns results from an Oracle 11g table into that ResultSet... it seems...

C++ basic qt question

c++ qt view matrix

Does someone know a fast way to add the ability to rotate and move a 3D model using Qt?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.