Android - creating a notification from SMS BroadcastReceiver

My program uses BroadcastReceiver to scan SMS (which works and can create toasts based on text content). But I would like this to trigger a notification (like those generated by the system, but I'm going to dynamically manage this based on the content. So far I have tried the following code after I received the SMS and filtered its 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

The public Notifier class extends the {

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

from now on, I name the part of the notification code that I tested and works.

But when I run the above code, I get an error, so I tried to debug using adb. When I run adb catlob, I get this error:

java.lang.RuntimeException: co m.mattwinder.android.gong.SmsReceiver: java.lang.IllegalStateException: System s ervices onCreate()

, !

+3

Source: https://habr.com/ru/post/1755086/


All Articles