小编tpu*_*unt的帖子

在DownloadManager中取消下载

我正在尝试使用以下代码从URL下载图像:-

public static void writeToDisk(Context context, @NonNull String imageUrl, @NonNull String downloadSubfolder) {
    Uri imageUri = Uri.parse(imageUrl);
    String fileName = imageUri.getPath();
    String downloadSubpath = downloadSubfolder + fileName;

    DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
    DownloadManager.Request request = new DownloadManager.Request(imageUri);
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    request.setDescription(imageUrl);
    request.allowScanningByMediaScanner();
    request.setDestinationUri(getDownloadDestination(downloadSubpath));

    downloadManager.enqueue(request);
}
Run Code Online (Sandbox Code Playgroud)

下载开始后,我不知道如何取消下载。

android android-download-manager

5
推荐指数
1
解决办法
2228
查看次数

创建新项目时,android无法解析的依赖项错误

我已经更新了Android Studio,但是之后,我将无法创建新项目。我的Android版本是2.2 beta 3。

这是尝试创建Gradle同步项目时错误消息的图像:

android android-studio android-gradle-plugin

2
推荐指数
1
解决办法
1万
查看次数

toString()方法不是从它的超类中引入的

我正在从事一项具有以下课程的任务:

  1. Vehicle.java (抽象类)
  2. NewVehicle.java 子类 Vehicle.java
  3. UsedVehicle.java 子类 Vehicle.java
  4. VehicleParser.java 用作解析器
  5. Drive 用作主要的类

VehicleParser课堂上我确定它是哪个对象.无论是NewVehicle对象还是对象UsedVehicle.在Drive课堂上我ArrayListVehicle对象填充.

现在,当我试图System.out.println一个Arraylist驱动类只是调用toString中声明的方法UsedVehicle/ NewVehicle而不是调用在声明的方法Vehicle.java类.我需要它首先调用该方法toString的车辆,然后CONCAT了toStringUsedVehicle/ NewVehicle它.

这是代码:

车辆

public abstract class Vehicle {

    protected String make;
    protected int modelYear;
    protected String motivePower;
    protected double licenseFee;

    public Vehicle(String make,int modeYear,String motivePower) {
        this.make = make;
        this.modelYear= modeYear;
        this.motivePower = motivePower; …
Run Code Online (Sandbox Code Playgroud)

java oop inheritance tostring

1
推荐指数
1
解决办法
565
查看次数