Tecnologia do Blogger.
RSS

[androidbrasil-dev] Re: NullPointer no método onCreate de um Service

Obrigado pela atenção.

Sim eu chamei o super.onCreate().
Estou mandando o método onCreate, não vou mandar tudo pq é muita coisa.
Mas o trecho é basicamente inicializações de campos.

O erro ocorre no:
 batteryHelper = BatteryHelper.getInstance(getBaseContext());

E quando eu rodo o Debug, a variável é instanciada corretamente.

[]s 

 @Override
    public void onCreate() {
        super.onCreate();
        
        // initiate network helper
        if (networkHelper == null)
            networkHelper = new NetworkHelper(getBaseContext(), this);
        // initiate database helper
        if (dbHelper == null)
            dbHelper = new OSDatabaseHelper(getBaseContext());
        // initiate configuration helper
        if (configHelper == null)
            configHelper = new ConfigHelper(dbHelper);
        // initiate photo manager
        if (photoManager == null)
            photoManager = new PhotoManager(getBaseContext(), dbHelper);
        // initiate battery helper
        if (batteryHelper == null)
            batteryHelper = BatteryHelper.getInstance(getBaseContext());
        // find device owner
        deviceOwner = findDeviceOwner();
        // find active workday
        activeWorkday = findActiveWorkday();
        // find active check in
        activeCheckIn = findActiveCheckIn();
        boolean isFirstLocation = activeWorkday == null || activeWorkday.geocoord == null;
        // initiate geolocation helper
        if (geoHelper == null)
            geoHelper = new GeoHelper(getBaseContext(), dbHelper, this, isFirstLocation);
        // initiate vibrator
        if (vibrator == null)
            vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        // check if application is already authenticated
        authenticated = configHelper.checkIfExists(Configs.AUTHENTICATED);
        // start to watch SMSs trying to find a sms to authenticated
        if (!authenticated && smsHelper == null) {
            // TWW: 27800
            List<String> numbersToWatches = Arrays.asList("27800");
            smsHelper = new SmsHelper(getBaseContext(), this, numbersToWatches);
        } else if (authenticated) {
            setGlobalDeviceHash();
            // start timer to check if is between 8am and 6pm
            setWorkdayAlarms();
            // Try to sync anything pendent
            dbHelper.syncAll();
        }
        // if workday is initiated start to track device
        if (activeWorkday.isInitiated())
            this.start();
        apiClient = ApiClient.getInstance(getBaseContext());
    }

Em sexta-feira, 30 de janeiro de 2015 12:25:00 UTC-2, Geovani **Leia a documentação oficial** de Souza escreveu:
Vc chamou "super.onCreate();"? Fora isso, ajudaria se vc postasse o trecho de código problemático...

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário