守望者--AIR技术交流

标题: Android-Notification 本机扩展 [打印本页]

作者: 破晓    时间: 2015-3-4 11:41
标题: Android-Notification 本机扩展
Android-Notification-Extension-ANE

Native Extension for Adobe AIR

Features:

  1. - toast
  2. - alert dialog (without buttons or with from 1 to 3 buttons)
  3. - list dialog (with any number of buttons)
复制代码
[attach]885[/attach]


Important! Be shure you are using latest version of AIR SDK. This ANE builded for 15.0.356How to use:Connect com.illuzor.extensions.NotificationExtension.ane file to your android air project. Imports: import com.illuzor.notificationextension.NotificationExtension; import com.illuzor.notificationextension.ToastDuration; import com.illuzor.notificationextension.ToastGravity;1) Toast:
  1. import com.illuzor.notificationextension.ToastDuration;

  2. NotificationExtension.showToast("Toast text");
  3. // or
  4. NotificationExtension.showToast("Toast text", ToastDuration.TOAST_SHORT);
  5. // or
  6. NotificationExtension.showToast("Toast text", ToastDuration.TOAST_LONG);
  7. // also you can add toast gravity:
  8. NotificationExtension.showToast("Toast text", ToastDuration.TOAST_LONG, ToastGravity.TOP) // or ToastGravity.BOTTOM, or ToastGravity.LEFT etc.
复制代码
2) Alert dialog:Example 1, Alert without buttons:
  1. import com.illuzor.notificationextension.AlertDialog;

  2. var alert:AlertDialog = NotificationExtension.getAlertDialog("Alert title", "Alert Message");
  3. alert.show();
复制代码
Example 2, Alert with OK button
  1. import com.illuzor.notificationextension.AlertDialog;
  2. import com.illuzor.notificationextension.AlertActionType;

  3. var alert:AlertDialog = NotificationExtension.getAlertDialog("Alert title", "Alert Message");
  4. alert.setButton(AlertActionType.NEUTRAL_BUTTON, "OK");
  5. alert.show();
复制代码
Example 3, Alert with three buttons with callback functions:
  1. import com.illuzor.notificationextension.AlertDialog;
  2. import com.illuzor.notificationextension.AlertActionType;

  3. var alert:AlertDialog = NotificationExtension.getAlertDialog("Alert title", "Alert Message");
  4. alert.setButton(AlertActionType.NEGATIVE_BUTTON, "Negative Button", button1Pressed);
  5. alert.setButton(AlertActionType.POSITIVE_BUTTOND, "Positive Button", button2Pressed);
  6. alert.setButton(AlertActionType.NEUTRAL_BUTTON, "Neutral Button", button3Pressed);
  7. alert.show();

  8. private function button1Pressed():void {
  9.     trace("Negative Button Pressed");
  10. }

  11. private function button2Pressed():void {
  12.     trace("Positive Button Pressed");
  13. }

  14. private function button3Pressed():void {
  15.     trace("Neutral Button Pressed");
  16. }
复制代码
You can add three buttons maximum with callback functions or without.Parameters:
  1. alert.title = "title";
  2. alert.message = "message";
  3. alert.cancelable = true;

  4. // also you can add callback function for cancel:

  5. alert.cancelFunction = cancelFunc;

  6. private function cancelFunc():void {
  7.     trace("Alert Canceled");
  8. }
复制代码
3) List Dialog:
  1. import com.illuzor.notificationextension.ListDialog;

  2. var dialog:ListDialog = NotificationExtension.getListDialog(titleText.text, cancelableBox.value);
  3. var buttonsNumber:uint = 5;

  4. for (var i:int = 0; i < buttonsNumber; i++) {
  5.     dialog.addButton("Button ".concat(i+1));
  6. }

  7. dialog.show();
  8. dialog.addEventListener(Event.SELECT, onSelected);

  9. private function onSelected(e:Event):void {
  10.     e.target.removeEventListener(Event.SELECT, onSelected);
  11.     trace("Button " + String(e.target.selectedID + 1) + " Pressed");
  12. }

  13. // you can add cancel callback function:
  14. dialog.cancelable = true;

  15. private function cancelFunc():void {
  16.     dialog.removeEventListener(Event.SELECT, onSelected);
  17.     trace("Dialog Canceled");
  18. }
复制代码
4) Dispose. If you don`t need extension after use, dispose it:
  1. NotificationExtension.dispose();
复制代码
Demo app - http://yadi.sk/d/Se_LR8fm1lgsD



[attach]886[/attach]


相关链接:
https://github.com/illuzor/Android-Notification-Extension-ANE






欢迎光临 守望者--AIR技术交流 (http://www.airmyth.com/)