本文整理匯總了Java中android.app.DownloadManager.ERROR_INSUFFICIENT_SPACE屬性的典型用法代碼示例。如果您正苦於以下問題:Java DownloadManager.ERROR_INSUFFICIENT_SPACE屬性的具體用法?Java DownloadManager.ERROR_INSUFFICIENT_SPACE怎麽用?Java DownloadManager.ERROR_INSUFFICIENT_SPACE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.app.DownloadManager
的用法示例。
在下文中一共展示了DownloadManager.ERROR_INSUFFICIENT_SPACE屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getHentetStatus
public HentetStatus getHentetStatus(Udsendelse udsendelse) {
if (!virker()) return null;
tjekDataOprettet();
HentetStatus hs = data.hentetStatusFraSlug.get(udsendelse.slug);
if (hs != null && (hs.status==DownloadManager.STATUS_SUCCESSFUL || hs.status == DownloadManager.STATUS_FAILED)) {
hs.statustekst = lavStatustekst(hs);
return hs;
}
Long downloadId = data.downloadIdFraSlug.get(udsendelse.slug);
if (downloadId == null) return null;
DownloadManager.Query query = new DownloadManager.Query();
query.setFilterById(downloadId);
Cursor c = downloadService.query(query);
if (c==null) return null; // fix for https://mint.splunk.com/dashboard/project/cd78aa05/errors/4066198043
if (!c.moveToFirst()) {
c.close();
return null;
}
if (hs == null) {
hs = new HentetStatus();
data.hentetStatusFraSlug.put(udsendelse.slug, hs);
}
hs.status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
hs.iAlt = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)) / 1000000;
hs.hentet = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)) / 1000000;
hs.startUri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
hs.statustekst = lavStatustekst(hs);
if (hs.status==DownloadManager.STATUS_FAILED || hs.status==DownloadManager.STATUS_PAUSED) {
int grund = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
Log.d(udsendelse.slug+ " hs.grund til fejl "+ grund);
if (grund==DownloadManager.ERROR_INSUFFICIENT_SPACE) hs.statustekst += " - Ikke nok plads";
}
c.close();
//if (!App.PRODUKTION) hs.statustekst+="\n"+hs.startUri+"\n"+hs.destinationFil; // til fejlfinding
return hs;
}
示例2: getDownloadFailureMessage
/**
* Get the message to display when a download fails.
*
* @param fileName Name of the download file.
* @param reason Reason of failure reported by android DownloadManager.
*/
private String getDownloadFailureMessage(String fileName, int reason) {
switch (reason) {
case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
return mContext.getString(
R.string.download_failed_reason_file_already_exists, fileName);
case DownloadManager.ERROR_FILE_ERROR:
return mContext.getString(
R.string.download_failed_reason_file_system_error, fileName);
case DownloadManager.ERROR_INSUFFICIENT_SPACE:
return mContext.getString(
R.string.download_failed_reason_insufficient_space, fileName);
case DownloadManager.ERROR_CANNOT_RESUME:
case DownloadManager.ERROR_HTTP_DATA_ERROR:
return mContext.getString(
R.string.download_failed_reason_network_failures, fileName);
case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
return mContext.getString(
R.string.download_failed_reason_server_issues, fileName);
case DownloadManager.ERROR_DEVICE_NOT_FOUND:
return mContext.getString(
R.string.download_failed_reason_storage_not_found, fileName);
case DownloadManager.ERROR_UNKNOWN:
default:
return mContext.getString(
R.string.download_failed_reason_unknown_error, fileName);
}
}
示例3: onDownloadFailed
/**
* Called when android DownloadManager fails to download the content.
*
* @param downloadInfo The information about the download.
* @param downloadId Download Id from the Android DownloadManager.
* @param reason The reason of failure.
* @param notifyURI The previously saved installNotifyURI attribute.
*/
public void onDownloadFailed(
DownloadInfo downloadInfo, long downloadId, int reason, String notifyURI) {
String status = DOWNLOAD_STATUS_DEVICE_ABORTED;
switch (reason) {
case DownloadManager.ERROR_CANNOT_RESUME:
status = DOWNLOAD_STATUS_LOSS_OF_SERVICE;
break;
case DownloadManager.ERROR_HTTP_DATA_ERROR:
case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
status = DOWNLOAD_STATUS_LOADER_ERROR;
break;
case DownloadManager.ERROR_INSUFFICIENT_SPACE:
status = DOWNLOAD_STATUS_INSUFFICIENT_MEMORY;
break;
default:
break;
}
OMAInfo omaInfo = mPendingOMADownloads.get(downloadId);
if (omaInfo == null) {
// Just send the notification in this case.
omaInfo = new OMAInfo();
omaInfo.addAttributeValue(OMA_INSTALL_NOTIFY_URI, notifyURI);
sendInstallNotificationAndNextStep(omaInfo, downloadInfo, downloadId, status);
return;
}
showDownloadWarningDialog(
R.string.oma_download_failed, omaInfo, downloadInfo, status);
mPendingOMADownloads.remove(downloadId);
}
示例4: getReasonDebugString
public static String getReasonDebugString(int status, int reason) {
String reasonText = "unKnown_status";
switch (status) {
case DownloadManager.STATUS_FAILED:
switch (reason) {
case DownloadManager.ERROR_CANNOT_RESUME:
reasonText = "ERROR_CANNOT_RESUME";
break;
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;
}
break;
case DownloadManager.STATUS_PAUSED: {
switch (reason) {
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;
}
break;
}
}
return reasonText;
}
示例5: getReasonTextResId
@StringRes
public static int getReasonTextResId(int status, int reason) {
int reasonText = R.string.unKnown_status;
switch (status) {
case DownloadManager.STATUS_FAILED:
switch (reason) {
case DownloadManager.ERROR_CANNOT_RESUME:
reasonText = R.string.ERROR_CANNOT_RESUME;
break;
case DownloadManager.ERROR_DEVICE_NOT_FOUND:
reasonText = (R.string.ERROR_DEVICE_NOT_FOUND);
break;
case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
reasonText = (R.string.ERROR_FILE_ALREADY_EXISTS);
break;
case DownloadManager.ERROR_FILE_ERROR:
reasonText = (R.string.ERROR_FILE_ERROR);
break;
case DownloadManager.ERROR_HTTP_DATA_ERROR:
reasonText = (R.string.ERROR_HTTP_DATA_ERROR);
break;
case DownloadManager.ERROR_INSUFFICIENT_SPACE:
reasonText = (R.string.ERROR_INSUFFICIENT_SPACE);
break;
case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
reasonText = (R.string.ERROR_TOO_MANY_REDIRECTS);
break;
case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
reasonText = (R.string.ERROR_UNHANDLED_HTTP_CODE);
break;
case DownloadManager.ERROR_UNKNOWN:
reasonText = (R.string.ERROR_UNKNOWN);
break;
}
break;
case DownloadManager.STATUS_PAUSED: {
switch (reason) {
case DownloadManager.PAUSED_QUEUED_FOR_WIFI:
reasonText = (R.string.PAUSED_QUEUED_FOR_WIFI);
break;
case DownloadManager.PAUSED_UNKNOWN:
reasonText = (R.string.PAUSED_UNKNOWN);
break;
case DownloadManager.PAUSED_WAITING_FOR_NETWORK:
reasonText = (R.string.PAUSED_WAITING_FOR_NETWORK);
break;
case DownloadManager.PAUSED_WAITING_TO_RETRY:
reasonText = (R.string.PAUSED_WAITING_TO_RETRY);
break;
}
break;
}
}
return reasonText;
}
示例6: onReceive
/**
* {@inheritDoc}
*/
@Override
public void onReceive(Context context, Intent intent) {
try {
//Check if the broadcast message is for our enqueued download
long referenceId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
if (referenceId == this.currentDicoDownloadReference) {
DownloadManager downloadManager = (DownloadManager) context.getSystemService(context.DOWNLOAD_SERVICE);
//Retrieve the status of the downloaded file
DownloadManager.Query downloadQuery = new DownloadManager.Query();
//Set the query filter to our previously Enqueued download
downloadQuery.setFilterById(this.currentDicoDownloadReference);
//Query the download manager about downloads that have been requested.
Cursor cursor = downloadManager.query(downloadQuery);
if (cursor.moveToFirst()) {
//Get the download status
int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS);
int status = cursor.getInt(columnIndex);
if (status == DownloadManager.STATUS_SUCCESSFUL) {
//Get the downloaded file path
columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI);
String filePath = cursor.getString(columnIndex);
//Send Intent to the Post download file processor Service
Intent downloadFileProcessIntent = new Intent(context, PostDownloadService.class);
downloadFileProcessIntent.putExtra(PostDownloadService.EXTRA_PARAM_DL_FILE_PATH, filePath);
downloadFileProcessIntent.putExtra(PostDownloadService.EXTRA_PARAM_TARGET_FILE_PATH, this.targetFilePath);
downloadFileProcessIntent.setAction(PostDownloadService.ACTION_DL_FILE_PROCESS);
context.startService(downloadFileProcessIntent);
NotificationUtil.sendNotification(context, "Dictionary download OK, pass to post processing...");
} else if (status == DownloadManager.STATUS_FAILED) {
//Get fail reason
String reasonText = "";
int columnReason = cursor.getColumnIndex(DownloadManager.COLUMN_REASON);
int reason = cursor.getInt(columnReason);
switch (reason) {
case DownloadManager.ERROR_CANNOT_RESUME:
reasonText = "ERROR_CANNOT_RESUME";
break;
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;
}
NotificationUtil.sendNotification(context, "Dictionary download fail for reason '" + reasonText + "' !");
}
}
}
} catch (Exception e) {
String msg = "Error during the download file processing: " + e.getMessage();
Log.e(MainActivity.LOG_TAG, msg, e);
NotificationUtil.sendNotification(context, msg);
}
}