2011-07-26 4 views
0

내 요구 사항은 업로드가 가능할 때마다 알림을 표시해야합니다. 새로운 활동으로 이동할 때마다 &가 업로드를 사용할 수 있는지 확인합니다. (업로드 의미 : Android DB에 변경 사항이있는 경우, 실제 SQL 서버에 업로드 db). 이 바의 상단에 표시되지 않은 내 코드에서안드로이드 알림

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