티스토리 툴바


달력

05

« 2012/05 »

  •  
  •  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  •  
  •  
ACTION_APPWIDGET_UPDATE를 Broadcast하면 되는데 이때 Extra로 Widget ID를 넣어 주어야 한다. 
다음과 같은 방법으로 위젯 ID들을 획득할 수 있다.

mgr.getAppWidgetIds(new ComponentName(this, Widget.class)) 

예제 코드를 작성하면 아래와 같다.

AppWidgetManager mgr = AppWidgetManager.getInstance(this);
Intent update = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
update.setClass(this, Widget.class);
update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, mgr.getAppWidgetIds(new ComponentName(this, Widget.class)));
this.sendBroadcast(update);

그냥 -_-; EXTRA_APPWIDGET_ID가 없으면 Class도 알겠다. 그냥 알아서 ID가져다가 갱신해주면 안되겠니? 
Posted by 철이아부지
-_-; 아놔. 제목 거창하네.

AndroidMenifest.xml 에서
.Main activity 정의할때 android:configChanges="orientation" 프로퍼티를 추가해주면 된다.
Posted by 철이아부지
갤럭시S가 프로요로 업그레이드 되고 나더니 개발 옵션에서 충전중 잠들기 방지 옵션이 사라졌다!!!

개발할때마다 전화기 깨우는게 귀찮아서 만든 프로그램

각성제(Stimulant)!

설치 후 위젯으로 등록한 후에 한번 눌러서 애가 눈이 시뻘개 지면 잠들기 모드로 빠지지 않는다. 

다시 누르면 잠들기로 빠질수 있게 전환된다.


버그가 하나 있는데 잠들지 않게 해놓아도 USB 케이블을 뺐다가 꼽으면 다시 잠들기로 빠질수 있음
그럴땐 다시 토글해주면 됨. ㅡㅡ 게을러서 고칠 이유도 없고 고치고 싶지도 않음....

수정: 귀차나서 ㅡㅡ 10초 마다 계속 Lock 걸게 수정

안드로이드 1.6 이상에서 동작 가능

Posted by 철이아부지
<meta name="format-detection" content="telephone=no, address=no, email=no" />

아이폰 Safari 계열은 전화 번호만 자동 링크로 바꾸는데 안드로이드는 메일 주소와 지도상 주소까지 링크로 만들어 버리는 만행을 저지른다.

ㅡㅡ 안드로이드 webkit 소스를 디벼보니 adress, email 이라는 메타 태그도 같이 처리해줌을 알수 있다.
따라서 위와 같이 해주면 오케이.

사실 

<meta name="format-detection" content="no" />

이렇게 해주면 포멧 감지 기능을 모두 꺼버리는건데.. 아이폰에서 어떻게 동작할지 몰라서 그냥.. 세개 다 써줌.
Posted by 철이아부지
<img src="그림 소스" 
oncontextmenu="return false"
style="-webkit-touch-callout:none" />

oncontextmenu="return false" 이걸 이용하여 안드로이드 계열에서 저장되는 것 막음
style="-webkit-touch-callout:none" 이걸 이용하여 아이폰 계열에서 저장되는 것 막음

잔지식만 느네.. ㅡㅡ;
Posted by 철이아부지
정말 정말 고생했다..

헤더에 틀림없이 

Pragma: no-cache
Cache-Contro: no-cache, no-store, max-age=1, must-revalidate
Expires: 0

까지 다 넣어 준 상태에서.. Back button 누르면 설정 다 무시하고 Cache에서 읽어 온다.
이게 모바일 브라우저 놈들만 그러더라는 말이지.. ㅠㅠ

캐쉬에서 적재되어 화면이 올라올때 먼 이벤트라도 발생해주면 어떻게든 해보겠는데 ㅡㅡ 잡히는 이벤트 하나 없다. onload 조차도..

이틀을 고생했는데.. 다음과 같은 신이 내린 코드 한줄로 해결되었다

<body onunload="">

onunload=""... 왜 이걸로 해결이 되지? ㅡㅡ; 뭐 하여튼... 문제는 풀렸으니..

