1

에뮬레이터에서 BOOAD_COMPLETED 동작으로 BROADCAST RECEIVER를 확인하고 싶습니다.BOOT_COMPLETED 브로드 캐스트 수신기를 테스트하는 방법

이 내 코드

public class AutoRunService extends BroadcastReceiver { 
@Override 
public void onReceive(Context context, Intent intent) { 
    if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { 
     Toast.makeText(UApplication.getInstance(), "Application is ready to open ", Toast.LENGTH_SHORT).show(); 

     myFunciton(context); 

    } 
} 

public void myFunciton(Context context) { 

} 

}

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

것은 나는 창 (10)와 genymotion 에뮬레이터를 사용하고 있습니다. 방송 수신기를 에뮬레이터에서 확인할 수있는 방법이 있습니까? 수신자를 확인하기 위해 에뮬레이터를 다시 시작할 수 있습니까? 직접적인 명령이 있습니까?

미리 감사드립니다.

답변

1

이동 ADB 도구 -> 고토 ADB 쉘 및 사용은 다음 명령을

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -p com.example.package 
+0

나는 그것을 시도하지만 난이 오류를 가지고, 다음과 같은 대답을 참조 in 명령 줄 @apk – BekaKK

+0

일반적으로 각 소켓 주소 (프로토콜/네트워크 주소/포트)를 한 번만 사용할 수 있습니다. (10048) ADB 서버에서 확인을 읽을 수 없습니다. 오류 : 데몬에 연결할 수 없습니다. – BekaKK

+0

일반 에뮬레이터로 시도하십시오. – apk

0

그냥 다음과 같이 onRecieve() 콜백 내에서 디버그 로그를 넣어 :

 public class AutoRunService extends BroadcastReceiver { 
     @Override 
     public void onReceive(Context context, Intent intent) { 
      if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { 
      Log.d("Boot", "completed"); // log to make sure that boot completed action is received 
      } 
     } 

을 그리고 에뮬레이터를 다시 시작

How to reboot emulator to test ACTION_BOOT_COMPLETED?

관련 문제