开发者

Android - Creating a notification from a SMS BroadcastReceiver

My program uses a BroadcastReceiver to scan for SMS (which works and can create a toast message based on text content). But I would like for this to fire off a notification (just like the system generated ones, but I am going to dynamically drive this based up开发者_JAVA技巧on the content. So far I have tried the following code after I have recieved the SMS and filtered for my application:

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

which then calls the class

public class Notifier extends Activity{

public class Notifier extends Activity{        
    private int count;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
    }
    // Proven working Notification call

from this point I call a piece of notification code that I have tested and is working.

But when I run the above code I recieve an error so I have tried to debug with adb. When I run adb catlob I receive this error:

java.lang.RuntimeException: Unable to start receiver co m.mattwinder.android.gong.SmsReceiver: java.lang.IllegalStateException: System s ervices not available to Activities before onCreate()

Please help!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