Pass Activity to Class data

0

Partners, I am sending values to my Service.class from the following activity:

But in service.class the getIntent does not take me (being a class)

I need to pass PimActivity data to service and then in service send data to a thirdActivity. (At the third activity, I sent it with putextra, that's a solution)

    
asked by AldazDev 24.01.2018 в 08:00
source

1 answer

0

If the service exhausts from Service :

 extends Service {

The values you send through Intent

   Intent i = new Intent(this, Servicio.class);
   i.putExtra("cantidadMonedas", stCantMonedas);
   startService(i);

must be obtained in the Service within onStartCommand()

   public int onStartCommand(Intent intent, int flags, int startId) {
           if (intent != null && intent.hasExtra("cantidadMonedas")) {
                String valorObtenido = intent.getStringExtra("cantidadMonedas");
            }

        return Service.START_NOT_STICKY;
    }
    
answered by 24.01.2018 в 17:20