بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
نمایش توتیفیکیشن در پروژه دانلودر استاد
چطور میشه یک progress notification به پروژه دانلودر استاد اضافه کرد که همزمان با این که در progress bar پر میشه در نوتیفیکیشن هم این اتفاق بیفته ؟
این کد نوتفیکیشنش هست
final int notifyID = 1;
Intent intent = new Intent(this, ActivityTest.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationManager mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final Builder mBuilder = new NotificationCompat.Builder(this); mBuilder.setContentTitle("Picture Download")
.setContentText("Download in progress")
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setContentIntent(pendingIntent); // Start a lengthy operation in a background thread new Thread( new Runnable() { @Override public void run() { int incr; // Do the "lengthy" operation 20 times for (incr = 0; incr <= 100; incr += 5) { // Sets the progress indicator to a max value, the // current completion percentage, and "determinate" // state mBuilder.setProgress(100, incr, false); // Displays the progress bar for the first time. mNotifyManager.notify(1, mBuilder.build()); // Sleeps the thread, simulating an operation mBuilder.setOngoing(true); // that takes time try { // Sleep for 5 seconds Thread.sleep(500); } catch (InterruptedException e) {} } // When the loop is finished, updates the notification mBuilder.setContentText("Download complete") // Removes the progress bar .setProgress(0, 0, false).setOngoing(false); mNotifyManager.cancel(notifyID); mNotifyManager.notify(notifyID, mBuilder.build()); } } // Starts the thread by calling the run() method in its Runnable ).start();
برای این سوال پاسخی وجود ندارد.
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .