Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-从SMS广播接收器创建通知_Android - Fatal编程技术网

Android-从SMS广播接收器创建通知

Android-从SMS广播接收器创建通知,android,Android,我的程序使用BroadcastReceiver来扫描SMS(它可以根据文本内容创建toast消息)。但是我想让它触发一个通知(就像系统生成的通知一样,但我将根据内容动态驱动它。到目前为止,我在收到短信并为我的应用程序过滤后,尝试了以下代码: Notifier notice = new Notifier(); Intent noticeIntent = new Intent(context, Preferences.class); notice.setNotice(c

我的程序使用BroadcastReceiver来扫描SMS(它可以根据文本内容创建toast消息)。但是我想让它触发一个通知(就像系统生成的通知一样,但我将根据内容动态驱动它。到目前为止,我在收到短信并为我的应用程序过滤后,尝试了以下代码:

    Notifier notice = new Notifier();
    Intent noticeIntent = new Intent(context, Preferences.class);   
    notice.setNotice(context, noticeIntent,noticeId ,
    R.drawable.gong_icon, "Gong Text", true);
然后调用类

公共类通知程序扩展活动{

public class Notifier extends Activity{        
    private int count;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
    }
    // Proven working Notification call
从这一点上,我调用了一段已测试并正在运行的通知代码

但是当我运行上面的代码时,我收到了一个错误,所以我尝试用adb进行调试。 运行adb catlob时,我收到以下错误:

java.lang.RuntimeException:无法启动接收器co m、 mattwinder.android.gong.SmsReceiver:java.lang.IllegalStateException:System s onCreate()之前的活动无法使用服务


请帮助!

SmsReceiver
中发布代码,你想做什么。