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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…