Skip to content

Instantly share code, notes, and snippets.

@ohjongin
ohjongin / gist:5344536
Created April 9, 2013 09:57
Android 캡쳐 방지 카카오 페이지에서는 컨텐츠 유출을 막기위해 스샷을 하지 못하게 해두었네요. 어떤 방법이 있나 궁금해서 찾아봤는데 의외로 간단한 방법이. https://plus.google.com/u/0/110330998862784153023/posts/SoMFkYMafm4
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
@ohjongin
ohjongin / holo theme color code
Created July 10, 2013 01:31
http://stackoverflow.com/questions/9947156/what-are-the-default-color-values-for-the-holo-theme-on-android-4-0 If you want the default colors of Android ICS, you just have to go to your Android SDK and look for this path: platforms\android-15\data\res\values\colors.xml. perhaps this is what you're looking for: https://github.com/android/platform…
<!-- For holo theme -->
<drawable name="screen_background_holo_light">#fff3f3f3</drawable>
<drawable name="screen_background_holo_dark">#ff000000</drawable>
<color name="background_holo_dark">#ff000000</color>
<color name="background_holo_light">#fff3f3f3</color>
<color name="bright_foreground_holo_dark">@android:color/background_holo_light</color>
<color name="bright_foreground_holo_light">@android:color/background_holo_dark</color>
<color name="bright_foreground_disabled_holo_dark">#ff4c4c4c</color>
<color name="bright_foreground_disabled_holo_light">#ffb2b2b2</color>
<color name="bright_foreground_inverse_holo_dark">@android:color/bright_foreground_holo_light</color>
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isAcceptingText()) {
writeToLog("Software Keyboard was shown");
} else {
writeToLog("Software Keyboard was not shown");
}
@ohjongin
ohjongin / EnableComponent.java
Created August 23, 2013 06:07
Android Quick Tip: Enabling and Disabling BroadcastReceivers at Runtime http://www.grokkingandroid.com/enabling-and-disabling-broadcastreceivers/
PackageManager pm = getPackageManager();
ComponentName newComposer = new ComponentName(getApplicationContext(), ComposerActivity.class);
pm.setComponentEnabledSetting(
newComposer,
is_new_composer ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
ComponentName oldComposer = new ComponentName(getApplicationContext(), SendSMSActivity.class);
pm.setComponentEnabledSetting(
@ohjongin
ohjongin / IsPhoneNumber.java
Created October 1, 2013 07:48
For API level 8 or above : Validation for a cell number in Android http://stackoverflow.com/questions/5958665/validation-for-a-cell-number-in-android
public boolean isPhoneNumber(String number) {
if (number == null || TextUtils.isEmpty(number)) {
return false;
}
// return Pattern.matches(PHONE_NUMBER_PATTERN, number.replace("-", ""));
return android.util.Patterns.PHONE.matcher(number).matches();
}
@ohjongin
ohjongin / getUserProfileInfo.java
Created December 16, 2013 12:41
Get google account profile information
public static boolean hasPermission(Context context, String permission) {
int res = context.checkCallingOrSelfPermission(permission);
return (res == PackageManager.PERMISSION_GRANTED);
}
@SuppressLint("NewApi")
public static String getUserDisplayName(Context context) {
if (Build.VERSION.SDK_INT < 14) return "";
if (!hasPermission(context, "android.permission.READ_PROFILE")) return "";
@ohjongin
ohjongin / Log.java
Last active January 2, 2016 08:29
Android용 Log class를 대체해서 사용 가능한 Log class로 Log 출력시 class 이름 및 줄번호가 같이 출력됨
/*
Copyright (C) 2013-2014. Jongin Oh
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@ohjongin
ohjongin / ActionBarSearchView.java
Created August 1, 2014 07:57
ActionBarActivity에서 SearchView 사용하기
@SuppressLint("NewApi")
public class ContactsActivity extends ActionBarActivity implements View.OnClickListener, AdapterView.OnItemClickListener, SearchView.OnQueryTextListener, SearchView.OnCloseListener {
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.contacts, menu);
@ohjongin
ohjongin / HangulUnicodeConverter.java
Created August 1, 2014 08:46
유니코드 vs. 한글코드로 상호 변환
// from: http://www.senun.com/Left/Programming/Java/Jsp/jsp_syntax_hangul.htm
// 유니코드를 한글코드로 변환
protected String uni2ksc (String Unicodestr) throws UnsupportedEncodingException {
return new String (Unicodestr.getBytes("8859_1"),"KSC5601");
}
// 한글코드를 유니코드로 변환
protected String ksc2uni(String str) throws UnsupportedEncodingException {
return new String( str.getBytes("KSC5601"), "8859_1");
/**
* (1)Get tweets by search keyword and (2)Stemming(Korean), (3)save to mysql finally
*/
var Promise = require('bluebird');
var TwitterKoreanText = require('twtkrjs');
var twitterKoreanText = new TwitterKoreanText({
stemmer: true, // (optional default: true)
normalizer: true, // (optional default: true)