我想在Android(Java)中实例化一个android.Media.Image
。因为该类是抽象类,所以我创建了一个扩展Image类的新子类。
public class ImageDepth extends Image {
public Plane[] plane;
int width ;
int height ;
int format ;
public ImageDepth(){
this.width = 240;
this.height = 180;
this.format = 1144402265;
}
public ImageDepth(int width, int height){
this.width = width;
this.height = height;
this.format = 1144402265;
}
public long getTimestamp(){
//TODO
}
public int getWidth(){
return this.width;
}
public int getHeight(){
return this.height;
}
public int getFormat(){
return this.format;
}
public Plane[] getPlanes(){
this.plane = (Plane[]) new DepthPLane(); // I also made a subclass of Plane[] to instanciate it but I have the same issue
return this.plane;
};
public void close(){
//TODO
};}
我重新定义了抽象方法,但是我有一个问题:android.Media.Image类构造函数受到保护。然后,当我尝试以下代码创建构造函数时:
public ImageDepth(){...}
我有此错误:
error: Image() is not public in Image; cannot be accessed from outside package
我的问题还有其他解决办法吗?
来源:
我要创建实例的android SDK中的图像类:
文档: https://developer.android.com/reference/android/media/Image