[Android] Canvas Animation

Android 2012. 8. 15. 15:56

invalidate를 루프에서 처리하면 onDraw가 불리지 않는다.

핸들러에서 재귀호출을 하면 /일단은/ 가능하다.


public final Handler refreshHandler = new Handler() {

public void handleMessage(Message msg) {



Act3Activity.this.ca.invalidate();

this.sendEmptyMessageDelayed(0, 25);   <-  25 milisecond 후에 재귀 호출

}

};


Posted by tenn
,

싱글터치


ACTION_DOWN   

ACTION_MOVE   

ACTION_UP      

ACTION_CANCEL    :    터치영역을 벗어날때 (버튼을 누른후 버튼영역을 벗어날때)



멀티터치


ACTION_POINTER_1_DOWN    :    먼저닿은 손가락이 떨어진 후 다시 터치할때

(나중에 닿은 손가락은 계속 터치)

ACTION_POINTER_1_UP        :    먼저 닿은 손가락이 떨어질때

ACTION_POINTER_2_DOWN    :    한손가락을 터치한 채로 다른 손가락이 터치될때

ACTION_POINTER_2_UP    :    나중에 터치된 손가락이 떨어질때



Posted by tenn
,

확인단말 : GalaxyNexus, Galaxy S2


Galaxy Nexus에서 좀처럼 동영상을 재생해주지않아서 삽질.


raw리소스의 동영상 파일을 file로 출력한 후, 생성파일을 이용해서 재생.

생성화일의 확장자는 관계없었다. (mp4를 mov로 바꾸어도 재생가능)


a() : 안드로이드에서 제공해주는 ACTION_VIEW 이용.

b() : VideoView + MediaController 이용.



방법1. 갤러리 이용


void a(){


this.filecopy();

String path = getFilesDir().getAbsolutePath()+"/"+FILE_NAME;

Log.e(null, path);

Log.e(null, "file exist? "+ new File(path).exists());


Intent i = new Intent(Intent.ACTION_VIEW);

 


Uri uri = Uri.fromFile(new File(path));

  it.setDataAndType(uri, "video/*");

  startActivity(i);

}


방법2. VideoVIew



void b(){


VideoView vv = (VideoView) findViewById(R.id.videoView1);


MediaController mc = new MediaController(this);

mc.setAnchorView(vv);

this.filecopy();

String path = getFilesDir().getAbsolutePath()+"/"+FILE_NAME;

Log.e(null"xxx : "+path);

Log.e(null"file : "+new File(path).exists());

vv.setMediaController(mc);

//Uri uri = Uri.fromFile(new File(path));

//vv.setVideoURI(uri);  //uri로도 정상동작

vv.setVideoPath(path);

vv.requestFocus();

vv.start();

}




raw Resource -> file


final String FILE_NAME = "a1.mp4";


void filecopy() {


Log.e(null, "filecopy");

InputStream in = this.getResources().openRawResource(R.raw.a14); //raw리소스


int size;

byte[] w = new byte[1024];

OutputStream out = null;

try {

out = this.openFileOutput(FILE_NAME, Context.MODE_WORLD_READABLE);

while (true) {

size = in.read(w);

if (size <= 0)

break;

out.write(w, 0, size);

}

out.close();

in.close();

} catch (Exception e) {

Log.e(null, e.toString());

}


}


Posted by tenn
,