Java tutorial
//package com.java2s; /* * Copyright (c) 2015 * * ApkTrack is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ApkTrack is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ApkTrack. If not, see <http://www.gnu.org/licenses/>. */ import android.content.Context; public class Main { private static Boolean _DOWNLOAD_SERVICE_AVAILABLE = null; /** * Checks whether the download service is present on the device. * @param ctx The context of the application. * @return True if the download service can be used to download files. */ public static boolean check_download_service(Context ctx) { if (_DOWNLOAD_SERVICE_AVAILABLE != null) { return _DOWNLOAD_SERVICE_AVAILABLE; } _DOWNLOAD_SERVICE_AVAILABLE = ctx.getSystemService(Context.DOWNLOAD_SERVICE) != null; return _DOWNLOAD_SERVICE_AVAILABLE; } }