Android App Not Responding the SMS Receiver

2019-08-02 20:38发布

I have been working on an app to respond to received SMS messages (before you complain, I know this has been asked A LOT, but believe me, I can't get it to work at all, and I've tried searching for hours). I've got my manifest set up like so:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.csbctech.notiscreen"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".NotiScreenActivity"
            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 android:name="NotiScreenSmsReceiver" android:process=":remote">
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED"/>
            </intent-filter>
        </receiver>
    </application>

</manifest>

And my receiver class looks like this:

package com.csbctech.notiscreen;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.CountDownTimer;
import android.os.PowerManager;
import android.util.Log;

public class NotiScreenSmsReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Log.w("NotiScreen", "Got SMS");

    }


}

But the "NotiScreenSmsReceiver" class never gets called. I've tried several different examples, and I can't for the life of me get the receiver class to get called...I've even tried removing the uses-permission, and I don't even get an error message about not having permissions. What could be wrong? Oh please help me, you're my only hope!

2条回答
乱世女痞
2楼-- · 2019-08-02 21:09

Change

<receiver android:name="NotiScreenSmsReceiver" android:process=":remote">

to

<receiver android:name=".NotiScreenSmsReceiver" android:process=":remote">
查看更多
3楼-- · 2019-08-02 21:25

Are you running this on a phone with a custom SMS app such as GOSMS? I've heard that some of those programs will stop the broadcast so that they can create their own notifications and stop the stock ones.

查看更多
登录 后发表回答