May 13 | 8:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Mark M. |
test
|
May 13 | 9:05 AM |
jamshaid | has entered the room |
jamshaid |
goodday
|
Mark M. |
hello, jamshaid!
|
Mark M. |
how can I help you today?
|
jamshaid |
View paste
|
jamshaid |
i thought best wayto go about it is to use Services
|
jamshaid |
And bound services with messenger and handler
|
jamshaid |
as there are so many types i am on the right path here
|
Mark M. |
if you are going to use a bound service, you do not necessarily need to use Messenger and Handler
|
Mark M. |
you can create your own custom callback in AIDL
|
Mark M. |
I cover this in my chapter on remote services and the binding pattern, with an example
|
jamshaid |
thanks i have checked it.Its just the messenger way seemed more simple
|
jamshaid |
what i understood is that one is multithreaded and messenger just has a single thread
|
Mark M. |
Messenger has nothing to do with threads
|
Mark M. |
a Messenger is tied to a Handler
|
Mark M. |
a Handler is tied to a thread, either the main application thread or another HandlerThread
|
May 13 | 9:10 AM |
Mark M. |
using a custom AIDL callback, that callback will be called on an arbitrary binder thread, and you should try to not tie up that thread too long
|
Mark M. |
you are certainly welcome to use Messenger if you feel more comfortable with it
|
Mark M. |
note that Messenger does not require a bound service, though
|
Mark M. |
and so you need to think through what the long-term ramifications are for Application B's process
|
Mark M. |
why is A calling B's service? is A controlling B's behavior?
|
jamshaid |
View paste
|
Mark M. |
OK, that's rather strange
|
Mark M. |
but, regardless, a bound service is not a great solution here
|
Mark M. |
Application A needs to be able to complete the work that Application B requests, and that may take quite some time
|
Mark M. |
with a purely bound service, A's service will be destroyed once B unbinds
|
Mark M. |
and the work might not be done yet
|
Mark M. |
A's service should be started, via startService(), so A can control how long A's service runs
|
Mark M. |
(at least until Android O, when a few things related to your project will change)
|
jamshaid |
View paste
|
May 13 | 9:15 AM |
jamshaid |
is it possible to have an app which has a service always running
|
jamshaid |
?
|
Mark M. |
your scenario most likely is valid; it's not especially common, as few developers are working in places where they can write system apps
|
jamshaid |
just a service no UI
|
Mark M. |
in your scenario, probably
|
Mark M. |
for ordinary app developers, no, particularly on Android O
|
Mark M. |
however, your scenario gets into stuff that I do not have much experience with
|
jamshaid |
ok thanks
|
jamshaid |
one other thing which might be general. i use messenger and have a handler
|
jamshaid |
something like this
|
jamshaid |
View paste
(3 more lines)
|
jamshaid |
if in handleMessage i have another callback how can i wait for it .As i understand handlemessage will execute and then return?
|
Mark M. |
most likely, the best answer is "do not wait for it; deliver the results of the work asynchronously"
|
Mark M. |
handleMessage() will block whatever thread you have the Handler tied to
|
Mark M. |
technically, there's nothing stopping you from making some sort of long blocking call from handleMessage()
|
jamshaid |
how can i tie a thread to the handler for example.I thought if i make an async task then i cannot reply using messenger back to client
|
May 13 | 9:20 AM |
Mark M. |
since you are creating a custom Handler subclass, you would need to create an instance of it via the constructor that takes a Looper as a parameter
|
Mark M. |
where your Looper is tied to some thread (e.g., comes from a HandlerThread)
|
Mark M. |
however, you cannot readily fork a background thread from inside handleMessage(), then wait for that thread to complete
|
jamshaid |
generally if one has a callback inside a function it wont wait and execute
|
jamshaid |
one should use this approach like u shared
|
jamshaid |
or is it specific to this case that i should use a loooper
|
jamshaid |
i have not used it before i will check the book
|
Mark M. |
I do not cover Handler much in the book, mainly because IMHO developers should be using higher-level patterns
|
Mark M. |
in your scenario, using a low-level solution like this may be fine
|
Mark M. |
again, your scenario is unusual
|
jamshaid |
another thing eventbus like one from greenrobot is limited to just the same process
|
jamshaid |
is that correct
|
Mark M. |
correct
|
jamshaid |
in the security chapter you listed that self signed certificate might be better in some situation.
|
May 13 | 9:25 AM |
jamshaid |
which scenarios this could be?
|
Mark M. |
this would be for when an Android app is talking to a server
|
Mark M. |
if that server is only supporting app clients -- not Web browsers -- there is no advantage in using a CA-signed certificate
|
Mark M. |
CA-signed certificates are for cases where arbitrary clients (typically Web browsers) need to talk to the server
|
jamshaid |
if one has both web browsers and app clients
|
jamshaid |
what you think is more secure self signed or CA
|
Mark M. |
if they are all talking to the same server (or server farm), you have no choice but to use a CA-signed certificate, as browsers do not accept self-signed certificates (except by having the user do stuff that users are not used to doing)
|
jamshaid |
View paste
|
May 13 | 9:30 AM |
Mark M. |
"is it more secure to secure the api end points for android based client app with self signed certificate" -- that may or may not be possible; talk to your server team
|
Mark M. |
using a self-signed certificate, overall, has equivalent security to implementing certificate pinning
|
jamshaid |
ok
|
Mark M. |
the advantage of the self-signed certificate is that you have more control over things like lifetime
|
jamshaid |
one of my peers thinks if the wifi is secured using 802.1x EAP or some secure https is not necessary
|
Mark M. |
WiFi isn't relevant, unless the server is not on the Internet
|
jamshaid |
thanks
|
May 13 | 9:35 AM |
jamshaid |
i get this message on android device where upon putting the usb otg
|
jamshaid |
i get this system dialog if i want to change my default write disk
|
jamshaid |
i wnated to get rid of it i saw on stackoverflow u had a comment
|
jamshaid |
but unsucessful was wondering if u had more to share on it
|
Mark M. |
I do not know what you are referring to, sorry
|
jamshaid |
i meant this
|
jamshaid | |
Mark M. |
well, I meant what I said
|
Mark M. |
that is not a standard Android dialog
|
Mark M. |
that is coming from something specific to that device from that manufacturer
|
Mark M. |
if you have questions or concerns about it, you need to talk to the manufacturer
|
May 13 | 9:40 AM |
jamshaid |
sorry i just realized that wiko is not some developer but the device manufacturer
|
Mark M. |
I assume that's a device manufacturer, from the context of the question
|
Mark M. |
I do not recall hearing of them
|
jamshaid |
yes you are right
|
Mark M. |
but, there are many small device manufacturers out there
|
jamshaid |
is it possible to restrict in android all internet communication to a single ip
|
jamshaid |
in past i used the vpn but was just wondering if there is another way u came across
|
Mark M. |
no, I was going to suggest a VpnService as a possibility
|
Mark M. |
there may be other options for people in position to customize the firmware, as you appear to be
|
Mark M. |
however, that is outside my areas of expertise
|
jamshaid |
actually just have to possibiity to get the app signed but not to customize firmware so ...but thanks
|
May 13 | 9:45 AM |
jamshaid |
thanks alot for your answers i will look into looper and try.
|
Mark M. |
you're welcome!
|
May 13 | 10:00 AM |
Mark M. |
that's a wrap for today's chat
|
Mark M. |
the next chat is Monday at 4pm US Eastern
|
jamshaid |
thanks
|
Mark M. |
this chat's transcript will be uploaded to https://commonsware.com/office-hours/ shortly
|
Mark M. |
have a pleasant day!
|
jamshaid | has left the room |
Mark M. | turned off guest access |