Blog

Cách bật Trình quản lý tải xuống của Android | TaigameIOline

341

Hộp thư đến Google Gmail đã kiểm tra xem Trình quản lý tải xuống có bị vô hiệu hóa hay không, nếu đúng thì hiển thị AlertDialog để báo cho người dùng kích hoạt Trình quản lý tải xuống trong Cài đặt. Hiển thị ảnh chụp màn hình bên dưới:

enter image description here

Tôi đã viết một lớp có tên DownloadManagerResolver để sửa lỗi này, hy vọng điều này có thể giúp ích cho bạn. 🙂

public final class DownloadManagerResolver { private static final String DOWNLOAD_MANAGER_PACKAGE_NAME = “com.Android.providers.downloads”; /** * Resolve whether the DownloadManager is enable in current devices. * * @return true if DownloadManager is enable,false otherwise. */ public static boolean resolve(Context context) { boolean enable = resolveEnable(context); if (!enable) { AlertDialog alertDialog = createDialog(context); taigameionline.vn(); } return enable; } /** * Resolve whether the DownloadManager is enable in current devices. * * @param context * @return true if DownloadManager is enable,false otherwise. */ private static boolean resolveEnable(Context context) { int state = taigameionline.vnackageManager() .getApplicationEnabledSetting(DOWNLOAD_MANAGER_PACKAGE_NAME); if (Build.VERSION.SDK_INT > taigameionline.vnY_BEAN_MR2) { return !(state == taigameionline.vnONENT_ENABLED_STATE_DISABLED || state == taigameionline.vnONENT_ENABLED_STATE_DISABLED_USER || state == taigameionline.vnONENT_ENABLED_STATE_DISABLED_UNTIL_USED); } else { return !(state == taigameionline.vnONENT_ENABLED_STATE_DISABLED || state == taigameionline.vnONENT_ENABLED_STATE_DISABLED_USER); } } private static AlertDialog createDialog(final Context context) { AppCompatTextView messageTextView = new AppCompatTextView(context); taigameionline.vnextSize(16f); taigameionline.vnext(“DownloadManager is disabled. Please enable it.”); return new taigameionline.vnder(context) .setView(messageTextView, 50, 30, 50, 30) .setPositiveButton(“ok”, new taigameionline.vnickListener() { @Override public void onClick(DialogInterface dialog, int which) { enableDownloadManager(context); } }) .setCancelable(false) .create(); } /** * Start activity to Settings to enable DownloadManager. */ private static void enableDownloadManager(Context context) { try { //Open the specific App Info page: Intent intent = new Intent(Android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); taigameionline.vnata(Uri.parse(“package:” + DOWNLOAD_MANAGER_PACKAGE_NAME)); taigameionline.vntActivity(intent); } catch (ActivityNotFoundException e) { e.printStackTrace(); //Open the generic Apps page: Intent intent = new Intent(Android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); taigameionline.vntActivity(intent); } } }

0 ( 0 votes )

TaigameIOline

https://taigameionline.vn
TaigameIOline - Chia sẻ mọi thứ về Game, Phần Mềm, Thủ Thuật dành cho máy tính với những tin hay nhất và những thông tin kiến thức hỏi đáp.

Readers' opinions (0)

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Bài Viết Liên Quan

Bài Viết Mới

24/05/2023 19:41 34

24/05/2023 17:52 26

Load more