Techiio-author
Started by Bradley ReidNov 6, 2021

Open
Download Manager did not work when APN is ON

0 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWES SHARE

I have this technique in my application and it is work quality however at android 11(Xiaomi) whilst APN is on it is now not running. In debug mode, the whole thing turns and does not "thunder", however, the document simply does not download. Additionally, the receiver didn't get a hold of the download reference. And all that is happened handiest whilst APN is on. I think that and settings are good enough due to the fact I have communication whit, my WCF provider.

public void showUpdatePromtDialog() {
     AlertDialog.Builder builder = new AlertDialog.Builder(OrmBaseActivity.this);
      builder.setMessage("Налична е нова версия на приложението. За да продължите работа 
       трябва да го обновите сега. Натиснете бутон 'Обнови' за да продължите.")
      .setCancelable(false)
      .setPositiveButton("Обнови", new DialogInterface.OnClickListener() {
       //if the user agrees to upgrade
       public void onClick(DialogInterface dialog, int id) {
        try {
        
            
            //deletes old APKs in the directory
            File dir = new File(OrmBaseActivity.this.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)+""); 
        
            if (dir.isDirectory()) 
            {
                String[] children = dir.list();
                for (int i = 0; i < children.length; i++)
                {
                   new File(dir, children[i]).delete();
                }
            }
            
            //start downloading the file using the download manager
            downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
            String url = getURL().replace("myServices.svc", "");
            Uri Download_Uri = Uri.parse(url + "ApkLatestVersion/myFile.apk");
            DownloadManager.Request request = new DownloadManager.Request(Download_Uri);
            /*request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
            request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE);*/
            request.setAllowedOverRoaming(false);
            request.setTitle("myAPP App Download");
            request.setDestinationInExternalFilesDir(OrmBaseActivity.this, Environment.DIRECTORY_DOWNLOADS,"myFile.apk");
            
           downloadReference = downloadManager.enqueue(request);
           
        } catch (Exception e) {
            e.printStackTrace();
            dialog.dismiss();
            Toast.makeText(OrmBaseActivity.this, "Възникна грешка. Моля, опитайте отново.", Toast.LENGTH_SHORT).show();
        }
        
       }
      });
      /*.setNegativeButton("За по-късно", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int id) {
        // User cancelled the dialog
       }
      });*/
      //show the alert message
      builder.create().show();
}

0 Replies

You must be Logged in to reply
Trending Technologies
15
Software91
DevOps48
Frontend Development24
Backend Development20
Server Administration17
Linux Administration28
Data Center24
Sentry24
Terraform23
Ansible83
Docker70
Penetration Testing16
Kubernetes21
NGINX20
JenkinsX17
Recommended Blogs
1
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance