On Monday, April 30, 2012 9:34:57 PM UTC+2, Kristopher Micinski wrote:
> Except that a service runs in the main application thread by default,
> so even if you're running it in a service you'll still need a thread
> and some way to communicate with it.
> yes, using an AsyncTask would be an alternative, and what is typically
> done in these situations where you're waiting for data to load.
> Kris
> On Mon, Apr 30, 2012 at 3:29 AM, Kamran Shamim <krsha...@gmail.com>
> wrote:
> > Thank you , Kristopher. That is an interesting read. This is an
> interesting
> > discussion as it addresses a (probably) common situation.
> > My penny's worth: Would it not be better to run the connection through a
> > service, rather than a thread? I have a feeling that this would be
> easier to
> > manage in the case described.
> > An alternative would be to use an AsyncTask and use cancel(booelan) to
> stop
> > it, and isCancelled() in the task (and therefore the thread essentially
> > watches itself to speed up the kill).
> > On Monday, 30 April 2012 06:47:03 UTC+2, Kristopher Micinski wrote:
> >> read this:
> http://docs.oracle.com/javase/1.5.0/docs/guide/misc/threadPrimitiveDe...
> >> On Mon, Apr 30, 2012 at 12:33 AM, Matt Clark <mrclark32...@gmail.com>
> >> wrote:
> >> > What do you mean use flags?
> >> > The app hangs on lines that wait for an HTTP response, so i want to
> be
> >> > able
> >> > to just cut them off mid execution if I have to, i cant call check
> >> > statements before and after.
> >> > Sorry, I do not know a whole lot about Threading.
> >> > On Monday, April 30, 2012 12:09:25 AM UTC-4, Ankita wrote:
> >> >> stop(),destroy() etc. methods were deprecated by JDK versions, so
> must
> >> >> have not got support now. To stop thread, you should try to use
> flags,
> >> >> AFAIK.
> >> >> On Mon, Apr 30, 2012 at 9:34 AM, Matt Clark <mrclark32...@gmail.com>
> >> >> wrote:
> >> >>> I am creating an app that sends various HTTP requests in seperate
> >> >>> threads, while doing so brings up a loading screen. If the network
> >> >>> request
> >> >>> is taking longer then the user expects, I want them to be able to
> >> >>> press the
> >> >>> back button to force quit the thread, and dismiss the loading
> screen.
> >> >>> I have my thread set up as:
> >> >>> dataThread = new Thread(new Runnable() {
> >> >>> public void run() {
> >> >>> //...
> >> >>> //Networking Data and Handlers
> >> >>> //...
> >> >>> }
> >> >>> });
> >> >>> dataThread.start();
> >> >>> and where I want to force quit at onBackPressed() I have tried:
> >> >>> dataThread.stop();
> >> >>> dataThread.destroy();
> >> >>> dataThread.interrupt();
> >> >>> And none of them work, Android does not support stop(), or
> destroy(),
> >> >>> and
> >> >>> interrupt() does nothing to stop the thread. I do not care about
> >> >>> exceptions
> >> >>> as everything will be caught, I just want it to allow the user to
> >> >>> resume
> >> >>> doing what they want, if it hangs on requests, or even retry the
> >> >>> request..
> >> >>> Any and all help is greatly appreciated.
> >> >>> ~Matt
> >> >>> --
> >> >>> You received this message because you are subscribed to the Google
> >> >>> Groups "Android Developers" group.
> >> >>> To post to this group, send email to
> >> >>> android-developers@googlegroups.com
> >> >>> To unsubscribe from this group, send email to
> >> >>> android-developers+unsubscribe@googlegroups.com
> >> >>> For more options, visit this group at
> >> >>> http://groups.google.com/group/android-developers?hl=en
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups "Android Developers" group.
> >> > To post to this group, send email to
> android-developers@googlegroups.com
> >> > To unsubscribe from this group, send email to
> >> > android-developers+unsubscribe@googlegroups.com
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/android-developers?hl=en
> > On Monday, 30 April 2012 06:47:03 UTC+2, Kristopher Micinski wrote:
> >> read this:
> http://docs.oracle.com/javase/1.5.0/docs/guide/misc/threadPrimitiveDe...
> >> On Mon, Apr 30, 2012 at 12:33 AM, Matt Clark <mrclark32...@gmail.com>
> >> wrote:
> >> > What do you mean use flags?
> >> > The app hangs on lines that wait for an HTTP response, so i want to
> be
> >> > able
> >> > to just cut them off mid execution if I have to, i cant call check
> >> > statements before and after.
> >> > Sorry, I do not know a whole lot about Threading.
> >> > On Monday, April 30, 2012 12:09:25 AM UTC-4, Ankita wrote:
> >> >> stop(),destroy() etc. methods were deprecated by JDK versions, so
> must
> >> >> have not got support now. To stop thread, you should try to use
> flags,
> >> >> AFAIK.
> >> >> On Mon, Apr 30, 2012 at 9:34 AM, Matt Clark <mrclark32...@gmail.com>
> >> >> wrote:
> >> >>> I am creating an app that sends various HTTP requests in seperate
> >> >>> threads, while doing so brings up a loading screen. If the network
> >> >>> request
> >> >>> is taking longer then the user expects, I want them to be able to
> >> >>> press the
> >> >>> back button to force quit the thread, and dismiss the loading
> screen.
> >> >>> I have my thread set up as:
> >> >>> dataThread = new Thread(new Runnable() {
> >> >>> public void run() {
> >> >>> //...
> >> >>> //Networking Data and Handlers
> >> >>> //...
> >> >>> }
> >> >>> });
> >> >>> dataThread.start();
> >> >>> and where I want to force quit at onBackPressed() I have tried:
> >> >>> dataThread.stop();
> >> >>> dataThread.destroy();
> >> >>> dataThread.interrupt();
> >> >>> And none of them work, Android does not support stop(), or
> destroy(),
> >> >>> and
> >> >>> interrupt() does nothing to stop the thread. I do not care about
> >> >>> exceptions
> >> >>> as everything will be caught, I just want it to allow the user to
> >> >>> resume
> >> >>> doing what they want, if it hangs on requests, or even retry the
> >> >>> request..
> >> >>> Any and all help is greatly appreciated.
> >> >>> ~Matt
> >> >>> --
> >> >>> You received this message because you are subscribed to the Google
> >> >>> Groups "Android Developers" group.
> >> >>> To post to this group, send email to
> >> >>> android-developers@googlegroups.com
> >> >>> To unsubscribe from this group, send email to
> >> >>> android-developers+unsubscribe@googlegroups.com
> >> >>> For more options, visit this group at
> >> >>> http://groups.google.com/group/android-developers?hl=en
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups "Android Developers" group.
> >> > To post to this group, send email to
> android-developers@googlegroups.com
> >> > To unsubscribe from this group, send email to
> >> > android-developers+unsubscribe@googlegroups.com
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/android-developers?hl=en
> > On Monday, 30 April 2012 06:47:03 UTC+2, Kristopher Micinski wrote:
> >> read this:
> http://docs.oracle.com/javase/1.5.0/docs/guide/misc/threadPrimitiveDe...
> >> On Mon, Apr 30, 2012 at 12:33 AM, Matt Clark <mrclark32...@gmail.com>
> >> wrote:
> >> > What do you mean use flags?
> >> > The app hangs on lines that wait for an HTTP response, so i want to
> be
> >> > able
> >> > to just cut them off mid execution if I have to, i cant call check
> >> > statements before and after.
> >> > Sorry, I do not know a whole lot about Threading.
> >> > On Monday, April 30, 2012 12:09:25 AM UTC-4, Ankita wrote:
> >> >> stop(),destroy() etc. methods were deprecated by JDK versions, so
> must
> >> >> have not got support now. To stop thread, you should try to use
> flags,
> >> >> AFAIK.
> >> >> On Mon, Apr 30, 2012 at 9:34 AM, Matt Clark <mrclark32...@gmail.com>
> >> >> wrote:
> >> >>> I am creating an app that sends various HTTP requests in seperate
> >> >>> threads, while doing so brings up a loading screen. If the network
> >> >>> request
> >> >>> is taking longer then the user expects, I want them to be able to
> >> >>> press the
> >> >>> back button to force quit the thread, and dismiss the loading
> screen.
> >> >>> I have my thread set up as:
> >> >>> dataThread = new Thread(new Runnable() {
> >> >>> public void run() {
> >> >>> //...
> >> >>> //Networking Data and Handlers
> >> >>> //...
> >> >>> }
> >> >>> });
> >> >>> dataThread.start();
> >> >>> and where I want to force quit at onBackPressed() I have tried:
> >> >>> dataThread.stop();
> >> >>> dataThread.destroy();
> >> >>> dataThread.interrupt();
> >> >>> And none of them work, Android does not support stop(), or
> destroy(),
> >> >>> and
> >> >>> interrupt() does nothing to stop the thread. I do not care about
> >> >>> exceptions
> >> >>> as everything will be caught, I just want it to allow the user to
> >> >>> resume
> >> >>> doing what they want, if it hangs on requests, or even retry the
> >> >>> request..
> >> >>> Any and all help is greatly appreciated.
> >> >>> ~Matt
> >> >>> --
> >> >>> You received this message because you are subscribed to the Google
> >> >>> Groups "Android Developers" group.
> >> >>> To post to this group, send email to
> >> >>> android-developers@googlegroups.com
> >> >>> To unsubscribe from this group, send email to
> >> >>> android-developers+unsubscribe@googlegroups.com
> >> >>> For more options, visit this group at
> >> >>> http://groups.google.com/group/android-developers?hl=en
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups "Android Developers" group.
> >> > To post to this group, send email to
> android-developers@googlegroups.com
> >> > To unsubscribe from this group, send email to
> >> > android-developers+unsubscribe@googlegroups.com
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/android-developers?hl=en
> > On Monday, 30 April 2012 06:47:03 UTC+2, Kristopher Micinski wrote:
> >> read this:
> http://docs.oracle.com/javase/1.5.0/docs/guide/misc/threadPrimitiveDe...
> >> On Mon, Apr 30, 2012 at 12:33 AM, Matt Clark <mrclark32...@gmail.com>
> >> wrote:
> >> > What do you mean use flags?
> >> > The app hangs on lines that wait for an HTTP response, so i want to
> be
> >> > able
> >> > to just cut them off mid execution if I have to, i cant call check
> >> > statements before and after.
> >> > Sorry, I do not know a whole lot about Threading.
> >> > On Monday, April 30, 2012 12:09:25 AM UTC-4, Ankita wrote:
> >> >> stop(),destroy() etc. methods were deprecated by JDK versions, so
> must
> >> >> have not got support now. To stop thread, you should try to use
> flags,
> >> >> AFAIK.
> >> >> On Mon, Apr 30, 2012 at 9:34 AM, Matt Clark <mrclark32...@gmail.com>
> >> >> wrote:
> >> >>> I am creating an app that sends various HTTP requests in seperate
> >> >>> threads, while doing so brings up a loading screen. If the network
> >> >>> request
> >> >>> is taking longer then the user expects, I want them to be able to
> >> >>> press the
> >> >>> back button to force quit the thread, and dismiss the loading
> screen.
> >> >>> I have my thread set up as:
> >> >>> dataThread = new Thread(new Runnable() {
> >> >>> public void run() {
> >> >>> //...
> >> >>> //Networking Data and Handlers
> >> >>> //...
> >> >>> }
> >> >>> });
> >> >>> dataThread.start();
> >> >>> and where I want to force quit at onBackPressed() I have tried:
> >> >>> dataThread.stop();
> >> >>> dataThread.destroy();
> >> >>> dataThread.interrupt();
> >> >>> And none of them work, Android does not support stop(), or
> destroy(),
> >> >>> and
> >> >>> interrupt() does nothing to stop the thread. I do not care about
> >> >>> exceptions
> >> >>> as everything will be caught, I just want it to allow the user to
> >> >>> resume
> >> >>> doing what they want, if it hangs on requests, or even retry the
> >> >>> request..
> >> >>> Any and all help is greatly appreciated.
> >> >>> ~Matt
> >> >>> --
> >> >>> You received this message because you are subscribed to the Google
> >> >>> Groups "Android Developers" group.
> >> >>> To post to this group, send email to
> >> >>> android-developers@googlegroups.com
> >> >>> To unsubscribe from this group, send email to
> >> >>> android-developers+unsubscribe@googlegroups.com
> >> >>> For more options, visit this group at
> >> >>> http://groups.google.com/group/android-developers?hl=en
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups "Android Developers" group.
> >> > To post to this group, send email to
> android-developers@googlegroups.com
> >> > To unsubscribe from this group, send email to
> >> > android-developers+unsubscribe@googlegroups.com
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/android-developers?hl=en
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/android-developers?hl=en