Office Hours — Today, October 31

Tuesday, October 29

Mark M.
has entered the room
Mark M.
turned on guest access
Oct 31
7:25 PM
Maurizio
has entered the room
Maurizio
Hi Mark
Mark M.
hello, Maurizio
how can I help you today?
Maurizio
First of all thank you
Mark M.
you are welcome, though I am not quite certain for what :-)
Maurizio
I will try to explain and see if you could give me some guidance
for your excellent job Mark!
anyway...
I would like to build some kind of "downolader"
View paste
Basically what I need is an application that

is called when the user clicks on a download link in the browser (or in the email client);
the app opens up
the app saves the file inside a directory defined by the app itself.
what do you think, which wy shoud >I go?
Mark M.
um, for what, specifically?
Maurizio
if i open the brwser
7:30 PM
Maurizio
and there is an attachmet to be downloaded
i would like the app to open up
and save the file in its private storage
Bob R.
has entered the room
Maurizio
I do not know if it is clear enogh?
Mark M.
I understood all of thqat
er, that
Bob R.
Hi all:)
Mark M.
however, what I do not understand is "which wy shoud >I go"
(hello, Bob, I will be with you shortly!)
Bob R.
Hi Mark
Mark M.
Maurizio: everything you list is covered in the book
Internet chapter covers downloads
Maurizio
because honestly I do not know wheere to start from
Mark M.
Fils chapter covers internal storage
er, Files chapter
Bob R.
I dived into your book this week and am enjoying it very much.
Mark M.
well, I cannot really answer that, other than to start with "Hello, world" :-)
(hello, Bob, *I will be with you shortly!*)
Maurizio
can i force download from the browers to a specific directory on my app?
Bob R.
Sure
Mark M.
Maurizio: not really, as the browser authors are welcome to do what they want
Maurizio
so basically I can't...
Mark M.
is there something specific about the files that you are seeking to download, like a specific MIME type?
Maurizio
no, that is the point, I would like to be able to redicrect all download to the app...
Mark M.
then you will need to write your own Web browser
Maurizio
hehehe
Mark M.
and convince people to use it rather than Chrome, Firefox, etc.
7:35 PM
Maurizio
I suppose it's the same for the mail client...
Mark M.
more or less
let me take a question from Bob, and we can continue discussing this in a bit
Maurizio
Ok
Mark M.
Bob: do you have a question?
Bob R.
I have a question relating to running lint. When I entered stuff directly out of a book (not yours yet, I had a lot of warning msgs. Then When I ran clean or lint they went away. Many times @Override was added where it wasn't. I deleted them back out because the book I was reading didn't have them. Is there a rule of thumb as to when you use @Override?
Mark M.
you @Override when you are overriding a method of a superclass, or implementing a method defined on an interface
the latter requires you to be using Java 6, and if you are using Eclipse, it requires Eclipse to be using Java 6 rules for examining your source code for warnings/errors
Bob R.
OK I on page 200 of your book. I;m not sure what this means.
Mark M.
(see page 19, 2nd paragraph, for more details about the Eclipse bit)
Bob R.
OK Thanks,
Mark M.
page 200 of the book is blank
note that I released Version 5.2 a couple of weeks ago
Bob R.
OK I'll check. I'm just beginning to read the WebView
Mark M.
let me take another question from Maurizio, and I will be back with you in a bit
Maurizio: do you have another question?
Bob R.
Sure
7:40 PM
Bob R.
Thanks for your help
Maurizio
not really
I understand that what I would like to do is not achievabe
correct?
Mark M.
well, you are welcome to create an app that has an <intent-filter> saying that you handle all HTTP requests, like a browser
users will uninstall your app within minutes
because every time they click a link, they'll be forced to choose between your app and their regular browser
or, they'll just make their regular browser the default, then eventually uninstall your app when they can't quite figure out why they have it
what would your app be doing, for the user, that is different from what the browser already does?
in other words, what is "the value-add" of your app?
Maurizio
is meant to be used by unskilled users
Mark M.
that is not a very useful answer
"Hello, world" is meant to be used by unskilled users too
Maurizio
so that they can put their dowloads (=documents) of choice stored in a single application
Mark M.
they already have this
it's called the Downloads app
it is on 95% of Android devices
Maurizio
I know... :-)
Mark M.
um, OK
let me swing back to Bob for a bit
Bob: do you have another question?
7:45 PM
Maurizio
well, ok Mark, thank you for your advice
7:45 PM
Maurizio
have a very nice evening
Mark M.
you too!
Maurizio
and keep on writing excellent books!
Night!
Maurizio
has left the room
Mark M.
Bob: do you have another question?
7:50 PM
Bob R.
Yes I do
7:55 PM
Bob R.
My eclypse is currently set to 1.7 should I change it to 1.6?
Mark M.
do you mean in Preferences > Java > Compiler?
Bob R.
yes
Mark M.
then that should be fine, so long as you actually have Java 1.7
1.5 is the value that causes problems
anything higher than 1.5 should be fine
Bob R.
OK Thanks
Also I have a question out on Stack Overflow.
Mark M.
do you have a link?
Bob R.
Yes.
They close the questions if it appears vague
Mark M.
and, to be honest, you are lucky that this one was merely ignored instead of closed
8:00 PM
Mark M.
saying "I tried several things and I wasn't able to get it to work" is not particularly helpful
you need to explain *what* you tried and *what* did not work
the rest of your question is littered with confusing phrases
JSON files do not have photos, as they are text files
it is unclear what an "email process" is
Bob R.
Yea I'll go back a rework the question after I read more in your book. Your book is answering a lot of questions for me.
Mark M.
in general, text messages (SMS) are text, like JSON files, and therefore do not have images
Bob R.
My process automatically builds a text message via anything available on the phone
Text msg, email etc.
I was trying to attach a photo to it
Mark M.
um, OK
what does "automatically builds a text message" mean?
Bob R.
I was trying to attach a photo to an email or txt. I thought that it wass possible.
8:05 PM
Mark M.
well, that depends a bit on what you mean by "attach a photo to an email or txt"
Bob R.
The user has a specific criteria and I put together several strings
Mark M.
um, OK
let's focus first on email
you say that you are trying to send an email
how are you doing that?
ACTION_SEND?
ACTION_SENDTO?
Bob R.
the email or txt msg is triggered and the user can send it from whatever txt msg or email system is on their phone
Mark M.
JavaMail library?
something else?
Bob R.
The image is saved to a json file
Mark M.
no, it is not
JSON is a text format, not a binary format
you do not save an image to a JSON file
(well, OK, you could base-64-encode the byte array or something, but that's just bizarre)
so, I will ask again: how are you trying to send the email?
Bob R.
I have to review what I did. I can save a photo with text into a listview with date and time
Mark M.
no, you can *display* a photo with text in a ListView with date and time
a ListView is a user interface widget
it is not a data storage mechanism
you do not "save" anything into a ListView
Bob R.
The text is saved to json. Shows you how much I know.
8:10 PM
Mark M.
putting text into JSON is certainly possible
Bob R.
I know that the project saves all the data onto a JSON file, and I thought the image from the photo was also saved there.
Mark M.
it certainly seems unlikely
Bob R.
Now I;m really confuded
I'll send u a piece of code
Mark M.
um, well, you are welcome to upload a file into the chat room, if you want
Bob R.
View paste (7 more lines)
    public Crime(JSONObject json) throws JSONException {
        mId = UUID.fromString(json.getString(JSON_ID));
        mTitle = json.getString(JSON_TITLE);
        mSolved = json.getBoolean(JSON_SOLVED);
        mDate = new Date(json.getLong(JSON_DATE));
        if (json.has(JSON_PHOTO))
            mPhoto = new Photo(json.getJSONObject(JSON_PHOTO));
        if (json.has(JSON_SUSPECT))
            mSuspect = json.getString(JSON_SUSPECT);
    }

    public JSONObject toJSON() throws JSONException {
        JSONObject json = new JSONObject();
        json.put(JSON_ID, mId.toString());
        json.put(JSON_TITLE, mTitle);
...
8:15 PM
Bob R.
This code is taken from the book The Big Nerd Ranch
8:15 PM
Bob R.
Where's the Photo going?
Mark M.
the image is already in a file somewhere
I think that the JSON is just holding a path to the image
Bob R.
So the image is actually in a separate file?
Mark M.
the comment on the Photo constructor is "Create a Photo representing an existing file on disk"
and toJSON() stores the filename in the JSON
Bob R.
OK. I think I'll just continuing with your book for a while. I'm realizing just how much I dont know.
8:20 PM
Bob R.
So If you are saving everything internally, the photo goes into one file and the rest of the data goes into another?
Mark M.
well, it's more that JSON is a text file, and so it cannot readily hold binary data like an image
similarly, HTML is a text file, and so it cannot readily hold binary data like an image
Bob R.
So in therms of an internal file, its saved differently?
Mark M.
that is why, when you put images on a Web page, you reference other files
Bob R.
so much I've yet to learn.
Mark M.
I have no idea how to parse your last question, sorry
Bob R.
Sorry. I'm just confused
thanks for your time
Mark M.
you are very welcome
8:25 PM
Bob R.
I meant earlier : when saving internally, you save the photo image in an image file and the rest of the data into a JSON file. Correct?
Mark M.
correct
Bob R.
Again thanks, I think I'll stick with only your book for a while.
Holding off with implementing anything just yet.
Have a great evening.
Mark M.
you too!
Bob R.
All this new stuff. I think I've been getting a little overwealmed.
Mark M.
it does get a bit complicated
Bob R.
I had no idea:)
8:30 PM
Mark M.
and that's a wrap for today's chat
the transcript will be posted shortly to http://commonsware.com/office-hours/
the next chat is tomorrow, 4pm Eastern
Bob R.
Thanks Mark
Bob R.
has left the room
Mark M.
turned off guest access

Tuesday, October 29

 

Office Hours

People in this transcript

  • Bob Richardson
  • Mark Murphy
  • Maurizio