아래 코드처럼 ProgressDialog로 파일이나 이미지를 저장할 때 기다리는 동안 로딩화면을 띄워 주려고 하는데 Context Menu에 가려서 안 보이는건지 뭐 때문인지 모르겠지만 프로그래스가 보이지 않아요.. 컨텍스트 메뉴에서 이미지나 파일 저장하기를 눌러야 저장이 되는데 어떻게 해야하나요....ㅠ.ㅠ 아무리해도 안되네요...
public boolean onContextItemSelected(MenuItem item)
{
URL url = null ;
InputStream is = null ;
File f = null ;
String fileName = null ;
HttpURLConnection conn = null ;
/// 프로그래스 띄우기
ProgressDialog savePd = new ProgressDialog( oaasysMain.this ) ;
savePd.setMessage( "Loading..." ) ;
savePd.setProgressStyle( ProgressDialog.STYLE_HORIZONTAL );
savePd.setCancelable(false);
savePd.show( ) ;
if(item.getTitle().equals("이미지 저장")) {
try{
url = new URL("hitTestResult.getExtra() + "&loginid=" + gsOaasysApp.getUserId() + "&loginpw=" + gsOaasysApp.getEncryptPass( )) ;
fileName = url.getFile( ) ;
conn = (HttpURLConnection) url.openConnection( ) ;
conn.setDoInput(true);
conn.connect( ) ;
is = conn.getInputStream( ) ;
int index1 = fileName.lastIndexOf("/") ;
if(index1 >= 0) {
fileName = fileName.substring(index1 + 1) ;
index1 = fileName.indexOf("&loginid") ;
fileName = fileName.substring(0,index1) ;
}
int index2 = fileName.lastIndexOf("\\") ;
if(index2 >= 0) {
fileName = fileName.substring(index2 + 1) ;
}
FileOutputStream fos ;
int jpgIndex = fileName.lastIndexOf(".jpg") ;
int pngIndex = fileName.lastIndexOf(".png") ;
int gifIndex = fileName.lastIndexOf(".gif") ;
int bmpIndex = fileName.lastIndexOf(".bmp") ;
if(jpgIndex >= 0 || pngIndex >= 0 || gifIndex >= 0 || bmpIndex >= 0) {
f = new File(Environment.getExternalStorageDirectory( ), fileName) ;
} else {
f = new File(Environment.getExternalStorageDirectory( ), "profile.png") ;
}
f = fileRenamePolicy(f) ;
fos = new FileOutputStream(f) ;
int read;
while((read = is.read( )) != -1){
fos.write(read) ;
}
fos.flush( ) ;
fos.close( ) ;
Toast.makeText(getApplicationContext( ), "저장이 완료되었습니다.", 0).show( ) ;
} catch (IOException e) {
Toast.makeText(getApplicationContext( ), "저장을 실패했습니다.", 0).show( ) ;
e.printStackTrace( ) ;
}
} else if (item.getTitle().equals("원본 이미지 저장")) {
try{
url = new URL("hitTestResult.getExtra() + "&loginid=" + gsOaasysApp.getUserId() + "&loginpw=" + gsOaasysApp.getEncryptPass( )) ;
fileName = url.getFile( ) ;
fileName = fileName.replaceFirst("Thumb", "");
url = new URL("http://" + url.getHost() + ":" + url.getPort() + fileName + "&loginid=" + gsOaasysApp.getUserId() + "&loginpw=" + gsOaasysApp.getEncryptPass( )) ;
conn = (HttpURLConnection) url.openConnection( ) ;
conn.setDoInput(true);
conn.connect( ) ;
is = conn.getInputStream( ) ;
int index = fileName.lastIndexOf("/") ;
if(index >= 0) {
fileName = fileName.substring(index + 1) ;
index = fileName.indexOf("&loginid") ;
fileName = "[original]" + fileName.substring(0,index) ;
}
FileOutputStream fos ;
f = new File(Environment.getExternalStorageDirectory( ), fileName) ;
f = fileRenamePolicy(f) ;
fos = new FileOutputStream(f) ;
int read;
while((read = is.read( )) != -1){
fos.write(read) ;
}
fos.flush( ) ;
fos.close( ) ;
Toast.makeText(getApplicationContext( ), "원본 저장이 완료되었습니다.", 0).show( ) ;
} catch (IOException e) {
Toast.makeText(getApplicationContext( ), "원본 저장을 실패했습니다.", 0).show( ) ;
e.printStackTrace( ) ;
}
}
//로딩프로그래스 없애기
savePd.dismiss( ) ;
return false ;
}




Thread 나 AsyncTask 찾아보세요!