Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] Rodar aplicativos em segundo plano.

Pessoal, vocês poderiam me esclarecer uma dúvida, por favor. 
O Android ele pode a qualquer momento parar um aplicativo por questões de gerenciamento de recursos. Pergunto: Este código postado anteriormente fará com que o Android não "mate" o aplicativo?

Desde já, agradeço a atenção de todos.

Tiago Sousa Rocha
Desenvolvedor de Hardware e Analista de Sistemas

Contato:
(83) 8801-8575
(83) 8111-5793
(83) 9654-1382

http://tiagorocha.net/
skype: tiagosousarocha


Em 23 de janeiro de 2014 09:58, Gabriel Augusto <gabrielaugustodm@gmail.com> escreveu:
Faço exatamente assim! O Service inicia, faz o seu trabalho e agenda com o AlarmManager para a próxima.

Em paralelo, recebo notificações por GCM quando (por algum motivo) o serviço foi interrompido, ou quando simplesmente o usuario deseja uma posição no momento.

--
Gabriel Augusto 
 |  gabrielaugustodm


Em 20 de janeiro de 2014 17:14, George Henrique Silva <ghsilva@gmail.com> escreveu:
A resposta é o wake lock, mas se você deseja fazer um tracking menos preciso mas que gaste menos energia eu recomendo usar o Alarm Manager e "agendar" a cada 5, 10 ou 30 minutos para que seu serviço execute, colha a informação e entregue o resultado ao servidor, assim a sua bateria vai durar muito mais.

George H. Silva
__
Android Community Manager
Intel do Brasil


2014/1/20 Pedro Cortez <pedro.fellipe.cortez@gmail.com>
Eu tenho um app que faz isso tambem... O Wake lock que resolveu

att,
Pedro Cortez


2014/1/20 Jones Almeida <jonesalmeida@gmail.com>
Bom sendo um pouco mais claro, o que eu não entendi, é onde e quando vc da o  mWakelock.acquire(),
Para ele ficar rodando sempre... se depois de 5 segundos vc sempre da o mWakelock.release() .

Obrigado desde já, isso pode solucionar um problema meu....


Em 20 de janeiro de 2014 13:43, Jones Almeida <jonesalmeida@gmail.com> escreveu:

Então não seria assim ?

 Timer timer = new Timer();
            TimerTask task = new TimerTask() {
                public void run() {
                    mWakelock.release();
                    mWakelock.acquire();
                }
            };
            timer.schedule(task, 5000);
        }


Em 20 de janeiro de 2014 13:11, marcelo yonamine <yonamine60@gmail.com> escreveu:

É que o serviço não pode entrar no modo de economia de energia, não teria como receber notificações. A cada 5 segundos o código da uma "cutucada" para confirmar se o serviço não "dormiu".   


Em 20 de janeiro de 2014 11:46, Jones Almeida <jonesalmeida@gmail.com> escreveu:

É que a notificação BOOT_COMPLETED, vc recebe só depois de reiniciar o aparelho correto.

E ai vc vai dar um adquire, e depois de 5 segundos ele volta a dormir, correto?

Então vc coloca o adquire dentro de outro lanço... correto ? Se não ele dorme depois de 5 segundo e não volta mais....


Desculpe estou tentando entender o código.


Em 20 de janeiro de 2014 11:21, marcelo yonamine <yonamine60@gmail.com> escreveu:
"Mais porque depois de 5 segundos, vc libera ?"
"economia-descanso" no processamento


Em 20 de janeiro de 2014 11:13, Jones Almeida <jonesalmeida@gmail.com> escreveu:

Legal seu código, sobre o WakeLock.
Mais porque depois de 5 segundos, vc libera ?



Em 20 de janeiro de 2014 10:59, marcelo yonamine <yonamine60@gmail.com> escreveu:

Tenho um app de geolocalização rodando como serviço com base no GCM, não dorme nunca.
Para fazer isso: permissão e receiver
<receiver android:name="com.test.exemplo.PollReceiver"
            android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
                        <intent-filter>
                                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                        </intent-filter>
                </receiver>


permissão <uses-permission android:name="android.permission.WAKE_LOCK" />


Dentro do código do service tem


        {
            // Wake Android Device when notification received
            PowerManager pm = (PowerManager) context
                    .getSystemService(Context.POWER_SERVICE);
            final PowerManager.WakeLock mWakelock = pm.newWakeLock(
                    PowerManager.FULL_WAKE_LOCK
                            | PowerManager.ACQUIRE_CAUSES_WAKEUP, "GCM_PUSH");
            mWakelock.acquire();

            // Timer before putting Android Device to sleep mode.
            Timer timer = new Timer();
            TimerTask task = new TimerTask() {
                public void run() {
                    mWakelock.release();
                }
            };
            timer.schedule(task, 5000);
        }




Em 20 de janeiro de 2014 10:21, Manoel Canhos <manoel.canhos@gmail.com> escreveu:

vou tentar refazer o serviço, devo estar fazendo algo errado.


Em 20 de janeiro de 2014 10:12, Tiago Sousa Rocha <tsrrocha@gmail.com> escreveu:

Quem determina isso é o App. Ele pode permanecer ligado tranquilamente mas você deve fazer o controle disso em sua App.

Tiago Sousa Rocha
Desenvolvedor de Hardware e Analista de Sistemas

Contato:
(83) 8801-8575
(83) 8111-5793
(83) 9654-1382

http://tiagorocha.net/
skype: tiagosousarocha


Em 20 de janeiro de 2014 09:11, Henrique Melo <henrique1985@gmail.com> escreveu:

Pelo que eu sei, o gps é desativado ao ter a tela apagada.
Tanto que alguns apps que possuem controle de corrida, só funcionam com a tela ligada.
Agora não sei se isso se aplica caso seu app/serviço seja de sistema.


Em 20 de janeiro de 2014 08:07, Tiago Sousa Rocha <tsrrocha@gmail.com> escreveu:

Olha, tenho uma aplicação que coleta dados de localização, ela é um serviço e não para quando a tela é desligada. Apenas quando está utilizando apenas a conexão WiFi, o app perde conexão com a NET, mas continua a coletar e armazenar como OFF-Line e depois descarrega para o server.

Tiago Sousa Rocha
Desenvolvedor de Hardware e Analista de Sistemas

Contato:
(83) 8801-8575
(83) 8111-5793
(83) 9654-1382

http://tiagorocha.net/
skype: tiagosousarocha


Em 20 de janeiro de 2014 08:23, Jones Almeida <jonesalmeida@gmail.com> escreveu:

Pelo que notei o Android, querendo ou não para o WIFI, e as vezes até para o serviço quando a tela apaga, pra poupar energia.... Já tentei de tudo também e continua desta forma. É alguma coisa interna do Android.
Coloca o celular direto na energia, e você vai que não para.



Em 20 de janeiro de 2014 08:50, Rudson Lima <rudsonlive@gmail.com> escreveu:

Ai complicou o-O;; Nunca implementei um serviço no Android e se desse pelo erro poderia tentar lhe ajudar...

Mas ele continua rodando e deixa de enviar as informações ou o Android fecha seu serviço?

Se ele tiver fechando não existe nenhuma permissão que você possa colocar para que ele não feche seu serviço?

Boa sorte..


2014/1/20 Manoel Canhos <manoel.canhos@gmail.com>
Ele nao da erro, primeiramente ele esta enviando normal ai quando a tela apaga para de enviar.


2014/1/20 Rudson Lima <rudsonlive@gmail.com>
Já testou Debug? O que o LogCat mostra?  Da algum erro?


2014/1/20 Manoel Canhos <manoel.canhos@gmail.com>
Sim.


Em 20 de janeiro de 2014 08:37, Rudson Lima <rudsonlive@gmail.com> escreveu:
Seu app é um serviço?


Em 20 de janeiro de 2014 07:35, Manoel Canhos <manoel.canhos@gmail.com> escreveu:
Olá, tenho o seguinte problema.
Tenho um aplicativo que fica pegando a posição atual do celular e enviando sua posição para um servidor na web, até ai esta tudo em ordem.
Só que o que acontece é que quando a tela do celular apaga o aplicativo para de enviar a posição, como faço para ele ficar rodando em segundo plano e continuar enviando a posição mesmo com a tela apagada ? 

Celular usado para testes Samsung Galaxy Y e Motorola moto A953.

--
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/groups/opt_out.



--
Rudson Lima ( live-O )
Desenvolvedor Android - Web Service C# - SQL Server - Delphi
+55 85 87050560 - Fortaleza-ce

--
You received this message because you are subscribed to a topic in the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/androidbrasil-dev/u0v0dxf8KSQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
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/groups/opt_out.



--
Rudson Lima ( live-O )
Desenvolvedor Android - Web Service C# - SQL Server - Delphi
+55 85 87050560 - Fortaleza-ce

--
You received this message because you are subscribed to a topic in the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/androidbrasil-dev/u0v0dxf8KSQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/groups/opt_out.



--
Rudson Lima ( live-O )
Desenvolvedor Android - Web Service C# - SQL Server - Delphi
+55 85 87050560 - Fortaleza-ce

--
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/groups/opt_out.

--
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/groups/opt_out.

--
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/groups/opt_out.



--
Henrique Nogueira de Melo
Analista e Arquiteto de Software

--
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/groups/opt_out.

--
You received this message because you are subscribed to a topic in the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/androidbrasil-dev/u0v0dxf8KSQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/groups/opt_out.

--
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/groups/opt_out.

--
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/groups/opt_out.

--
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/groups/opt_out.

--
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/groups/opt_out.

--
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/groups/opt_out.


--
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/groups/opt_out.

--
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/groups/opt_out.



--
--
George Henrique Silva

--
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/groups/opt_out.

--
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/groups/opt_out.

--
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/groups/opt_out.

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

0 comentários:

Postar um comentário