package net.snclab.lednotificationcontrol;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.graphics.Color;
import android.support.v4.app.NotificationCompat;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.BA;
@ShortName("LedNotificationControl")
@Author("FabioG")
@Version(1.0f)
public class LedNotificationControl {
private static final String Icon = null;
private Context mContext = BA.applicationContext;
NotificationCompat.Builder builder;
NotificationManager nm = ( NotificationManager ) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notif = new Notification();
/**
* A, B, R,G and B is ARGB Colors
* TimeOutONms is the Timeout for Led On in Milliseconds
* TimeOutOFFms is the Timeout for Led Off in Milliseconds
* NOTIFY_ID is the ID for the Notification
**/
public void LedFlashColor(int A, int R, int G, int B, int TimeOutONms, int TimeOutOFFms, int NOTIFY_ID)
{
notif.ledARGB = Color.argb(A, R, G, B);
notif.flags = Notification.FLAG_SHOW_LIGHTS;
notif.ledOnMS = TimeOutONms;
notif.ledOffMS = TimeOutOFFms;
nm.notify(NOTIFY_ID, notif);
}
public void ClearLED(int NOTIFY_ID)
{
NotificationManager nm = ( NotificationManager ) mContext.getSystemService( Context.NOTIFICATION_SERVICE );
nm.cancel(NOTIFY_ID);
}
public void StartIconNotify()
{
builder.setContentTitle("Notification")
.setContentText("ContentText")
.setTicker("TickerText")
.setSmallIcon(BA.applicationContext.getResources().getIdentifier(Icon, "drawable", BA.packageName))
.setWhen(System.currentTimeMillis());
nm.notify(1, builder.build());
}
}