Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.DownloadManager;

import android.database.Cursor;

public class Main {
    public static final String[] REASONLISTPAUSED = { "0", "Waiting to Retry", "Waiting for Network",
            "Queued for Wi-Fi", "Unknown", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" };
    public static final String[] REASONLISTFAILED = { "Unknown", "File Error", "Unhandled HTTP Code", "3",
            "HTTP Data Error", "Too Many Redirects", "Insufficient Space", "Storage Device Not Found",
            "Cannot Resume", "File Already Exists", "10", "11", "12", "13", "14", "15", "16" };

    public static String reasonString(Cursor c) {
        String msg = "???";

        //get reason index
        Integer statusint = statusInt(c);
        Integer reasonint = reasonInt(c);
        //interpret reason index depending on status
        if (statusint == DownloadManager.STATUS_PAUSED)
            msg = REASONLISTPAUSED[reasonint];
        else if (statusint == DownloadManager.STATUS_FAILED)
            msg = REASONLISTFAILED[reasonint - 1000];

        return (msg);
    }

    public static Integer statusInt(Cursor c) {
        return c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
    }

    public static Integer reasonInt(Cursor c) {
        return c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
    }
}