저게 동작되어 신기한 것 보다는.. onunload="" 를 알아내기 위해 뺑이 치셨을 인터넷에 글 올려주신 아주 아주 훌륭하신 분께 감사를 드리오며... ㅠㅠ 이짓도 해먹을 짓이 아님을 격하게 깨닫고 있는중...
Posted by 철이아부지
2010/12/14 15:09

Javascript로 Calendar 구현 분류없음2010/12/14 15:09

자바 스크립트로 달력 그릴일이 생겼는데 java같은 calendar 클래스가 없어서 개발 새발 만들어봄
혹시 이거 쓰는 사람이 혹시라도 생기게 되면 오류에 대해 Feedback 주세요~

calendar.js
function fillZero(value, length) {
var result = "" + value;

for( var step = result.length; step < length; step++ ) {
result = "0" + result;
}

return result;
}

function Calendar() {
this.date = new Date();
this.set = function(newDate) {
this.date = newDate;
};
this.get = function() {
return this.date;
};
this.getLongTime = function() {
return this.date.getTime();
};
this.setLongTime = function(millisec) {
return this.date.setTime(millisec);
};
this.addDay = function( day ) {
this.setLongTime(this.getLongTime() + day * 86400000);
}
this.getYear = function() {
return this.date.getFullYear();
};
this.setYear = function(year) {
this.date.setFullYear(year);
};
this.getMonth = function() {
return this.date.getMonth();
};
this.setMonth = function(month) {
this.date.setMonth(month);
};
this.getDayOfMonth = function() {
return this.date.getDate();
};
this.setDayOfMonth = function(dayOfMonth) {
this.date.setDate(dayOfMonth);
};
this.getDayOfWeek = function() {
return this.date.getDay();
};
this.setDayOfWeek = function(dayOfWeek) {
this.addDay(this.getDayOfWeek() * -1);
this.addDay(dayOfWeek);
};
this.setDate = function( year, month, dayOfMonth ) {
this.setYear(year);
this.setMonth(month);
this.setDayOfMonth(dayOfMonth);
};

this.getDate = function() {
return this.getYear() + "-" + fillZero((this.getMonth() + 1), 2) + "-" + fillZero(this.getDayOfMonth(), 2);
};


this.getHours = function() {
return this.date.getHours();
};
this.setHours = function(hours) {
this.date.setHours(hours);
};
this.getMinutes = function() {
return this.date.getMinutes();
};
this.setMinutes = function(minutes) {
this.date.setMinutes(minutes);
};
this.getSeconds = function() {
return this.date.getSeconds();
};
this.setSeconds = function(seconds) {
this.date.setSeconds(seconds);
};

this.getMilliseconds = function() {
return this.date.getMilliseconds();
};

this.setMilliseconds = function(seconds) {
this.date.setMilliseconds(seconds);
};
this.setTime = function( hour, minute, second) {
this.setHours(hour);
this.setMinutes(minute);
this.setSeconds(second);
this.setMilliseconds(0);
};

this.getTime = function() {
return fillZero(this.getHours(),2) + ":" + fillZero(this.getMinutes(), 2)  + ":" + fillZero(this.getSeconds(), 2);
};

this.getDateTime = function() {
return this.getDate() + " " + this.getTime();
};

this.format = function(format) {
var result = format;

result = result.replace( "yyyy", this.getYear() );
result = result.replace( "yy", this.getYear() % 100 );
result = result.replace( "MM", fillZero(this.getMonth()+1,2));
result = result.replace( "M", this.getMonth()+1);
result = result.replace( "dd", fillZero(this.getDayOfMonth(),2));
result = result.replace( "d", this.getDayOfMonth());
result = result.replace( "a", this.getHours() > 12 ? "PM" : "AM");
result = result.replace( "HH", fillZero(this.getHours(), 2));
result = result.replace( "H", this.getHours());
result = result.replace( "hh", fillZero(this.getHours() == 0 || this.getHours() == 12 ? 12 : this.getHours() % 12, 2));
result = result.replace( "h", this.getHours() == 0 || this.getHours() == 12 ? 12 : this.getHours() % 12 );
result = result.replace( "mm", fillZero(this.getMinutes(), 2));
result = result.replace( "m", this.getMinutes());
result = result.replace( "ss", fillZero(this.getSeconds(), 2));
result = result.replace( "s", this.getSeconds());
return result;
};

this.parseDate = function(dateString) {
if( dateString == null || dateString.length <= 0 ) {
return false;
}

var dateItem = dateString.split("-");

if( dateItem.length < 3 ) {
return false;
}

var year = parseInt(dateItem[0]);
var month = parseInt(dateItem[1]);
var day = parseInt(dateItem[2]);

if( isNaN(year) == true || isNaN(month) == true || isNaN(day) == true ) {
return false;
}

this.setDate(year, month-1, day);
return true;
}

this.parseTime = function(timeString) {
if( timeString == null || timeString <= 0 ) {
return false;
}

var timeItem= timeString.split(":");

if( timeItem.length < 3 ) {
return false;
}

var hour = parseInt(timeItem[0]);
var minute = parseInt(timeItem[1]);
var second = parseInt(timeItem[2]);

if( isNaN(hour) == true || isNaN(minute) == true || isNaN(second) == true ) {
return false;
}

this.setTime(hour, minute, second);
return true;
}

this.parse = function(dateTimeString) {
if( dateTimeString == null || dateTimeString <= 0 ) {
return false;
}

var dateTimeItem= dateTimeString.split(" ");

if( dateTimeItem.length < 2 ) {
return false;
}

if( this.parseDate(dateTimeItem[0]) == false || this.parseTime(dateTimeItem[1]) == false ) {
return false;
}

return true;
}
}

