2012-05-09 3 views
0

메신저이 코드를 사용하는 것입니다 onRecive 기능에 디바이스 ID를 얻는 방법 :(브로드 캐스트 리시버 내부)는 onRecive하지만 난 볼 수있는 유일한 방법은 내부의 장치 ID를 얻으려고 노력

TelephonyManager tManager = (TelephonyManager)myActivity.getBaseContext().getSystemService(Context.TELEPHONY_SERVICE); 
device_id = tManager.getDeviceId(); 

하지만 내가 여기 활동에 없다. 어떻게 장치 ID를 얻을 수 있습니까? 감사합니다.

답변

3

onReceive를 사용중인 경우 컨텍스트가 있습니다. 당신은 상황이있는 경우 당신은 getSystemService를 호출 할 수 있습니다 및

+0

모자 끄기 -을 – chhameed

2

사용에게로 여기에이 같은 일을 : 당신이 남자에게

public class PhoneReceiver extends BroadcastReceiver { 
     @Override 
     public void onReceive(Context context, Intent intent) { 
     TelephonyManager tManager = (TelephonyManager)context.getSystemService(Service.TELEPHONY_SERVICE); 
     device_id = tManager.getDeviceId(); 
     } 
     } 
관련 문제