Office Hours — Today, December 28

Monday, December 21

Dec 28
8:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
Dec 28
9:00 AM
Ryan G.
has entered the room
Ryan G.
hey mark
Mark M.
Howdy!
Mark M.
Got any Android development questions?
Dec 28
9:05 AM
Ryan G.
yes! sry my browser is being a little sluggish
Ryan G.
so i am working on a photo frame/slidshow app widget
Ryan G.
and i want it to have different frames
Ryan G.
currently i am using an imageview with a background of the frame
Dec 28
9:10 AM
Ryan G.
so the photo just goes over the frame (which is the background)
Ryan G.
which seems to work fine except for two things
Ryan G.
I want to make a bunch of different frames, so initially i wanted to just change the background of the image view and all would be good
Ryan G.
but i need to use the remote view to update my appwidget
Ryan G.
and it doesn't seem to allow me to change the background of the imageview
Ryan G.
do you know how I could do this?
Mark M.
Somebody (perhaps you?) asked about this on [android-developers] recently
Mark M.
I would have thought that setInt() on RemoteViews would work
Ryan G.
yeah i saw that, could you explain that answer a little more
Terry
has entered the room
Ryan G.
how is the setInt doing that?
Ryan G.
or what is the setInt for?
Mark M.
If you look at the source code to RemoteViews, all of the "built-in" setters, like setTextColor(), turn around and call one of the primitive setters, like setInt() or setLong().
Ryan G.
o ok
Mark M.
Really, RemoteViews is building up a list of commands to execute against the real Views running in the home screen's process
Dec 28
9:15 AM
Mark M.
So, in principle, setInt(R.id.my_image_view, "setBackgroundDrawable", R.drawable.my_new_frame) should work
Ryan G.
so i could really do anything in a remoteview that i can do on the imageview by using the setInt? or at least I should be able to?
Mark M.
I'd say any void-returning, single-parameter accepting setter, in theory, should work
Mark M.
In practice, the person I corresponded with claimed to try this and it failed
Mark M.
It is possible that there are issues extracting the drawable resource from your APK
Mark M.
I'd look at the source code to RemoteViews, see how they implement setImageViewResource(), and try to clone it for setBackgroundResource()
Mark M.
(BTW, typo earlier in this chat -- I meant "setBackgroundResource", not "setBackgroundDrawable")
Mark M.
and a belated "Howdy" to Terry!
Ryan G.
ok, i'll try the setInt thing
Ryan G.
the next thing I also saw a response from you on a message in the boards but want to try to get a little better explaination
Dec 28
9:20 AM
Terry
Thanks Mark!
Terry
And you wrote when I was getting belated coffee.
Mark M.
Nothing worse than belated coffee
Ryan G.
so I want to implement image cropping in my app, since the cropImage app isn't official on all phones I decided to just copy it to my program. I was able to do this and everything seems to work fine except some variables such as mContext, mLeft/Right/Top/Bottom aren't initialized anywhere and I can't seem to figure it out
Mark M.
Those are probably declared in some parent class
Terry
I know that you have talked before about using a database on the SD card. I found a working app that does that last night -- a 5MB database with an accompanying APK. You install the db on the S card and then use preferences in the app to point to the location of the database.
Mark M.
Terry: I've heard it was possible but haven't tried it and never ran across source code that demonstrated it
Mark M.
There's also a slight risk of the user ejecting the card while you have your database open
Terry
I wrote them and asked for it. I will send if I get it.
Dec 28
9:25 AM
Terry
Yes, that is an issue.
Terry
Here is the link if you want it: http://blog.digitalbias.com/android-scriptures/
Terry
One would think that Google/Android would have made this an essential feature. It just makes no sense to store a database in precious main memory.
Ryan G.
would it be possible to take a quick look and see if you can see where i might look to find these? the link for the source is here: http://android.git.kernel.org/?p=platform/… and its in the "ensureVisible" method
Dec 28
9:30 AM
Mark M.
Ryan: Have you looked in MonitoredActivity?
Mark M.
Hmmmm...nope, not there
Ryan G.
there is 2 classes in that sorce
Ryan G.
the mcontext and mTop/bottom etc
Ryan G.
are part of the second
Ryan G.
class CropImageView extends ImageViewTouchBase
Ryan G.
i didn't see it in imageviewtouchbase
Mark M.
Ah, sorry
Ryan G.
but i didn't know if it has something to do with it being a custom view?
Mark M.
However, I think those are available on View
Mark M.
If you are trying to use the code outside of a View, you'll need to get the values from the View you're applying the crop to.
Mark M.
Those are all available as methods AFAIK (e.g., getContext())
Ryan G.
how can they do it without calling the methods?
Dec 28
9:35 AM
Mark M.
They are all protected data members on View.
Mark M.
Hence, subclasses of View can reference them directly.
Mark M.
Terry: back to your database location stuff, actually, there are reasons to have small databases in on-board flash, such as security (cannot be accessed except on rooted phones) and SD card ejection
Ryan G.
so they put this line in their xml for the crop layout <view class="com.android.camera.CropImageView" ...> does this make it a view and allow them to reference the data members of the view directly?
Mark M.
No, it's a View because they subclass View, indirectly.
Terry
I understand.
Mark M.
They use <view class="com.android.camera.CropImageView" ...> as alternative syntax to <com.android.camera.CropImageView ...>
Mark M.
Some tools probably don't like long, dot-delimited XML element names
Dec 28
9:40 AM
Terry
It is just that I know from experience on my phone that I often get down to 30MB of main memory or less on my phone as I use it and apps stay open so I am constantly having to kill them. A few 5-10 MB databases would tie up memory so that new programs would not load.
Mark M.
Terry: most apps don't use 5-10MB databases, though
Terry
I understand but I would like to write some that do.
Mark M.
Aha!
Terry
I have not explored the alternative -- pulling the data from the web.
Mark M.
Pros and cons there -- no local storage other than perhaps a small cache, but you need one of those darn Internet connections
Terry
The downside of that is that you have to be online and I spend a lot of time in airports, on planes, etc.
Terry
I just created an app for amusement in Oracle / PL/SQL and all I need to figure out the conversion to Java. Getting the data into SQLite is a breeze. By the way, the database in the link I sent is really a SQLite database -- I changed the extension and pulled it up in the Firefox add on.
Dec 28
9:45 AM
Terry
He seemed to follow the instructions in another site I found. http://www.reigndesign.com/blog/using-your…
Mark M.
That blog post is pretty messed up, IMHO
Mark M.
I don't know why he's subclassing SQLiteOpenHelper, then not using anything SQLiteOpenHelper helps with
Terry
You are certainly allowed humble opinions. LOL I found it lacking in detail.
Mark M.
Otherwise, though, that's about what I expected in terms of copying the database to SD and opening it.
Mark M.
I'll be experimenting with this stuff for an _Advanced Android_ update in January
Terry
Great!
Terry
I have done IT for a long time but Java is very new.
Terry
I was hoping you would do that. You seem to have an incredibly solid grasp of the language and what is available.
Dec 28
9:50 AM
Mark M.
Thanks! I do what I can.
Mark M.
Android is vast
Ryan G.
mark, my appwidget works in portrait mode but in landscape it lays out funny (i think my images size needs to change) do you know what the best way to redo the widget on orientation change is?
Terry
And I appreciate all your help. I think it is incredible that you do this.
Ryan G.
i'm sure there is a orientation change broadcast
Ryan G.
but but how do i get just my appwidget id's?
Mark M.
Ryan: Those are all very good questions, for which I lack answers. :-(
Terry
Can you freeze orientation (not let it change despite the accelerometer)?
Ryan G.
aww boo
Ryan G.
lol
Mark M.
No, app widgets are on the home screen
Mark M.
We can't control home screen orientation
Mark M.
The best hope is if the app widget IDs are reasonably persistent
Terry
I meant in an app
Mark M.
Terry: in an app, you could always wire an activity to a specific orientation
Terry
OK
Mark M.
Ryan: you might try posting that question to StackOverflow
Ryan G.
ok
Ryan G.
yeah all i need is my code to run again to resize the image, i think i can get all the widget ids from the appwidgetmanager, and i could just look for my preferences and run my code using those ids
Dec 28
9:55 AM
Mark M.
I would hope that app widget IDs do not change until the app widget is removed...but I'm not 100% certain of that
Ryan G.
i'm pretty sure that is true, except for HTC sense, they do screwy things with the id's although i'm not sure if they do them on orientation change or just at reboot
Ryan G.
well i know on orientation change its still ok because i save my ids in the preference names so i can have more than one instance of my widget, and my widget still works after orientation change
Dec 28
10:00 AM
Mark M.
Well, that's the end of the office hours chat for today.
Terry
Thanks for all the information!
Ryan G.
thanks mark
Mark M.
Happy to help. I'll be posting the transcript shortly.
Mark M.
Have a pleasant day!
Terry
You too!
Ryan G.
has left the room
Terry
has left the room
Mark M.
turned off guest access

Monday, December 21

 

Office Hours

People in this transcript

  • Mark Murphy
  • Ryan Grandy
  • Terry