@Test public void testNotify() { Intent intent = new Intent(ApplicationProvider.getApplicationContext(), TestService.class); intent.putExtra("code", "1234"); intent.setAction(""); controller = Robolectric.buildService(TestService.class, intent); service = controller.create().get(); service.notify("test"); }
public void notify(String message) { Intent intent = null; switch (serviceState) { case STOPPED: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case ADVERTISING: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTING: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTED: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; default: Log.e(TAG, "Unknown state"); break; } raiseNotification(buildForegroundNotification(message, intent)); }
NearbyService extends IntentService { public void notify(String message) { Intent intent = null; switch (serviceState) { case STOPPED: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case ADVERTISING: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTING: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTED: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; default: Log.e(TAG, "Unknown state"); break; } raiseNotification(buildForegroundNotification(message, intent)); } }
NearbyService extends IntentService { public void notify(String message) { Intent intent = null; switch (serviceState) { case STOPPED: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case ADVERTISING: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTING: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTED: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; default: Log.e(TAG, "Unknown state"); break; } raiseNotification(buildForegroundNotification(message, intent)); } NearbyService(); }
NearbyService extends IntentService { public void notify(String message) { Intent intent = null; switch (serviceState) { case STOPPED: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case ADVERTISING: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTING: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTED: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; default: Log.e(TAG, "Unknown state"); break; } raiseNotification(buildForegroundNotification(message, intent)); } NearbyService(); static String[] getRequiredPermissions(); @Override int onStartCommand(@Nullable Intent intent, int flags, int startId); void notify(String message); NearbyState getServiceState(); void setServiceState(NearbyState state, @Nullable String message); static Intent createNearbyIntent(String state, Context context); void handleResponse(boolean error, String message); void handlePayload(Payload payload); void handlePayloadTransferUpdate(PayloadTransferUpdate update); void start(); void stop(); void setNearbyCode(String code); String getNearbyCode(); void sendBroadcastMessage(String message); }
NearbyService extends IntentService { public void notify(String message) { Intent intent = null; switch (serviceState) { case STOPPED: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case ADVERTISING: intent = new Intent(this, ShowCodeActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTING: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; case CONNECTED: intent = new Intent(this, ConnectionSetupActivity.class); intent.putExtra("code", getNearbyCode()); break; default: Log.e(TAG, "Unknown state"); break; } raiseNotification(buildForegroundNotification(message, intent)); } NearbyService(); static String[] getRequiredPermissions(); @Override int onStartCommand(@Nullable Intent intent, int flags, int startId); void notify(String message); NearbyState getServiceState(); void setServiceState(NearbyState state, @Nullable String message); static Intent createNearbyIntent(String state, Context context); void handleResponse(boolean error, String message); void handlePayload(Payload payload); void handlePayloadTransferUpdate(PayloadTransferUpdate update); void start(); void stop(); void setNearbyCode(String code); String getNearbyCode(); void sendBroadcastMessage(String message); static final String TAG; static final String ACTION_START; static final String ACTION_STOP; static final String VIDEO_START; }