Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
132 views
in Technique[技术] by (71.8m points)

Download by ADM download manager in Android Studio

I looked for a code and did not find it, so I decided to ask a question. I want to put a download Button in my application and when the user clicks on it, the ADM download manager application will open and the link will be inserted automatically and the download will start. I found the following code, but this code only copies the da link in the clipboard, and the user has to put the da link in the app himself. I want this to be done automatically.

                boolean isAppInstalled = appInstalledOrNot("com.dv.adm");

            SharedPreferences prfs = getSharedPreferences("AUTHENTICATION_FILE_NAME", Context.MODE_PRIVATE);
            String url = prfs.getString("url", "");

            ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("download link", url);
            clipboard.setPrimaryClip(clip);

            if (isAppInstalled) {
                //This intent will help you to launch if the package is already installed
                Intent LaunchIntent = getPackageManager()
                        .getLaunchIntentForPackage("com.dv.adm");
                startActivity(LaunchIntent);
                Toast.makeText(MovieActivity.this, "The download link was copied to your clipboard.", Toast.LENGTH_SHORT).show();

            } else {
                Toast.makeText(MovieActivity.this, "ADM is not installed", Toast.LENGTH_SHORT).show();
            }
question from:https://stackoverflow.com/questions/65546096/download-by-adm-download-manager-in-android-studio

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...