Press on the image to return to the main documentation page.
CustomNotification
Written by Barx
List of types:
CustomNotification
CustomNotification
This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
Permissions:
android.permission.VIBRATE
Events:
None
Members:
AlertOnce
As
Boolean
[write
only]
AutoCancel
As
Boolean
[write
only]
Cancel
(
Id
As
Int
)
DefaultLED
As
Boolean
[write
only]
DefaultSound
As
Boolean
[write
only]
DefaultVibrate
As
Boolean
[write
only]
Initialize
(
Layout
As
Int
)
Insistent
As
Boolean
[write
only]
IsInitialized
As
Boolean
NoClear
As
Boolean
[write
only]
Notify
(
Id
As
Int
)
Number
As
Int
OnGoingEvent
As
Boolean
[write
only]
setCustomLED
(
LightOn
As
Int
,
LightOff
As
Int
)
SetCustomSound
(
path
As
String
)
SetCustomVibrate
(
Values
()
As
Long
)
setIcon
(
FileName
As
String
)
SetImage
(
id
As
String
,
Image
As
android
.
graphics
.
Bitmap
)
SetIntent
(
Activity
As
Object
)
SetProgress
(
id
As
String
,
maxProgress
As
Int
,
progress
As
Int
,
indeterminate
As
Boolean
)
SetTag
(
Tag
As
String
)
SetText
(
id
As
String
,
text
As
String
)
SetTextColor
(
id
As
String
,
Color
As
Int
)
SetTextSize
(
id
As
String
,
Value
As
Int
)
TickerText
As
String
[write
only]
When
As
Long
Members description:
AlertOnce
As
Boolean
[write
only]
Sets whether the notification sound and/or vibration should sound each time the notification is sent, even if it has not been cancelled before.
AutoCancel
As
Boolean
[write
only]
Sets whether the notification will be cancelled automatically when the user click on it
Cancel
(
Id
As
Int
)
Cancels the notification with the given Id
DefaultLED
As
Boolean
[write
only]
Sets whether the notification will Flash the LED (if available) using the Default settings.
NOTE: Setting to True will over rule the CustomLED
Example:
n.DefaultLED = False
DefaultSound
As
Boolean
[write
only]
Sets whether the notification will play a sound using the default settings
Example:
n.DefaultSound = True
DefaultVibrate
As
Boolean
[write
only]
Sets whether the notification will vibrate using the default settings
NOTE: Setting to True will overrule the CustomVibrate
Example:
n.DefaultVibrate = True
Initialize
(
Layout
As
Int
)
Initializes the notification setting default values of:
LED = Enabled
Sound = Enabled
Vibration = Enabled
Layout - Sets the layout to be used.
Options:
1 = Default notification layout (Two Text fields plus Icon)
2 = Two Text fields plus One Image
3 = One Text field plus One Image plus One Progress Bar
4 = Two Text fields ONLY
5 = User Defined. Add your xml file to the res/layout. Name it mylayout.xml and make it read only.
Example:
cn.Initialize(2) 'Initializes the notification and sets the layout to Two Text fields plus One Image
Insistent
As
Boolean
[write
only]
Sets whether the sound will play repeatedly until the user opens the notification screen
IsInitialized
As
Boolean
NoClear
As
Boolean
[write
only]
Sets whether the notification should NOT be cancelled when the user clicks the Clear All button.
Example:
Dim cn as CustomNotification
cn.NoClear = True 'Notification will not clear.
Notify
(
Id
As
Int
)
Displays the notification.
Id: - The notification Id. This can be used later to update the notification (by calling notify again with the same Id) or cancel it.
Number
As
Int
Gets or Sets a number that will be displayed over the icon. This is useful to represent multiple events in a single notification.
OnGoingEvent
As
Boolean
[write
only]
Set if the notification is in reference to an ongoing event, e.g. a phone call.
Do not set for notifications that are in reference to something that happened at a particular point in time.
setCustomLED
(
LightOn
As
Int
,
LightOff
As
Int
)
Set a custom timing for the notification Light.
Timings are in milliseconds.
NOTE: DefaultLED must be set to False.
Example:
Dim cn as CustomNotification
cn.DefaultLED = False
cn.CustomLED(300, 1000)
SetCustomSound
(
path
As
String
)
Sets a custom sound to be played on new notification
Example:
cn.CustomSound("file:///sdcard/notification/ringer.mp3")
SetCustomVibrate
(
Values
()
As
Long
)
Sets A custom vibrate sequence for notification Vibration
The Array of values can be as long as you wish.
The First Value is the pause before vibration starts, then it's ON, OFF, ON, OFF, etc.
NOTE: DefaultVibrate must be set to False
Example:
Dim cn as CustomNotification
Dim v() as Long
v = Array as Long(0, 100, 200, 300, 400)
cn.DefaultVibrate = False
cn.CustomVibrate(v)
setIcon
(
FileName
As
String
)
Sets the icon to be displayed.
The image file should manually copied to the Objects\res\drawable\ folder and set to read-only.
The file name is case sensitive and should not contain the file extension.
You can use "icon" to use the applications icon.
Example:
cn.Icon("icon")
SetImage
(
id
As
String
,
Image
As
android
.
graphics
.
Bitmap
)
Sets image used in a notification. Only use with "twotextsplusimage" and "onetextplusimageplusprogress" Presets or if defined as part of a user defined layout.
For Preset layout the id is "image".
SetIntent
(
Activity
As
Object
)
Sets the Activity that is called when the user clicks the notification
Example:
cn.Activity(Main)
SetProgress
(
id
As
String
,
maxProgress
As
Int
,
progress
As
Int
,
indeterminate
As
Boolean
)
Sets the parameters for a progress bar used in a notification. Only use with "onetextplusprogress" Preset or if defined as part of a user defined layout.
For Preset layout the id is "progress".
maxProgress - the upper limit of the progress bar. A good value is 100
progress - the current level of progress to be shown. Must be <= maxProgress.
SetTag
(
Tag
As
String
)
The Tag is a string that can be extracted later on Activity_Resume.
This can be used to determine which notification has been clicked by the user when multiple notifications exist.
Example of extracting the Tag:
Sub Activity_Resume
Dim in as Intent
Dim intentExtra as String
in = Activity.GetStartingIntent
If in.HasExtra("Notification_Tag") Then
intentExtra = in.GetExtra("Notification_Tag")
End If
End Sub
SetText
(
id
As
String
,
text
As
String
)
Sets the content of text items for the notification
For Preset Layouts the id's are "title" and "text".
Example:
cn.SetText("title", "New notification")
cn.SetText("text", "You have a new notification")
SetTextColor
(
id
As
String
,
Color
As
Int
)
Sets the Color of a text item.
For Preset Layouts the id's are "title" and "text".
Example:
cn.SetText("title", "New notification")
cn.SetTextColor("title", Colors.Red)
SetTextSize
(
id
As
String
,
Value
As
Int
)
Sets the text size of a text item.
For Preset Layouts the id's are "title" and "text".
Example:
cn.SetText("title", "New notification")
cn.SetTextSize("title", 20)
TickerText
As
String
[write
only]
Sets the Ticker Text which shows along side the status bar icon on new notification.
Example:
cn.TickerText = "New notification"
When
As
Long
Note: Experimental Feature
The offical description of this method is -
The timestamp for the notification.
Setting this to the max Value for a long (9,223,372,036,854,775,807) pushes the Notification Icon to the right.
Top