My Android App has 3 different objects ( light, humidity, temperature) all these
ID: 3856253 • Letter: M
Question
My Android App has 3 different objects ( light, humidity, temperature) all these in separate classes and activities, as well as each object, has own data in Firebase
How to get Temperature notification for range and Humidity push notification for range if my Range class look like below:
public class Range implements Serializable f private String type; private double minRange, maxRange Default constructor public Range) this, type = " this. minRange = Double . NaN; this.maxRange = Double.NaN; A constructor which just accepts the ranges, mainly for testing aparam minRange The min range aparam maxRange The max range public Range (double minRange, double maxRange) this, type = " this. minRange = minRange; this. maxRange = maxRange; Constructor that sets type and range @param type The key and identifier. Light, Humidity, or Temperature aparam minRange The min range * @param maxRange The max range k/ public Range (String type, double minRange, double maxRange) f this. type = type; this. minRange = minRange; this. maxRange = maxRange;Explanation / Answer
Your question is little unclear, still am answering it.
You can have a method notify
void notify (){ if(isInRange())
NotificationManager notif=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Notification notify=new Notification.Builder (getApplicationContext()).setContentTitle(type).setContentText(type+ " is out of range").setContentTitle (type).setSmallIcon(R.drawable.abc).build();
notify.flags |= Notification.FLAG_AUTO_CANCEL;
notif.notify(0, notify);
}
You can call the notify method of range class and you will have notification
If you want exact code, please let me know. Note that and is drawable image u might need
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.