PDA

Ver la Versión Completa : [ CONSULTA ] No funciona FileObserver


LEAJIM_454
06/09/17, 00:53:42
Hola estimada comunidad, intenté de muchas fomas y nunca llega a llamarse al metodo interno onEvent() pido un poco de su ayuda, gracias por su tiempo

Éste es el código

private void takePhoto(){
mPhotoResult = mFotoapparat.takePicture();

temporaryPath = Calendar.getInstance().getTime().getTime();

imagePath = new File(alphemsoftInkDirectory.getAbsolutePath(),temp oraryPath+".png" );

fileObs = new FileObserver(imagePath.getAbsolutePath()){

override
public void onEvent(int event, String path) {
if (event == FileObserver.CREATE){
afterListener();
Toast.makeText(getActivity(),"Hi", Toast.LENGTH_LONG).show();

}
}
};
fileObs.startWatching();

storeImageLocations.add(imagePath.getAbsolutePath( ));

if (!alphemsoftInkDirectory.exists()){
alphemsoftInkDirectory.mkdir();
}


Toast.makeText(getActivity(),"Ready",Toast.LENGTH_LONG).show();

try {
imagePath.createNewFile();

} catch (IOException e) {
e.printStackTrace();
Toast.makeText(getActivity(),imagePath.toString(), Toast.LENGTH_LONG);
}

mPhotoResult.saveToFile(imagePath);



}