Android Studio Tutorial - 52 - Services & Thread

preview_player
Показать описание
Always use a separate thread for service and do not use the main GUI thread . If you use the main GUI thread for service, it may cause the the Application Not Responding Error (ANR) . This video demonstrate how to create a separate thread for your service.
Рекомендации по теме
Комментарии
Автор

Thank you very much Prabeesh for creating this helpful tutorial....learning a lot from your videos.

sameerk
Автор

The tutorial series is really helpful sir.

SajalTyagi
Автор

Hi Prabeesh. Thank you for great tutorial . I have a question though. MyService class involves a callback, LocationListener onLocationChanged, does the newly created thread handle the callback or main thread handles it ? Please let me khow

swethats
Автор

Great tutorial, I have a question, please help me: We only can create one service at a time?

jmariovt
Автор

You are perfect my brother congratulations.

hasanpacac
Автор

Thank you very much for the video. Clear and easy to understand.

hosha
Автор

Hi Prabeesh! I removed the code inside from run and why the service finish in aproximately 10 seconds alone? Thank you!

ricardogomes
Автор

You are the best!
Great tutorial. Thank you !

ricardogomes
Автор

hlo sir, great tutorial.can you create a video for push notification in a webview service?? thanks in advance...

sreepriyanousapp
Автор

hi sir,
I was having a task like, where i have to insert/update A LOT OF DATA like 1000 rows with 80 colums each in the sqlite local DB, for that i was creating a thread.. in that thread i was creating a method like dbLogic(), the thing is after completion of the task i.e; insertion/updation completion i have to show an alert dialog, that alert dialog code i have written normally not in the thread..In some times the main problem causing is, the alert dialog is coming before only unless my another thread doesn't completed its work, i was trying to store 1000 data, in some times it was storing 200 data and the alert was coming, in some times it was storing 400 data alert was coming, in sometimes it was storing 550 or 600 or 650 the alert box was coming.. what i need is after successfully completion of the task only my main thread should execute. i heard that thread is an independent process... what to do please help me..

suneelkumar-hmkd
Автор

is it possible to use Async task instead of a service + thread?

yasminedwedar
Автор

why are you use syncronized function ? as it is in the same thread

amrashraf
Автор

I have a problem when i had used the thread (ANR), and Start it is not working, i have to replace it with Run

lukalionc
Автор

I have a switch button in my android application.
I make a thread which work is randomly flashing. I put a Start method
when switch button is on and interrupt the method when the button is of.
It works the first time but the second time when I touch the switch
button the application ends automatically. I press the button then the
random flashing work then I stop the button and the flashing stops but
when I start it again with the button the app stops by itself.
xx=new Runnable()
{
@Override
public void run()
{
synchronized (this)
{
while (true)
{
try {




camera.stopPreview();

c1.sleep(100);


camera.startPreview();
//c1.interrupt();


}
catch (Exception e)
{

break; //this is a MUST

}

}
}
}
//}

};


c1 =new Thread(xx);

{
public void buttonView, boolean isChecked) {
if (s1.isChecked())

{
c1.start();
}
else
{
c1.interrupt();

}

}

});

anikaanik
Автор

if we use seperate thread, whats the meaning of using service

gurkanlus
Автор

i don't think that thread will stop coz it doesnot have intrrupt in it as for the service i know it will stop but

deadpiece
Автор

Make a video on service which gives toast for every 10sec even when the app is closed

TRK
Автор

I cannot understand anything U R saying!

iadorakelley