当前位置: 首页>>代码示例>>Java>>正文


Java Constants类代码示例

本文整理汇总了Java中com.google.android.vending.expansion.downloader.Constants的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Constants类属于com.google.android.vending.expansion.downloader包,在下文中一共展示了Constants类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reportProgress

import com.google.android.vending.expansion.downloader.Constants; //导入依赖的package包/类
/**
 * Report download progress through the database if necessary.
 */
private void reportProgress(State state, InnerState innerState) {
    long now = System.currentTimeMillis();
    if (innerState.mBytesSoFar - innerState.mBytesNotified
            > Constants.MIN_PROGRESS_STEP
            && now - innerState.mTimeLastNotification
            > Constants.MIN_PROGRESS_TIME) {
        // we store progress updates to the database here
        mInfo.mCurrentBytes = innerState.mBytesSoFar;
        mDB.updateDownloadCurrentBytes(mInfo);

        innerState.mBytesNotified = innerState.mBytesSoFar;
        innerState.mTimeLastNotification = now;

        long totalBytesSoFar = innerState.mBytesThisSession + mService.mBytesSoFar;

        if (Constants.LOGVV) {
            Log.v(Constants.TAG, "downloaded " + mInfo.mCurrentBytes + " out of "
                    + mInfo.mTotalBytes);
            Log.v(Constants.TAG, "     total " + totalBytesSoFar + " out of "
                    + mService.mTotalLength);
        }

        mService.notifyUpdateBytes(totalBytesSoFar);
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:29,代码来源:DownloadThread.java

示例2: scheduleAlarm

import com.google.android.vending.expansion.downloader.Constants; //导入依赖的package包/类
private void scheduleAlarm(long wakeUp) {
    AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    if (alarms == null) {
        Log.e(Constants.TAG, "couldn't get alarm manager");
        return;
    }

    if (Constants.LOGV) {
        Log.v(Constants.TAG, "scheduling retry in " + wakeUp + "ms");
    }

    String className = getAlarmReceiverClassName();
    Intent intent = new Intent(Constants.ACTION_RETRY);
    intent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent);
    intent.setClassName(this.getPackageName(),
            className);
    mAlarmIntent = PendingIntent.getBroadcast(this, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);
    alarms.set(
            AlarmManager.RTC_WAKEUP,
            System.currentTimeMillis() + wakeUp, mAlarmIntent
            );
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:24,代码来源:DownloaderService.java

示例3: onReceive

import com.google.android.vending.expansion.downloader.Constants; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    pollNetworkState();
    if (mStateChanged
            && !isServiceRunning()) {
        Log.d(Constants.TAG, "InnerBroadcastReceiver Called");
        Intent fileIntent = new Intent(context, mService.getClass());
        fileIntent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent);
        // send a new intent to the service
        context.startService(fileIntent);
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:13,代码来源:DownloaderService.java

示例4: generateSaveFile

import com.google.android.vending.expansion.downloader.Constants; //导入依赖的package包/类
/**
 * Creates a filename (where the file should be saved) from info about a
 * download.
 */
public String generateSaveFile(String filename, long filesize)
        throws GenerateSaveFileError {
    String path = generateTempSaveFileName(filename);
    File expPath = new File(path);
    if (!Helpers.isExternalMediaMounted()) {
        Log.d(Constants.TAG, "External media not mounted: " + path);
        throw new GenerateSaveFileError(STATUS_DEVICE_NOT_FOUND_ERROR,
                "external media is not yet mounted");

    }
    if (expPath.exists()) {
        Log.d(Constants.TAG, "File already exists: " + path);
        throw new GenerateSaveFileError(STATUS_FILE_ALREADY_EXISTS_ERROR,
                "requested destination file already exists");
    }
    if (Helpers.getAvailableBytes(Helpers.getFilesystemRoot(path)) < filesize) {
        throw new GenerateSaveFileError(STATUS_INSUFFICIENT_SPACE_ERROR,
                "insufficient space on external storage");
    }
    return path;
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:26,代码来源:DownloaderService.java

示例5: handleExceptionalStatus

import com.google.android.vending.expansion.downloader.Constants; //导入依赖的package包/类
/**
 * Check the HTTP response status and handle anything unusual (e.g. not
 * 200/206).
 */
private void handleExceptionalStatus(State state, InnerState innerState, HttpResponse response)
        throws StopRequest, RetryDownload {
    int statusCode = response.getStatusLine().getStatusCode();
    if (statusCode == 503 && mInfo.mNumFailed < Constants.MAX_RETRIES) {
        handleServiceUnavailable(state, response);
    }
    if (statusCode == 301 || statusCode == 302 || statusCode == 303 || statusCode == 307) {
        handleRedirect(state, response, statusCode);
    }

    int expectedStatus = innerState.mContinuingDownload ? 206
            : DownloaderService.STATUS_SUCCESS;
    if (statusCode != expectedStatus) {
        handleOtherStatus(state, innerState, statusCode);
    } else {
        // no longer redirected
        state.mRedirectCount = 0;
    }
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:24,代码来源:DownloadThread.java

示例6: pollNetworkState

import com.google.android.vending.expansion.downloader.Constants; //导入依赖的package包/类
/**
 * Polls the network state, setting the flags appropriately.
 */
void pollNetworkState() {
    if (null == mConnectivityManager) {
        mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    }
    if (null == mWifiManager) {
        mWifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    }
    if (mConnectivityManager == null) {
        Log.w(Constants.TAG,
                "couldn't get connectivity manager to poll network state");
    } else {
        NetworkInfo activeInfo = mConnectivityManager
                .getActiveNetworkInfo();
        updateNetworkState(activeInfo);
    }
}
 
开发者ID:google,项目名称:play-apk-expansion,代码行数:20,代码来源:DownloaderService.java

示例7: pollNetworkState

import com.google.android.vending.expansion.downloader.Constants; //导入依赖的package包/类
/**
 * Polls the network state, setting the flags appropriately.
 */
void pollNetworkState() {
    if (null == mConnectivityManager) {
        mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    }
    if (null == mWifiManager) {
        mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    }
    if (mConnectivityManager == null) {
        Log.w(Constants.TAG,
                "couldn't get connectivity manager to poll network state");
    } else {
        NetworkInfo activeInfo = mConnectivityManager
                .getActiveNetworkInfo();
        updateNetworkState(activeInfo);
    }
}
 
开发者ID:cclink,项目名称:ObbDownloadHelper,代码行数:20,代码来源:DownloaderService.java


注:本文中的com.google.android.vending.expansion.downloader.Constants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。