Office Hours — Today, April 16

Tuesday, April 14

Mark M.
has entered the room
Mark M.
turned on guest access
IpiRon
has entered the room
IpiRon
Hello to all
Mark M.
hello, IpiRon!
how can I help you today?
MyWay
has entered the room
MyWay
hi all
IpiRon
View paste (8 more lines)
I have to develop an app that will communicate with a 3rd party device. At this point in time I don't know much about the 3rd party device 

other than it connects to the USB port and will probably simulate serial I/O to send data to the Android. I'm trying to get ahead of the game 

and figure out how I can have the 3rd party device connected along with my development PC so I can debug my app as I develop it against the 

3rd party device.

I connected a powered 4 port USB hub to my Android device USB and then connected to my development PC to the hub but DDMS did not recognize my 

Android device. I've Googled on this and see posts that indicate people do have success connecting a hub and things like a keyboard, mouse, 

etc. to the hub.

I have seen a couple of obscure posts on 'Host Mode Debugging' and 'Debugging over Ethernet' but the instructions seem a bit vague. (I've only 
...
Mark M.
hello, MyWay!
MyWay: IpiRon beat you into the room by a bit, so I'll take his question first and will be back to you shortly
MyWay
ahah, sure :)
Mark M.
IpiRon: OK, I'm lost already :-(
the third-party device is not an Android device, right?
IpiRon
Correct
Mark M.
and it connects to an Android device via USB OTG?
IpiRon
Correct
Apr 16
4:00 PM
Mark M.
um, then unless there's a USB hub and an Android device can can simultaneously act as host and client, I don't think what you want to do with the hub is possible
with normal adb debugging, the Android device acts as a USB client, not as a host
IpiRon
Okay, are you familiar with debugging over ethernet?
Mark M.
WiFi, yes; Ethernet, no, because most Android devices do not have Ethernet ports
though it probably works the same
IpiRon
Wifi would work for me. Can you point me to any instructions?
Mark M.
you are looking for the "adb connect" command
IpiRon
Are there ADB commands executes on my development PC or in the Android device?
Mark M.
these are all on your development PC
you briefly use a USB cable to "bootstrap" the WiFi debugging
then, you should be able to switch over to using the USB port for your third-party device
IpiRon
Okay, I'll check out the link and get back with you. You can proceed with next chatter!
Mark M.
OK
MyWay: over to you! do you have a question?
MyWay
Mark, do you plan to add a small section about AccountManager in the book, to store users' credentials and so avoiding bad practices?
Mark M.
do I plan to cover AccountManager someday? yes
4:05 PM
Mark M.
that being said, AccountManager is definitely "an acquired taste"
MyWay
what do you mean?
Mark M.
too many nasty-sounding permissions, for one
MyWay
ah
so not in the short-term, probably
thank you anyway (I don't have other questions)
Mark M.
I won't cover it until I have alternatives that provide good security that I can write about as well (e.g., storing generated keys in KeyStore)
MyWay
ah, nice
Mark M.
I understand your security concerns; I just don't think that AccountManager was especially well-thought-out
if you come up with another question while you're still in the chat room, tap me on the virtual shoulder
in the meantime...
IpiRon: back to you!
MyWay
sure, thank you
IpiRon
The link you sent is a good place for me to start. I'm done for today. Thanks!!!
IpiRon
has left the room
4:30 PM
EGHDK
has entered the room
Mark M.
hello, EGHDK!
EGHDK: MyWay is currently out of questions, so... do you have a question?
EGHDK
Hey Mark, hopefully a single simple question for you. I'm trying to get the intent flags from an activity but all I get is a number. How can I tell what the flag is?
Mark M.
compare it to the values
all those flags are numbers
FLAG_ACTIVITY_BROUGHT_TO_FRONT is 0x00400000
EGHDK
So what do I do for combined flags. Like using the pipe symbol
Mark M.
those flags are usually just individual bits or simple bitmasks
so, you would need to see if the bits in the value you get from the Intent have the bits that you are seeking from a flag
4:35 PM
Mark M.
EGHDK
Okay. I'll look into it. Thanks. Oh another question actually. On a reddit discussion someone asked how many httpclients an app should use. There wasn't a canonical answer but having a static httpclient in the app class seemed to be a favorite. Thoughts?
Mark M.
if you literally mean HttpClient, the correct answer for the past couple of years has been "zero"
Android's HttpClient was formally deprecated in Android 5.1, but Google has been steering developers away from it for a couple of years
EGHDK
Well not Apache. I'm going to use okhttp
Mark M.
you would have to check the OkHttp docs to see what scope they recommend
EGHDK
But I don't know where to out my client and whether it should be static member of app class.
Okay. I'll prod around some more
Mark M.
again, the answer to that is VERY dependent on whose API you are using
the answer for HttpClient could differ from OkHttp, which could differ from HttpUrlConnection, which could differ from Ion, etc.
4:40 PM
EGHDK
Interesting that it is dependent on that. It makes sense to me that one application would have one httpclient
Mark M.
you are welcome to your opinion
and with HttpClient itself, there are reasons for doing that
however, different developers of different HTTP client libraries may have different philosophies
EGHDK
Ok. I'll look into it more.
4:55 PM
Mark M.
we're running out of time -- anyone have any questions?
5:00 PM
EGHDK
has left the room
Mark M.
well, that's a wrap for today's chat
the transcript will be posted to http://commonsware.com/office-hours/ shortly
the next one is Wednesday at 7:30pm US Eastern
have a pleasant day!
MyWay
has left the room
Mark M.
turned off guest access

Tuesday, April 14

 

Office Hours

People in this transcript

  • EGHDK
  • IpiRon
  • Mark Murphy
  • MyWay