DownloadService.java 文件源码

java
阅读 39 收藏 0 点赞 0 评论 0

项目:AndroidBookTest 作者:
private Notification getNotification(String title,int progress){
    Intent intent=new Intent(this,MainActivity.class);
    PendingIntent pi=PendingIntent.getActivity(this,0,intent,0);
    NotificationCompat.Builder builder=new NotificationCompat.Builder(this);
    builder.setSmallIcon(R.mipmap.ic_launcher);
    builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher));
    builder.setContentIntent(pi);
    builder.setContentTitle(title);
    if (progress>=0){
        //当progress大于等于0时才显示下载进度
        builder.setContentText(progress+"%");
        builder.setProgress(100,progress,false);
    }
    return  builder.build();

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号