2016-06-14 65 views
1

我创建了一个使用语言环境通知的应用程序。为了设置通知,将对后端进行调用,并返回要设置的通知列表。我创建了一个遍历此列表的循环,并逐个设置通知。我注意到它几乎需要一秒钟才能设置通知。这是我设置通知时调用的功能:我们可以加快按区域设置通知ANE的通知吗?

public function sendNotification(title:String, body:String, delay:int, id:int, tickerText:String, data:String, alertAction:String = "") : void 
    { 
     if (Notifications.isSupported) 
     { 
      Notifications.service.notify(
       new NotificationBuilder() 
       .setId(id) 
       .setDelay(delay) 
       .setAlert(tickerText) 
       .setTitle(title) 
       .setSound("sound/trigger") 
       .enableVibration(false) 
       .setCount(1) 
       .setBody(body) 
       .setPayload(data) 
       .build() 
      ); 
     } 
    } 

是否可以加快速度?也许是一批?

+0

您使用的是最新版本?我想我们在最近的构建中加速了这个调用? – Michael

+0

这将是多久?我有一个版本从2016年5月19日,03:05 – APvG

回答

1

试试这个:

NotificationManager mNotificationManager = 
        (NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); 

public void createSimpleNotification(Context context) { 
     if (Build.VERSION.SDK_INT < 16) 
      return; 
     Intent resultIntent = null; 
      resultIntent = new Intent(context, LauncherActivity.class); 
     TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); 
     stackBuilder.addParentStack(SplashActivity.class); 
     stackBuilder.addNextIntent(resultIntent); 
     PendingIntent resultPending = stackBuilder 
       .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); 
     Bundle bundle = new Bundle(); 
     bundle.putString(Constants.DATA, "Your data"); 
     resultIntent.putExtra(Constants.DATA, bundle); 
     Notification.Builder mBuilder = new Notification.Builder(context) 
       .setSmallIcon(R.mipmap.ic_launcher) // notification icon 
       .setContentTitle("Title") // main title of the notification 
       .setStyle(new Notification.BigTextStyle().bigText("Hello, how are you")) 
       .setAutoCancel(true) 
       .setContentText("Hello everyone") // notification text 
       .setContentIntent(resultPending); // notification intent 
     mNotificationManager.notify(1, mBuilder.build()); 
    } 

希望它会帮助你:)

+0

感谢您的回答。我没有说清楚,对不起。通知ANE用于Adobe Air(as3)。 – APvG

相关问题