2011-07-26 38 views
0

我的要求是需要显示通知,当上传available.Each &每次去新的活动,它检查上传可用(上传的意思:如果有任何变化的Android分贝发生了,那么它表明需要上传到实际的SQL Server DB)。Android通知

见我的代码:

uploadSize = new UploadActivity().getUploadTable(); 
    if(uploadSize > 0){ 
     Button button = (Button) findViewById(R.id.u); 
     button.setBackgroundColor(Color.RED); 

     long whenTo = System.currentTimeMillis(); 
     Notification n = new Notification(R.drawable.icon, "", whenTo); 
     n.tickerText = "TV Spored ++"; 

     String contentTitle = "I am expanded title"; 
     String contentText = "I am expanded text"; 
     Intent intent = new Intent(this, NotificationReceiver.class); 
     // Put additional stuff into the created intent 
     PendingIntent contentIntent = PendingIntent.getActivity(this, 1, intent, 1); 
     n.setLatestEventInfo(this, contentTitle, contentText, contentIntent); 
    } 

从我的代码,

  1. 它并没有显示在栏的顶部。
  2. 有没有什么好的解决方案是可供上传。

请帮助我..

在此先感谢。

是否有任何

回答

1

要显示通知调用此方法

private void triggerNotification(String s) { 
     CharSequence title = "Hello"; 
     CharSequence message = s; 
     NotificationManager notificationManager; 
     notificationManager = (NotificationManager) context 
       .getSystemService("notification"); 
     Notification notification; 
       notification = new Notification(R.drawable.icon, "", whenTo); 

     // Intent notificationIntent = new 
     // Intent(android.content.Intent.ACTION_VIEW, null, context, 
     // NotificationBariconExmp.class); 
     PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, 
       null, 0); 

     notification.setLatestEventInfo(context, title, message, pendingIntent); 
     notificationManager.notify(1010, notification); 

    } 
+0

非常感谢你。它的做工精细 – Piraba

+0

欢迎您 – Rasel