크리에이티브 커먼즈 라이선스
Creative Commons License

2개월 가량 먹을것도 못먹고, 잠도 덜자고? 참 오랫동안 준비 한 공모전 앱입니다.
중간에 데이터베이스 설계잘못 해서 소스 뒤업고, 기획을 잘 못해서 몇일 허비 했습니다.
프로그램 개발에서 기획/설계능력이 중요한것을 다시한번 느낌니다..
아직 갈길은 멀었고, 출품 마감일은 다가 오고..
이번엔 좋은 결과 있기를..

저작자 표시 비영리 동일 조건 변경 허락
TRACKBACK ADDRESS
http://www.kmshack.kr/trackback/182 관련글 쓰기
이름 :
비밀번호 :
홈사이트 :
비밀글 :
크리에이티브 커먼즈 라이선스
Creative Commons License
안드로이드 화면 회전시 OnDestory(), OnCreate()등이 호출 되면서 기존의 변수들이 모두 초기화 되어 버린다.
이러한 데이터 초기화를 방지하기 위해 화전회전시 onRetainNonConfigurationInstance()이 호출 되는데 이때,
데이터를 저장하여 화면회전후 다시 불러오는 방법이다.

@Override
public Object onRetainNonConfigurationInstance() 
{		
        //HashMap을 이용하여 데이터를 저장
        HashMap data= new HashMap();
        data.put("year", year);
        data.put("month", month);
        return data;
}


@SuppressWarnings("unchecked")
private void restore() 
{
       //데이터를 불러온다.
       Object obj = getLastNonConfigurationInstance();
       if(obj!=null)
       {
           HashMapdata = (HashMap) obj;
           this.year = Integer.parseInt(data.get("year").toString());
           this.month = Integer.parseInt(data.get("month").toString());
       }
}


저작자 표시 비영리 동일 조건 변경 허락
TRACKBACK ADDRESS
http://www.kmshack.kr/trackback/181 관련글 쓰기
이름 :
비밀번호 :
홈사이트 :
비밀글 :
크리에이티브 커먼즈 라이선스
Creative Commons License
안드로이드 폰은 부팅이 끝나면 액션이 'android.intent.action.BOOT_COMPLETED'인 인텐트를 브로드캐스트 한다. 그러므로 이 인텐트 브로트캐스트를 받을 수 있는 BroadcastReceiver가 필요하다.

public class GPSLoggerServiceManager extends BroadcastReceiver {
  @Override
  public void onReceive(Context ctx, Intent intent) {
   if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
     ComponentName cName = new ComponentName(ctx.getPackageName(), GPSLogger);
     ComponentName svcName = ctx.startService(new Intent().setComponent(cName);
     if (svc == null) {
       Log.e(TAG, "Could not start service " + cName.toString());
     }
   } else {
     Log.e(TAG, "Received unexpected intent " + intent.toString());
   }
  }
}

여기서 가장 핵심은 onReceive() 메소드이다. 원하는 인텐트가 브로드캐스트 되면 onReceive() 메소드가 호출된다.

그리고 리시버는 manifest 파일에 선언되어 있어야 한다.

<receiver android:name=".LocationLoggerServiceManager"
   android:enabled="true"
   android:exported="false"
   android:label="LocationLoggerServiceManager" >
  <intent-filter>
   <action android:name="android.intent.action.BOOT_COMPLETED" />
  </intent-filter>
</receiver>

또한 이 클래스는 보안 설정에 선언할 필요가 있는 특정 이벤트 브로드캐스트를 들어야 하기 때문에 manifest 파일에 RECEIVE_BOOT_COMPLETED 퍼미션이 있어야 한다.

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

위와 같이 추가해주면 부팅이 끝나고 서비스가 자동으로 실행되게 된다.




On current Android devices, we can keep only a small handful of applications
running at the same time.  Having your application do this is going to going
to take resources from other things that at any particular point in time
would be better used elsewhere.  And in fact, you can be guaranteed that
your service will -not- stay running all of the time, because there is so
much other stuff that wants to run (other background services that are only
running when needed will be prioritized over yours), or needs more memory
for what the user is actually doing (running the web browser on complicated
web pages is a great way to kick background stuff out of memory).

We have lots of facilities for implementing applications so they don't need
to do this, such as alarms, and various broadcasts from events going on in
the system.  Please please please use them if at all possible.  Having a
service run forever is pretty close to the side of evil.


지나치게 긴 작업의 경우 작업도중 죽게 된다고하네요. 이럴경우 쓰레드로 빼서 구현해야 될것 같네요..
저작자 표시 비영리 동일 조건 변경 허락
TRACKBACK ADDRESS
http://www.kmshack.kr/trackback/180 관련글 쓰기
이름 :
비밀번호 :
홈사이트 :
비밀글 :
*1  *2  *3  *4  *5  ... *58 
I am
알립니다
분류 전체보기 (173)
My (36)
Application (59)
Review (4)
Ing... (3)
Mobile Programming (42)
Lecture (2)
Interest (0)
Etc (27)
트위터
달력
«   2010/09   »
      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    
count total 45,974, today 68, yesterday 107