List of usage examples for android.app DownloadManager PAUSED_QUEUED_FOR_WIFI
int PAUSED_QUEUED_FOR_WIFI
To view the source code for android.app DownloadManager PAUSED_QUEUED_FOR_WIFI.
Click Source Link
From source file:Main.java
public static void CheckDwnloadStatus(DownloadManager downloadManager, Activity activity, long id) { // TODO Auto-generated method stub DownloadManager.Query query = new DownloadManager.Query(); query.setFilterById(id);//from ww w . java2 s.co m Cursor cursor = downloadManager.query(query); if (cursor.moveToFirst()) { int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS); int status = cursor.getInt(columnIndex); int columnReason = cursor.getColumnIndex(DownloadManager.COLUMN_REASON); int reason = cursor.getInt(columnReason); switch (status) { case DownloadManager.STATUS_FAILED: String failedReason = ""; switch (reason) { case DownloadManager.ERROR_CANNOT_RESUME: failedReason = "ERROR_CANNOT_RESUME"; break; case DownloadManager.ERROR_DEVICE_NOT_FOUND: failedReason = "ERROR_DEVICE_NOT_FOUND"; break; case DownloadManager.ERROR_FILE_ALREADY_EXISTS: failedReason = "ERROR_FILE_ALREADY_EXISTS"; break; case DownloadManager.ERROR_FILE_ERROR: failedReason = "ERROR_FILE_ERROR"; break; case DownloadManager.ERROR_HTTP_DATA_ERROR: failedReason = "ERROR_HTTP_DATA_ERROR"; break; case DownloadManager.ERROR_INSUFFICIENT_SPACE: failedReason = "ERROR_INSUFFICIENT_SPACE"; break; case DownloadManager.ERROR_TOO_MANY_REDIRECTS: failedReason = "ERROR_TOO_MANY_REDIRECTS"; break; case DownloadManager.ERROR_UNHANDLED_HTTP_CODE: failedReason = "ERROR_UNHANDLED_HTTP_CODE"; break; case DownloadManager.ERROR_UNKNOWN: failedReason = "ERROR_UNKNOWN"; break; default: failedReason = "unknown reason"; break; } Toast.makeText(activity, "FAILED: " + failedReason, Toast.LENGTH_LONG).show(); break; case DownloadManager.STATUS_PAUSED: String pausedReason = ""; switch (reason) { case DownloadManager.PAUSED_QUEUED_FOR_WIFI: pausedReason = "PAUSED_QUEUED_FOR_WIFI"; break; case DownloadManager.PAUSED_UNKNOWN: pausedReason = "PAUSED_UNKNOWN"; break; case DownloadManager.PAUSED_WAITING_FOR_NETWORK: pausedReason = "PAUSED_WAITING_FOR_NETWORK"; break; case DownloadManager.PAUSED_WAITING_TO_RETRY: pausedReason = "PAUSED_WAITING_TO_RETRY"; break; } Toast.makeText(activity, "PAUSED: " + pausedReason, Toast.LENGTH_LONG).show(); break; case DownloadManager.STATUS_PENDING: Toast.makeText(activity, "PENDING", Toast.LENGTH_LONG).show(); break; case DownloadManager.STATUS_RUNNING: Toast.makeText(activity, "RUNNING", Toast.LENGTH_LONG).show(); break; case DownloadManager.STATUS_SUCCESSFUL: Toast.makeText(activity, "SUCCESSFUL", Toast.LENGTH_LONG).show(); break; } } }
From source file:com.dvdprime.mobile.android.ui.DocumentViewActivity.java
@Override public boolean onContextItemSelected(android.view.MenuItem menuItem) { switch (menuItem.getItemId()) { default:/*from w w w . j a v a2s.c o m*/ case CONTEXT_MENU_COPY_URL: SystemUtil.copyToClipboard(mActivity, contextUrl); break; case CONTEXT_MENU_BROWSER: AndroidUtil.clickedLinkAction(mActivity, contextUrl); break; case CONTEXT_MENU_SHARE_LINK: Intent localIntent = new Intent("android.intent.action.SEND"); localIntent.setType("text/plain"); localIntent.putExtra("android.intent.extra.TEXT", contextUrl); startActivity(Intent.createChooser(localIntent, getString(R.string.action_bar_share_with))); break; case CONTEXT_MENU_SAVE_IMAGE: DownloadManager dm = (DownloadManager) getSystemService("download"); DownloadManager.Request req = new DownloadManager.Request(Uri.parse(this.contextUrl)); req.setTitle("DP Downloader"); req.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, StringUtil.substringAfterLast(this.contextUrl, "/")); req.setAllowedNetworkTypes(DownloadManager.PAUSED_QUEUED_FOR_WIFI); req.setMimeType("image/" + StringUtil.substringAfterLast(contextUrl, ".")); File localFile = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); if (!(localFile.exists())) localFile.mkdirs(); dm.enqueue(req); break; } return false; }
From source file:se.bitcraze.crazyfliecontrol.bootloader.FirmwareDownloader.java
public String getReasonString(int reason) { String reasonText = ""; switch (reason) { case DownloadManager.ERROR_CANNOT_RESUME: reasonText = "ERROR_CANNOT_RESUME"; break;// ww w .ja va 2s . c o m case DownloadManager.ERROR_DEVICE_NOT_FOUND: reasonText = "ERROR_DEVICE_NOT_FOUND"; break; case DownloadManager.ERROR_FILE_ALREADY_EXISTS: reasonText = "ERROR_FILE_ALREADY_EXISTS"; break; case DownloadManager.ERROR_FILE_ERROR: reasonText = "ERROR_FILE_ERROR"; break; case DownloadManager.ERROR_HTTP_DATA_ERROR: reasonText = "ERROR_HTTP_DATA_ERROR"; break; case DownloadManager.ERROR_INSUFFICIENT_SPACE: reasonText = "ERROR_INSUFFICIENT_SPACE"; break; case DownloadManager.ERROR_TOO_MANY_REDIRECTS: reasonText = "ERROR_TOO_MANY_REDIRECTS"; break; case DownloadManager.ERROR_UNHANDLED_HTTP_CODE: reasonText = "ERROR_UNHANDLED_HTTP_CODE"; break; case DownloadManager.ERROR_UNKNOWN: reasonText = "ERROR_UNKNOWN"; break; case DownloadManager.PAUSED_QUEUED_FOR_WIFI: reasonText = "PAUSED_QUEUED_FOR_WIFI"; break; case DownloadManager.PAUSED_UNKNOWN: reasonText = "PAUSED_UNKNOWN"; break; case DownloadManager.PAUSED_WAITING_FOR_NETWORK: reasonText = "PAUSED_WAITING_FOR_NETWORK"; break; case DownloadManager.PAUSED_WAITING_TO_RETRY: reasonText = "PAUSED_WAITING_TO_RETRY"; break; case 404: reasonText = "404 - NOT FOUND"; break; case 403: reasonText = "403 - FORBIDDEN"; break; case 401: reasonText = "401 - UNAUTHORIZED"; break; case 500: reasonText = "500 - INTERNAL SERVER ERROR"; break; case 503: reasonText = "503 - SERVICE UNAVAILABLE"; break; default: reasonText = "" + reason; break; } return reasonText; }