Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.disp;
- import android.app.Activity;
- import android.app.Notification;
- import android.app.NotificationManager;
- import android.content.Context;
- import android.os.Bundle;
- import android.os.SystemClock;
- public class DispalyActivity extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- for (int i = 0; i < 100; i++) {
- SystemClock.sleep(300);
- displaymessage(""+i+"%");
- }
- }
- public void displaymessage(String string) {
- String ns = Context.NOTIFICATION_SERVICE;
- NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
- Notification notification = new Notification(R.drawable.ic_launcher, "Notification Service", System.currentTimeMillis());
- Context context = getApplicationContext();
- notification.setLatestEventInfo(context, "Downloading Content:", string, null);
- final int HELLO_ID = 2;
- mNotificationManager.notify(HELLO_ID, notification);
- }
- }
Add Comment
Please, Sign In to add comment