2011-07-26 59 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