Office Hours — Today, June 3

Thursday, May 22

Jun 3
7:20 PM
Mark M.
has entered the room
7:25 PM
Mark M.
turned on guest access
7:30 PM
Susheel C.
has entered the room
Susheel C.
Hi Mark
Mark M.
hello, Susheel!
how can I help you today?
Susheel C.
I have a raw audio file. Can I play it at a certain frequency in android?
Mark M.
maybe via AudioTrack, where you are pushing in raw PCM data
otherwise, I doubt it, but that's outside my depth in the audio space
7:35 PM
Susheel C.
no just like an mp3 or something like that
7:35 PM
Susheel C.
Ok I have another question. As part of a text message I want to put a link to start my app. How can I do that? I mean launch mainactivity by clicking a link in the text. Is that possible?
Mark M.
that depends on your requirements
the problem is that there are N text messaging clients
you have no control over whether they make things be links
your most likely case for them making some piece of your text message be a link, is if that link is an HTTP URL
you can add an <intent-filter> on the activity to advertise that you support such URLs
there's coverage of that in the book
however, bear in mind two things:
Susheel C.
in custom urls section?
Mark M.
1. the user will *also* be given browser(s) as options in a chooser
2. not all SMS clients will necessarily make URLs be clickable
Susheel C.
ok
Mark M.
and, yes, that sounds about right in terms of where it is in the book
7:40 PM
Susheel C.
great
7:40 PM
Susheel C.
Just to make sure I asked my question clearly, I will give you an example. Say I am sending a text to my friend 'Test this'. When my friends receives it, he should be able to launch my app (already installed on his phone) when he clicks 'Test'. I hope this is what you understood my question to be in the first place.
Mark M.
well, that's not possible
text messages do not support HTML in general
there is nothing that will cause SMS clients to magically make "Test" clickable at all, let alone to launch anything in particular
Susheel C.
ok
If I remember intercepting text messages using SMS manager is not available for android 4.4, am I right?
not smsmanager, broadcast receiver
Mark M.
you can intercept text messages via their broadcast, but you cannot prevent the user's chosen SMS client from receiving the message as well
Susheel C.
Oh I get it
Can I ask you questions about serial port programming in android?
7:45 PM
Mark M.
you can ask them, but I can't answer them :-)
Susheel C.
Haha
Well thanks for your help Mark.
Mark M.
you are very welcome
Susheel C.
has left the room
8:05 PM
EGHDK
has entered the room
Mark M.
hello, EGHDK!
how can I help you today?
EGHDK
Hey Mark, so another simple question. I'm working through my Head First Java book. But right on the cover it says "Java is pass by value". You said it's pass by reference the last time I brought this question up. So For primitives its pass by value, and for objects its by reference?
8:10 PM
Mark M.
well, it depends on how you define "pass by value"
I'm pretty sure we went over this already
technically, Java is always pass by value... however the "value" of an object is what in C/C++ you would consider a "pointer"
the net effect, from the standpoint of simple analysis, is that Java behaves like pass-by-reference for objects
however, language purists (e.g., http://javadude.com/articles/passbyvalue.htm) will stick with the "it's pass-by-value, with values being pointers" description
EGHDK
Interesting...
I've never worked with c/c++ so I'm not sure what a pointer is.
Mark M.
and *that's* why it is usually simpler to just think of Java as pass-by-reference
to understand why it is technically pass-by-value, you need experience in lower-level programming languages, like C/C++
there are lots of Java developers in the same boat as you
8:15 PM
EGHDK
Hmm. Okay. Well I'm glad that it "is" technically "pass by value" but that value just happens to be a reference.
C seems simple enough to learn.
Mark M.
like many programming languages, C is not that hard to write, but very hard to write well
EGHDK
c++ on the other hand is really weird, because I tried to get into it but I had a hard time because I had to seemingly use microsoft visual studio. then I had questions that I asked, and people had no idea why I was importing certain things, but apparently they are needed for windows. i don't understand why the same exact code wont work across different os's
Mark M.
it can, so long as you don't want to do anything that is OS-specific
which, in C/C++, means "so long as you only want trivial programs that run at the command prompt"
even trying to implement a server is likely to get you into OS-specific stuff, let alone a desktop GUI
EGHDK
Is that why java is so popular?
Mark M.
the Java class library helps insulate you more from the OS
8:20 PM
Mark M.
that has its pros and its cons
the popularity of Java is more based on where and how it got used: server-side "enterprise class" Web apps, plus Android
EGHDK
Gotcha. All the books I've read about how popular it got mention servers. But that doesn't really make any sense to me. Forgive me for my lack of knowledge on how java made server side easier.
Mark M.
it didn't make it easier
at least, not on an absolute scale
it was easier than some things, and probably harder than others
asking why Java succeeded on the server is akin to asking why kangaroos exist
if you believe in the theory of evolution, kangaroos exist because of a series of evolutionary steps, that eventually wound up with kangaroos
8:25 PM
Mark M.
kangaroos aren't the fastest, the most lethal, the cutest, the highest fliers, etc.
but, they filled some ecological niche
in other words, kangaroos exist because, well, something had to exist, and we gave it the name "kangaroo", perhaps because we were running out of simpler animal names
similarly, something had to create Web apps
lots of things were tried
some stuck around for a short while (Perl and CGI), to be replaced by alternatives that were clearly superior
some stuck around for a long time, and in parallel to other solutions (e.g., PHP and Java)
PHP and Java each filled a niche
EGHDK
Really interesting. Thanks.
Last question for today. This will actually be on Android development. In 4.0 in multi tasking you get a little screenshot of your app. Do you think its possible to set that screenshot programatically? I have tried to override onPause, and set the background color of the window before I call super.onPause(), but somehow I see the color change really quickly, but when I look in the multitasking it doesn't have the color change. Any ideas?
Mark M.
override onCreateThumbnail(), IIRC
8:30 PM
Mark M.
and that's a wrap for today's chat
the next one is Thursday at 10am US Eastern Time
EGHDK
Great. Thanks.
Mark M.
this chat's transcript will be archived at http://commonsware.com/office-hours/ shortly
have a pleasant day!
EGHDK
has left the room
Mark M.
turned off guest access

Thursday, May 22

 

Office Hours

People in this transcript

  • EGHDK
  • Mark Murphy
  • Susheel Chanda