프로그램 코드로 APK 파일을 설치해 보자. 안드로이드 7.0에서는 직접 외부 폴더(External Storage)의 APK를 설치할수 없다.따라서 다음과 같이 FileProvider를 만들어야 한다. xml/provider_paths.xml [AndroidManifest.xml] [java]final Intent intent = new Intent(Intent.ACTION_VIEW);final Uri apkURI = FileProvider.getUriForFile(getActivity(), getActivity().getApplicationContext().getPackageName() + ".provider", new File(item.path));intent.setDataAndType(apkURI,..
public class ExtSdCardHelper { public static HashSet getExternalMounts() { final HashSet out = new HashSet(); String reg = "(?i).*vold.*(vfat|ntfs|exfat|fat32|ext3|ext4).*rw.*"; String s = ""; try { final Process process = new ProcessBuilder().command("mount") .redirectErrorStream(true).start(); process.waitFor(); final InputStream is = process.getInputStream(); final byte[] buffer = new byte[10..
https://support.apple.com/ko-kr/HT204460
static Typeface FileStreamTypeface(Context context, int resource) { Typeface tf = null; InputStream is = context.getResources().openRawResource(resource); try { File outputDir = context.getCacheDir(); // context being the Activity pointer File outputFile = File.createTempFile("tmp", ".raw", outputDir); String outPath = outputFile.getAbsolutePath(); byte[] buffer = new byte[is.available()]; Buffe..
안드로이드에서 TXT파일을 처리하다보면 EUC-KR 파일을 처리할때가 있다. 그럴때는 다음과 같이 UniversalDetector를 쓰면 되는데 gradle에 먼저 다음과 같이 추가해 주어야 한다. //encoding compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3' 그리고 다음과 같이 프로그래밍 하면 텍스트 파일 내용을 UTF-8 자바 문자열로 얻을 수 있다.File file = new File(path);FileInputStream is = new FileInputStream(file); UniversalDetector detector = new UniversalDetector(null);byte[] buffer = new byte..
http://stackoverflow.com/questions/22758048/collection-element-of-type-double-is-not-an-objective-c-object 위의 에러메세지는 컬렉션에는 double 타입이 들어가지 못한다는 에러 메세지이다.그래서 NSNumber로 박싱을 해야 한다. 박싱은 간단하게 @(doubleTypeVariable) 또는 [NSNumber numberWithDouble:doubleTypeVariable] 이렇게 할수 있다.
윈도우에서 작성한 소스코드를 xcode에서 불러올때 한글이 깨지는 경우가 있다. 물론 UTF-8로 작성했다면 깨지지 않지만, 구형 소스의 경우는 한글 CP949(이하 CP949)로 작성된 경우가 많다. 일일이 UTF-8로 소스코드의 인코딩을 변경하여 사용하면 되지만, 데이터가 CP949기반으로 작성했다면 UTF-8로 인코딩을 변경하면 깨지는 경우가 있어서 바로 CP949를 읽어야 한다. 프로젝트에서 CP949 소스코드를 열면 한글이 깨져있다. 오른쪽에서 Text Settings에서 Text Encoding을 선택한다. 그 다음에 여러가지 Korean이 있는데 EUC나 다른 것을 선택하지 말고 반드시 Korean (Windows, DOS)를 선택하자. 그러면 텍스트를 변환한다는 다이얼로그가 뜨는데 여기서 ..
public class UnitConverter { public static int dpToPx(int dp) { return (int) (dp * Resources.getSystem().getDisplayMetrics().density); } public static int pxToDp(int px) { return (int) (px / Resources.getSystem().getDisplayMetrics().density); }} public class RoundedImageView extends ImageView { public RoundedImageView(Context context) { super(context); } public RoundedImageView(Context context, ..
- Total
- Today
- Yesterday