예제 HTML
<html>
<head>
<script src="calendar.js"></script>
<script>
function drawCalendar(pannelId) {
var pannel = document.getElementById(pannelId);

var calendarText = "";
var calendar = new Calendar();
calendarText = "<b>" + calendar.format("yyyy년 MM월") + "</b><br/>";
var currMonth = calendar.getMonth();
var currYear = calendar.getYear();

calendar.setDayOfMonth(1);
calendar.setDayOfWeek(0);
calendarText += 
"<table><tr>" +
"<td>일</td>" +
"<td>월</td>" +
"<td>화</td>" +
"<td>수</td>" +
"<td>목</td>" +
"<td>금</td>" +
"<td>토</td></tr>";
while( currMonth >= calendar.getMonth() && currYear >= calendar.getYear() ) {
calendarText += "<tr>";

for( var step = 0; step < 7; step++ ) {
calendarText += "<td>" + calendar.format("dd") + "</td>";
calendar.addDay(1);
}

calendarText += "</tr>";
}

calendarText += "</table>";
pannel.innerHTML = calendarText;
}

function parseTest() {
var calendar = new Calendar();
calendar.parseDate( "2010-10-12" );
alert( calendar.getDate() );
calendar.parseTime( "14:02:11" );
alert( calendar.getTime() );
calendar.parse( "1999-01-01 17:18:19");
alert( calendar.getDateTime() );
}
</script>
</head>
<body onload="drawCalendar('calendar')">
<div id="calendar"></div>
<button onclick="parseTest()">parse test</button>
<body>
</html>
Posted by 철이아부지
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlValue));
intent.putExtra(Browser.EXTRA_APPLICATION_ID, TAG);
context.startActivity(intent);

간단함. 
Extra 에 자신의 Application ID를 정해서 던지면 같은 ID에 대해서는 같은 창에다가 계속 띄워줌

몰라서 무척 헤맸다는.. ^^
Posted by 철이아부지
2010/04/28 15:19

onbeforeunload 이벤트 처리하기 분류없음2010/04/28 15:19

이런 뭐가튼 경우가.. 
onbeforeunload 이벤트의 경우 IE는 event.returnValue에 사용자 확인 문자열을 줘야 하고
크롬은 사용자 확인 문자열을 return 시켜야 한다.
뻘짓하니라 2시간 날림. ㅡㅡ 설마 파폭은 또 다를랑가.

결론으로 나온 함수

window.onbeforeunload = function() {
event.returnValue = '나가시렵니까?'
return '나가시렵니까?'
}

이런 간단한걸! 제길!
Posted by 철이아부지
2010/03/08 09:29

마나님이 구축해주신 근무 환경 분류없음2010/03/08 09:29



거북이 목이 되면 안되잖아. ^^
고마워 철이 엄마.

Posted by 철이아부지