Android: show notification bar on downloading application

前端 未结 2 1199
一整个雨季
一整个雨季 2020-12-06 15:34

I want to show a notification bar when an application is being downloaded in Android. I want the bar to be the same as the one showed when an application is downloaded from

2条回答
  •  广开言路
    2020-12-06 16:21

    Try this code for Notification Bar

    void showProgress(String file_path){
            dialog = new Dialog(DownloadFileDemo1.this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.myprogressdialog);
            dialog.setTitle("Download Progress");
    
            TextView text = (TextView) dialog.findViewById(R.id.tv1);
            text.setText("Downloading file from ... " + file_path);
            cur_val = (TextView) dialog.findViewById(R.id.cur_pg_tv);
            cur_val.setText("Starting download...");
            dialog.show();
    
            pb = (ProgressBar)dialog.findViewById(R.id.progress_bar);
            pb.setProgress(0);
            pb.setProgressDrawable(getResources().getDrawable(R.drawable.green_progress));
        }
    

提交回复
热议问题