스크린샷을 찍고 저장하는 어플을 구현하였습니다. 핸드폰 내의 ES파일탐색기로 검색하면 제가 구현할때 정해놓은 폴더와 그안에 이미지 파일까지 모두 잘나타납니다.
그러나 컴퓨터와 연결해서 보면 폴더자체가 보이지가 않습니다. ㅜㅜ 폴더명으로 검색을 해보아도 나오지가 않습니다. 아래 코드를 첨부하오니 선배님들 및 전문가 분들의 감사한 조언 부탁 드립니다.
p.s 코드편집기 메뉴를 불러서 넣으려고했는데 아무리 예를 눌러도 반응하징 않아 바로 그냥 붙여넣었습니다 ㅜㅜ
package com.example.johyoungjin.sciencedesign;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Environment;
import android.view.View;
import android.widget.Toast;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.sql.Date;
import java.text.SimpleDateFormat;
/**
* Created by johyoungjin on 2015-12-28.
*/
public class Share {
Activity mActivity;
String filename;
public Share(PlanSection1A activity) {
mActivity = activity;
}
public void save() {
File dir = new File(Environment.getExternalStorageDirectory().toString()+ "/SciencePlan");
if(!dir.exists())
dir.mkdir();
try {
screenshot(mActivity);
} catch (Exception e) {
}
}
public void screenshot(Activity av2)throws Exception {
View view = av2.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
Bitmap screenshot = view.getDrawingCache();
long now = System.currentTimeMillis();
Date date = new Date(now);
SimpleDateFormat sdfNow = new SimpleDateFormat("MM월dd일HH시mm분ss초");
String strNow = sdfNow.format(date);
filename = strNow+".jpg";
try {
File f = new File(Environment.getExternalStorageDirectory().toString()+"/SciencePlan/" + filename);
f.createNewFile();
OutputStream outStream = new FileOutputStream(f);
screenshot.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
outStream.close();
Toast.makeText(mActivity.getApplicationContext(),filename+" 파일명으로 저장되었습니다.", Toast.LENGTH_LONG).show();
} catch (Exception e) {
}
view.setDrawingCacheEnabled(false);
}
public void share() {
shareImage();
}
public void shareImage() {
if(filename == null) {
Toast.makeText(mActivity.getApplicationContext(), "캡쳐를먼저해주세요!", Toast.LENGTH_SHORT).show();
}
else {
File share = new File(Environment.getExternalStorageDirectory().toString() + "/SciencePlan");
String file1 = filename;
File file2 = new File(share, file1);
Uri uri = Uri.fromFile(file2);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
mActivity.startActivity(Intent.createChooser(intent, "공유할App 선택"));
}
}
}