ねえ、オブジェクト要素を内部ストレージに保存しようとしています。マトリックスが含まれているので、シリアル化しようとしています。NotSerializableException.Here が発生する原因となる間違ったことを誰か教えてください。
要素クラス
public class Element extends main implements Serializable{
private int mX;
private int mY;
int location2 ;
Matrix elementlocation;
private Bitmap mBitmap;
Canvas canvas2;
byte[] byteArray;
int num=1;
float[] matrixValues = new float[9];
public Element(Resources res, int x, int y,Context context) {
location2 =item3;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
mBitmap = BitmapFactory.decodeResource(res, location2);
mX = x - mBitmap.getWidth() / 2;
mY = y - mBitmap.getHeight() / 2;
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byteArray = stream.toByteArray();
// writeBitmap(byteArray, context);
// writemX(mX,context);
// writemY(mY,context);
Log.v("Element", "num: "+num);
num++;
elementlocation=new Matrix();
elementlocation.postTranslate(mX,mY);
elementlocation.getValues(matrixValues);
ByteBuffer bytebuff=ByteBuffer.allocate(4 * matrixValues.length);
FloatBuffer floatBuf = bytebuff.asFloatBuffer();
floatBuf.put(matrixValues);
byte [] byte_array = bytebuff.array();
writeElement(new Element(res,mX,mY), context);
}
public Element(Resources res, int x, int y) {
location2 =item3;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
mBitmap = BitmapFactory.decodeResource(res, location2);
mX = x - mBitmap.getWidth() / 2;
mY = y - mBitmap.getHeight() / 2;
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byteArray = stream.toByteArray();
Log.v("Element", "num: "+num);
num++;
elementlocation=new Matrix();
elementlocation.postTranslate(mX,mY);
elementlocation.getValues(matrixValues);
ByteBuffer bytebuff=ByteBuffer.allocate(4 * matrixValues.length);
FloatBuffer floatBuf = bytebuff.asFloatBuffer();
floatBuf.put(matrixValues);
byte [] byte_array = bytebuff.array();
}
public Element(){
}
public void doDraw2(Canvas canvas) {
elementlocation=new Matrix();
elementlocation.postTranslate(mX,mY);
canvas2=canvas;
canvas2.drawBitmap(mBitmap, elementlocation,null);
}
public void setelementlocation(float num1,float num2){
elementlocation=new Matrix();
elementlocation.postTranslate(num1,num2);
}
public Canvas getCanvas2(){
return(canvas2);
}
public String toString() {
String sentence;
sentence= mBitmap+" "+mX+" "+mY;
return (sentence);
}
}
writeElement メソッド
public void writeElement(Element obj, Context context){
Log.v("main", "made it to method writeElement" );
value=getvalue();
File f = new File(context.getFilesDir(),FILENAME);
try {
fos = new FileOutputStream(f);
objectwrite = new ObjectOutputStream(fos);
objectwrite.writeObject(obj);
fos.close();
Log.v("main", "file was made File ");
}catch (FileNotFoundException e){
e.printStackTrace();
Log.v("main", "file was not made File not found ");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.v("main", "file was not made File IOException ");
}