@Override protected void onPreExecute() { super.onPreExecute(); Notification.Builder builder = new Notification.Builder(SendWeiboService.this) .setTicker(getString(R.string.sending)) .setContentTitle(getString(R.string.sending)) .setContentText(content) .setOnlyAlertOnce(true) .setOngoing(true) .setSmallIcon(R.drawable.upload_white); if (!TextUtils.isEmpty(picPath)) { builder.setProgress(0, 100, false); } else { builder.setProgress(0, 100, true); } notification = builder.getNotification(); int notificationId = new Random().nextInt(Integer.MAX_VALUE); NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(notificationId, notification); tasksNotifications.put(WeiboSendTask.this, notificationId); Toast.makeText( SendWeiboService.this, getString(R.string.background_sending), Toast.LENGTH_SHORT) .show(); }
@Override protected void onPreExecute() { super.onPreExecute(); }