i'm trying to count a notification from OneSignal, and make it display in the badge, but i still getting this error. What's wrong with my code?
public class HomeActivity extends AppCompatActivity implements NetworkBroadcastListener.iNetStats, iNotif {
Context context;
SharedPref spref;
TextView notif_badge;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
OneSignal.startInit(this).init();
setContentView(R.layout.activity_home);
notif_badge = findViewById(R.id.cart_badge);
setupBadge();
private void setupBadge() {
int counter = spref.GetInt(localPref.TOTALNOTIF);
context=this;
spref = new SharedPref(this);
notif_badge.setText(String.valueOf(Math.min(counter,99)));
}
Here is my OneSignal ReceiveHandler
public class NotifReceivedHandler implements OneSignal.NotificationReceivedHandler {
Context context;
SharedPref spref;
public NotifReceivedHandler(Context context){
this.context = context;
spref = new SharedPref(context);
}
@Override
public void notificationReceived(OSNotification notification) {
Intent intent = new Intent();
intent.setAction("com.x.x.NOTIFICATION");
intent.putExtra("body",notification.payload.body);
intent.putExtra("title",notification.payload.title);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
spref.AddInt(localPref.TOTALNOTIF,spref.GetInt(localPref.TOTALNOTIF)+1);
}
}