| Nov 16 |  7:25 PM  | 
| Mark M. | has entered the room  | 
| Mark M. | turned on guest access  | 
| Steve S. | has entered the room  | 
| Mark M. | 
     hello, Steve! 
    
  
   | 
| Steve S. | 
     Hi Mark! 
    
  
   | 
| Mark M. | 
     how can I help you today? 
    
  
   | 
| Steve S. | 
     Let me paste in my question: 
    
  
   | 
| Steve S. | 
     My app requires Bluetooth communication the entire time it runs. I'm thinking of implementing it as a started service and starting the service in an Application subclass. Is that reasonable? (Note that in our application we provide the Android devices, which all run 4.4.4.)  
    
  
   | 
| Mark M. | 
     what do you mean by "the entire time it runs"? 
    
  
   | 
| Steve S. | 
     I mean from the time the is first started until it's shutdown (if it's shutdown) 
    
  
   | 
| Steve S. | 
     *the app 
    
  
   | 
| Mark M. | 
     um, that didn't help 
    
  
   | 
| Mark M. | 
     do you mean "the entire time the UI is in the foreground?", "the entire time the process is running?", "until Ft. Lauderdale freezes over?", or something else 
    
  
   | 
| Nov 16 |  7:30 PM  | 
| Steve S. | 
     Multiple activities of the app require Bluetooth, so I would like Bluetooth to be available to every activity in the app 
    
  
   | 
| Mark M. | 
     and if the user navigates away (HOME, RECENTS, etc.)... what then? 
    
  
   | 
| Steve S. | 
     This is a kiosk app, so there shouldn't be any navigation away in normal circumstances. But even if there were navigation away, it would be best if incoming Bluetooth messages kept getting received 
    
  
   | 
| Mark M. | 
     OK 
    
  
   | 
| Mark M. | 
     then the started service seems reasonable 
    
  
   | 
| Steve S. | 
     ok 
    
  
   | 
| Steve S. | 
     And starting it in onCreate of the Application subclass is a reasonable place to start it? 
    
  
   | 
| Mark M. | 
     in a kiosk situation, starting from Application is probably OK, though you could perhaps get by with just doing that in onCreate() of your launcher activity 
    
  
   | 
| Steve S. | 
     ok 
    
  
   | 
| Steve S. | 
     I have another question: 
    
  
   | 
| Steve S. | 
     View paste
 
    
  
  
 | 
| Mark M. | 
     seriously? Google shows that? 
    
  
   | 
| Mark M. | 
     all I/O on the main application thread is a bad idea 
    
  
   | 
| Mark M. | 
     I would write on a background thread 
    
  
   | 
| Steve S. | 
     ok 
    
  
   | 
| Steve S. | 
     ok 
    
  
   | 
| Steve S. | 
     I was thinking that was probably the case, but wasn't sure because of the example 
    
  
   | 
| Nov 16 |  7:35 PM  | 
| Steve S. | 
     By the way, the Google example is called BluetoothChat 
    
  
   | 
| Steve S. | 
     ok, no more questions today 
    
  
   | 
| Steve S. | 
     Thank you so much! I appreciate your guidance. 
    
  
   | 
| Mark M. | 
     FWIW, it seems like BluetoothChat is using background threads 
    
  
   | 
| Mark M. | |
| Mark M. | 
     looks like the I/O is being done by these ConnectedThread instances 
    
  
   | 
| Steve S. | 
     But not for writing, as far I can tell 
    
  
   | 
| Steve S. | 
     Yes, but not in the run() method. 
    
  
   | 
| Steve S. | 
     Maybe I'm not understanding. 
    
  
   | 
| Mark M. | 
     ah 
    
  
   | 
| Mark M. | 
     yeah, that's probably just a bug 
    
  
   | 
| Mark M. | 
     this example is as old as the hills 
    
  
   | 
| Mark M. | 
     (I think the 2014 copyright date lies) 
    
  
   | 
| Steve S. | 
     it's the only example I've ever been able to find 
    
  
   | 
| Mark M. | 
     yeah, maybe in 2017, I'll get around to writing about Bluetooth 
    
  
   | 
| Mark M. | 
     er, 2018 
    
  
   | 
| Steve S. | 
     and everybody else who has an example that I've found has based it on BluetoothChat, perpetuating that bug 
    
  
   | 
| Mark M. | 
     groovy 
    
  
   | 
| Mark M. | 
     ah well, no rest for the weary, and all that 
    
  
   | 
| Steve S. | 
     it would be great if you could write about it 
    
  
   | 
| Mark M. | 
     it's on one of my many lists 
    
  
   | 
| Steve S. | 
     i have a rewritten version of BluetoothChat that does the write off the main thread, so i'll stick with that then 
    
  
   | 
| Nov 16 |  7:40 PM  | 
| Mark M. | 
     sounds like a plan 
    
  
   | 
| Steve S. | 
     i'm going to post a comment to a Stackoverflow post about this issue. Would it be ok if i mention your view (with proper attribution)? 
    
  
   | 
| Mark M. | 
     sure 
    
  
   | 
| Steve S. | 
     thanks so much 
    
  
   | 
| Mark M. | 
     you're very welcome! 
    
  
   | 
| Steve S. | 
     you've solved all my problems today! 
    
  
   | 
| Mark M. | 
     that seems a bit over the top 
    
  
   | 
| Steve S. | 
     well, maybe a little... 
    
  
   | 
| Steve S. | 
     have a great rest of the day 
    
  
   | 
| Mark M. | 
     you too! 
    
  
   | 
| Steve S. | has left the room  | 
| Nov 16 |  8:25 PM  | 
| Mark M. | turned off guest access  |