我正在尝试使用以下代码从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 Studio,但是之后,我将无法创建新项目。我的Android版本是2.2 beta 3。
这是尝试创建Gradle同步项目时错误消息的图像:

我正在从事一项具有以下课程的任务:
Vehicle.java (抽象类) NewVehicle.java 子类 Vehicle.javaUsedVehicle.java 子类 Vehicle.javaVehicleParser.java 用作解析器Drive 用作主要的类在VehicleParser课堂上我确定它是哪个对象.无论是NewVehicle对象还是对象UsedVehicle.在Drive课堂上我ArrayList用Vehicle对象填充.
现在,当我试图System.out.println一个Arraylist驱动类只是调用toString中声明的方法UsedVehicle/ NewVehicle而不是调用在声明的方法Vehicle.java类.我需要它首先调用该方法toString的车辆,然后CONCAT了toString的UsedVehicle/ 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)