2012-09-15 2 views
-2

안드로이드에서 다음 코드간에 차이가 있습니까?Intent 생성자를 사용하는 방법?

  1. 새로운 인 텐트 (this, MyOtherActivity.class);
  2. 새로운 인 텐트 (Context.this, MyOtherActivity.class);
  3. 새로운 인 텐트 (getApplicationContext(), MyOtherActivity.class);

자세한 내용을 설명해주십시오. 예제 코드도 환영합니다.

미리 감사드립니다.

+0

당신은 * * [문서 및 가이드]를 읽어야합니다 (http://developer.android.com/guide/components/intents-filters.html) – adatapost

+0

왜 물어? –

답변

1
1> new Intent(this, MyOtherActivity.class); here this means the context of your current 
    activity 
    3> new Intent(getApplicationContext(), MyOtherActivity.class); here getApplicationContext() means the context of your application. 
+0

이 컨텍스트 또는 응용 프로그램 컨텍스트를 사용할 때 확인하십시오. – Selva

+0

서비스와 같은 장기 실행 프로세스의 경우 응용 프로그램 컨텍스트를 사용하십시오. – Rajendra

+0

감사합니다. rajuendra – Selva

관련 문제