Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 14th, 2012  |  syntax: None  |  size: 1.09 KB  |  views: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package com.disp;
  2.  
  3.  
  4. import android.app.Activity;
  5. import android.app.Notification;
  6. import android.app.NotificationManager;
  7. import android.content.Context;
  8. import android.os.Bundle;
  9. import android.os.SystemClock;
  10.  
  11. public class DispalyActivity extends Activity {
  12.     @Override
  13.     public void onCreate(Bundle savedInstanceState) {
  14.         super.onCreate(savedInstanceState);
  15.         setContentView(R.layout.main);
  16.  
  17.         for (int i = 0; i < 100; i++) {
  18.             SystemClock.sleep(300);
  19.             displaymessage(""+i+"%");
  20.  
  21.         }
  22.     }
  23.  
  24.     public void displaymessage(String string) {
  25.         String ns = Context.NOTIFICATION_SERVICE;
  26.         NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
  27.         Notification notification = new Notification(R.drawable.ic_launcher, "Notification Service", System.currentTimeMillis());
  28.         Context context = getApplicationContext();
  29.         notification.setLatestEventInfo(context, "Downloading Content:", string, null);
  30.         final int HELLO_ID = 2;
  31.         mNotificationManager.notify(HELLO_ID, notification);
  32.  
  33.     }
  34. }
clone this paste RAW Paste Data