| 생김새 | 코드 | 의미 |
|---|---|---|
| " | " | 따옴표 |
| & | & | 앰퍼샌드 |
| < | < | 꺽쇠 |
| > | > | 꺽쇠 |
| © | © | 카피라이트 |
| ® | ® | 등록상표 |
| ™ | ™ | 트레이드마크 |
| × | × | 곱하기 기호 |
| ÷ | ÷ | 나눗셈 기호 |
| • | • | 불릿 |
| · | · | 가운데 점 |
| ⋅ | ⋅ | dot operator |
| — | — or — | dash |
2013년 4월 29일 월요일
어플 실행 여부 확인
public static boolean isRunningProcess(Context context, String packageName){ boolean isRunning = false; // ActivityManager actMng = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE); // List<RunningAppProcessInfo> proceses = actMng.getRunningAppProcesses(); // for(RunningAppProcessInfo rap : proceses){ // if( rap.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND && rap.processName.equals(packageName)){ // isRunning = true; // break; // } // } ActivityManager activityManager = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE); List<RunningTaskInfo> info; info = activityManager.getRunningTasks(1); for (Iterator iterator = info.iterator(); iterator.hasNext();) { RunningTaskInfo runningTaskInfo = (RunningTaskInfo) iterator.next(); if(runningTaskInfo.topActivity.getClassName().startsWith(packageName) ) { return true; } } return isRunning; }
2013년 4월 24일 수요일
사용자가 5초 동안 앱을 터치하지 않았을 경우 처리
public class hard_UserInteraction extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hard_userinteraction);
}
protected Handler mFinishHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
finish();
}
};
void registerFinish() {
mFinishHandler.sendEmptyMessageDelayed(0, 5 * 1000);
}
void unRegisterFinish() {
}
void RefreshFinish() {
unRegisterFinish();
registerFinish();
}
protected void onResume() {
super.onResume();
registerFinish();
}
protected void onPause() {
super.onPause();
unRegisterFinish();
}
public void onUserInteraction() {
super.onUserInteraction();
RefreshFinish();
}
protected void onUserLeaveHint () {
super.onUserLeaveHint();
Toast.makeText(this, "Leave by user", Toast.LENGTH_LONG).show();
}
}
출처 : http://www.winapi.co.kr/android/annex/19-3.htm
2013년 3월 22일 금요일
휴대폰 번호 정규식(070포함)
//휴대폰 번호 정규식
public boolean getCheckTelNo(String noStr) {
String pattern = "^0[17](?:0|1|[6-9])-?(\\d{3,4})-?(\\d{4})$";;
Pattern tellPattern = Pattern.compile(pattern);
if(noStr == null || noStr.length()==0)
return false;
Matcher matcher = tellPattern.matcher( noStr);
if(matcher.matches()) {
return true;
} else {
return false;
}
}
2013년 3월 5일 화요일
Activity 간 객체 넘기기
[객체 클래스]
public class BookData implements Parcelable{
private String title;
private String author;
public BookData(Parcel in){
readFromParcel(in);
}
public BookData(String title, String author) {
super();
this.title = title;
this.author = author;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(title);
dest.writeString(author);
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator(){
@Override
public Object createFromParcel(Parcel source) {
return new BookData(source);
}
@Override
public Object[] newArray(int size) {
return new BookData[size];
}
};
private void readFromParcel(Parcel in){
title = in.readString();
author = in.readString();
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
}
public class MainActivity extends Activity {
Button btn;
Activity mActivity;
Context mContext;
BookData data;
ArrayList array = new ArrayList();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mActivity = this;
mContext = this;
data = new BookData("TITLE1", "TEST1");
array.add(data);
data = new BookData("TITLE2", "TEST2");
array.add(data);
btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, Test.class);
intent.putParcelableArrayListExtra("book", array);
//intent.putExtra("book", data);
mActivity.startActivity(intent);
finish();
}
});
Log.d("TEST", "onCreate!");
}
}
public class Test extends Activity{
BookData book;
ArrayList arr;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
arr = getIntent().getParcelableArrayListExtra("book");
// Bundle bundle = getIntent().getExtras();
// book = bundle.getParcelable("book");
for(int i=0; i < arr.size(); i++){
book = arr.get(i);
Log.d("TEST", "Author: " + book.getAuthor() + ", Title: " + book.getTitle());
}
}
}
2013년 1월 18일 금요일
AppWidget에서의 onEnabled() 재정의
스케쥴러가 메모리 부족 시 제거할 프로세스 선택할 때 선택되지 않도록 지정하는 용도로도 사용된다.
@Override
public void onEnabled(Context context) {
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(
new ComponentName("패키지명", ".클래스명"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP
);
}
2013년 1월 3일 목요일
Google Charts API를 이용한 QRCode 생성
private Bitmap makeQRCode(){
String input = "http://m.naver.com";
URL url;
try{
url = new URL("http://chart.apis.google.com/chart?chs=300x300&cht=qr&choe=UTF-8&chl="
+ URLEncoder.encode(input, "UTF-8"));
URLConnection conn = url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bmp = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
return bmp;
}catch(Exception e){
e.printStackTrace();
return null;
}
}
[Google chart api]cht=qr
chs=<size>
chl=<text to encode>
choe=<output encoding>
피드 구독하기:
글 (Atom)