2012-11-30 2 views
1

여기 내 코드가 있습니다.안드로이드에서 계정 설정을 프로그래밍 방식으로 호출하는 방법

Intent i=new Intent(); 
try { 
    i.setClassName(this, (Settings.ACTION_ADD_ACCOUNT)); 
    startActivity(i); 
} 
catch(Exception e) { 
    e.printStackTrace(); 
} 

널 포인터 예외가 발생합니다. 당신은 AccountManager을 사용할 수 있습니다

+0

어디에서이 코드를 호출하고 있습니까? 또한 logcat 로그를 공유하십시오. –

+0

활동 클래스에서 이것을 호출하는 중 – Shweta

+0

장치를 시도한 다음 오류 –

답변

1

가 추가 Gmail을

를 들어이

Intent intent=new Intent(Settings.ACTION_SYNC_SETTINGS); 
startActivity(intent); 

을 시도 도와주세요.

AccountManager acm = AccountManager.get(getApplicationContext()); 
      acm.addAccount("com.google", null, null, null, thisclassname.this, 
      null, null); 
+0

Gmail 계정 추가를 시작하고 싶습니다. 그게 가능하지 않니? – Shweta

+0

Android 계정에서 Add 계정을 시작하고 싶습니다. 계정을 추가하지 않음 – Shweta

+0

"설정"또는 "계정 및 동기화 설정"또는 "계정 추가"중 열려는 화면을 선택 하시겠습니까 ?? –

관련 문제