Android examples for User Interface:ProgressDialog
progress Notification
//package com.java2s; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat.Builder; public class Main { static private void progressNotification(Context c, int notifyid, String t, String m, boolean isFinished, double progress, String filePath) {/* w ww.j a v a2 s . c o m*/ Builder bd = new NotificationCompat.Builder(c).setTicker(t) .setContentTitle(t).setAutoCancel(true); PendingIntent pi = null; int prg = (int) (100 * progress); if (isFinished) { bd.setSmallIcon(android.R.drawable.stat_sys_download_done); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); pi = PendingIntent.getActivity(c, notifyid, intent, PendingIntent.FLAG_UPDATE_CURRENT | Intent.FLAG_ACTIVITY_NEW_TASK); if (m == null) m = progress >= 1.0 ? "?????" : "????"; } else { bd.setSmallIcon(android.R.drawable.stat_sys_download); if (m == null) m = prg + "%"; } bd.setProgress(100, prg, false); bd.setContentText(m); if (pi != null) bd.setContentIntent(pi); bd.setWhen(System.currentTimeMillis()); NotificationManager nm = (NotificationManager) c .getSystemService(Context.NOTIFICATION_SERVICE); //int defaults = Notification.DEFAULT_VIBRATE; //defaults |= Notification.DEFAULT_SOUND; //bd.setDefaults(defaults); Notification nf = bd.build(); if (!isFinished) nf.flags = Notification.FLAG_NO_CLEAR; nm.notify(notifyid, nf); } }