Nov 9 | 4:05 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Suzanne A. | has entered the room |
Prasanna P. | has entered the room |
Prasanna P. |
Hi Mark
|
Mark M. |
hi!
|
Mark M. |
sorry I'm late
|
Suzanne A. |
Hi Mark and Prasanna
|
Mark M. |
my Google Calendar reminder must be broken for this calendar entry
|
Mark M. |
:-(
|
Mark M. |
OK, ladies first...Suzanne: how can I help you?
|
Prasanna P. |
no problem
|
Suzanne A. |
Can we ask general Android development questions here?
|
Mark M. |
absolutely!
|
Suzanne A. |
I have a list of questions ..
|
Mark M. |
If we could do one at a time, then give others a shot, that'd be great
|
Suzanne A. |
View paste
|
Ales | has entered the room |
Mark M. |
howdy, Ales!
|
Mark M. |
Suzanne: I'm not aware there is more than one option
|
Octavian D. | has entered the room |
Ales |
Hello
|
Nov 9 | 4:10 PM |
Suzanne A. |
Is it BitmapFactory.Options, followed by Bitmap.createScaledBitmap?
|
Mark M. |
right
|
Octavian D. |
hello
|
Mark M. |
I'm fairly certain everything else (e.g., the scale options on ImageView) all route to the same core logic
|
Mark M. |
howdy, Octavian!
|
Suzanne A. |
ok, thanks
|
Mark M. |
we'll get back to your next question in a bit...
|
Mark M. |
next up, Prasanna -- do you have a question?
|
Prasanna P. |
i am showing a dialog on my ui thread. I want to get rid of this dialog on my onPause()
|
Prasanna P. |
as I do not want it to show up when the app ...
|
Prasanna P. |
is started again if the user did not
|
Prasanna P. |
click on 'OK" to get rid of the dialog
|
Prasanna P. |
so how do i check to see
|
Prasanna P. |
if it is was shown and
|
Prasanna P. |
the user did not click 'ok' on it
|
Mark M. |
um, that's up to you
|
Prasanna P. |
and if it is still there to get rid of it
|
Prasanna P. |
so how can i check to see if a dialog is still showing
|
Mark M. |
AFAIK, it is safe to dismiss a dialog that is not showing, so you can probably call that blindly
|
Jay M. | has entered the room |
Prasanna P. |
so i can always dismiss a dialog
|
Mark M. |
I think so
|
Prasanna P. |
on my onStop method?
|
Mark M. |
beyond that, use a boolean data member
|
Mark M. |
you get control on every button click
|
Mark M. |
so you can track your state yourself
|
Darryl | has entered the room |
Prasanna P. |
ok
|
Prasanna P. |
thanks!
|
Mark M. |
it would be nice if there were an isDialogShowing() method for the managed dialog system, but it doesn't appear there is
|
Mark M. |
OK...next up, Ales: do you have a question?
|
Ales |
I have a problem with ANR. Not sure where to start looking for possible problems
|
Prasanna P. |
fyi. no more qs from me ... so just handing out ...
|
Ales |
Activity starts and display a list of items
|
Nov 9 | 4:15 PM |
Ales |
but i can't check checkboxes
|
Nov 9 | 4:15 PM |
Ales |
until that message pops up
|
Ales |
Application not responding...
|
Mark M. |
OK, it is rather difficult to provide assistance on this sort of question via a chat
|
Mark M. |
you are doing something that is taking too long on the main application thread
|
Mark M. |
what that is, I can't say
|
Julius | has entered the room |
Ales |
The only thing i do is get like 5 or 6 items from database and that is all
|
Ales |
If I attach log, do you think you can see a problem?
|
Mark M. |
I doubt it
|
Mark M. |
it's been a while since I've looked at an ANR log
|
Mark M. |
but IIRC, it does not exactly say where you are being tied up
|
Mark M. |
do you see any of your code in the stack trace?
|
Ales |
I'm not realy familiar with that trace
|
Ales |
It is interesting though
|
Mark M. |
OK, my recommendation is for you to set up an
account on StackOverflow and open up a question about this, posting your
code and the stack trace
|
Ales |
When i start application it works fine, but if i switch a few of my activities this happens
|
Ales |
Ok, i'll try there
|
Mark M. |
wait a minute, you said that "Activity starts and
display a list of items but i can't check checkboxes until that message
pops up"
|
Nov 9 | 4:20 PM |
Ales |
correct
|
Mark M. |
now you're saying it works, but you have to click around other activities?
|
Mark M. |
which is it?
|
Ales |
list is always populated
|
Ales |
but sometimes can't check checkboxes for a while
|
Ales |
after that message .. i click wait and it works fine from then
|
Mark M. |
OK, this is definitely something beyond what a chat can resolve
|
Mark M. |
I'm not even sure if StackOverflow can help
|
Mark M. |
you need to narrow down the source of your
difficulty, perhaps by commenting things out, or determining the precise
set of events that causes you to consume too much time on the main
application thread
|
Mark M. |
Octavian, do you have a question?
|
Octavian D. |
nope, just lurking
|
Ales |
Could something like this happen if I use ArrayAdapter instead of CursorAdapter?
|
Mark M. |
Ales: your choice of adapter should not cause an ANR
|
Mark M. |
Jay, do you have a question?
|
Jay M. |
View paste
|
Mark M. |
on your first question, yes, instance and static data members may both be gone by the time the service starts up again
|
Mark M. |
on your second question, SQLite or a flat file are likely candidates
|
Mark M. |
it has to be in file storage
|
Mark M. |
if there are no other components of your
application running, Android may recycle or terminate your process,
taking any in-RAM objects with it
|
Nov 9 | 4:25 PM |
Mark M. |
Darryl, do you have a question?
|
Jay M. |
Ok - good to know I'm in the right direction. Thanks for the awesome resources!
|
Darryl |
Hello, thanks once again for taking the time to
help us out. I was wondering a little about networking. I am running
Android 2.2 on my Nexus One. I would like to be able to enable the
portable hotspot (which doesn't have to be programmatically) then
connect other devices to the hotspot (another android phone, an iPad,
whatever). Now, from my Nexus One, I would like to be able to know what
devices are connected to the hotspot, as well as be able to transfer
files to those devices (or request a file transfer from my Nexus to one
of the devices). Now, I have been able to connect two devices via
Bluetooth and transfer data that way, but I would like to connect more
than two devices (and maybe an i-device) at the same time. So the
bottom line question: is there a way to see what devices are connected
to the hotspot and communicate with devices which are connected? If so,
how would I go about doing that? I know there is wifiManager, but that
doesn't seem to be enough.
|
Mark M. |
Nothing about the WiFi hotspot is in the SDK at this time
|
Mark M. |
We'll see if they add anything in Gingerbread
|
Darryl |
Darn.
|
Darryl |
Thanks!
|
Mark M. |
yeah, it'd be nice to do more with it -- my guess is that they aren't comfortable with the API just yet
|
Mark M. |
Julius, do you have a question?
|
Julius |
yes
|
Julius |
hi
|
Julius |
3
|
Julius |
one at a time
|
Julius |
View paste
|
Julius |
it's really just image branding and maybe package naming
|
Mark M. |
sounds like an Android library project for the core, and application projects for the rest
|
Mark M. |
you could play some games with version control scripts, but they make me nervous
|
Mark M. |
take a look at Android library projects and see if that fits your needs
|
Mark M. | |
Julius |
ok thanks
|
Mark M. |
we'll swing back for your other questions in a bit
|
Julius |
of course thank you
|
Mark M. |
back to the top -- Suzanne, do you have another question from your list?
|
Suzanne A. |
I need to download a batch of images from a web
server, once a day, each with some text metadata. Can I download a zip
or jar file using HttpClient and unpack it?
|
Mark M. |
sure
|
Mark M. |
java.util.zip is in the SDK
|
brack | has entered the room |
Mark M. |
as is java.util.jar
|
Mark M. |
though I'd probably just use a ZIP file
|
Suzanne A. |
And since I need metadata for each image, what's the best way to store the data?
|
Mark M. |
I like ASCII -- better support for that than EBCDIC in Android
|
Mark M. |
:-)
|
Mark M. |
(mainframe joke for you young'uns on the chat)
|
Nov 9 | 4:30 PM |
Mark M. |
beyond that: XML, JSON, ...
|
Nov 9 | 4:30 PM |
Mark M. |
take your pick
|
Suzanne A. |
On the device - in a content provider?
|
Mark M. |
you lost me there
|
Mark M. |
where's a content provider come into the download-a-ZIP-file picture?
|
Suzanne A. |
If I download a zip and unpack it on the device, I have a batch of images, each with text
|
Darryl | has left the room |
Suzanne A. |
And I need to match each image to its text, for display
|
Mark M. |
you can use a content provider, or a database, or just a Java class
|
Mark M. |
that's really up to you
|
Suzanne A. |
whichever I choose?
|
Suzanne A. |
ok
|
Mark M. |
it's not like content providers are somehow magical for daily downloads of ZIP files of images and metadata
|
Mark M. |
OK, brack did not get a chance just yet -- brack, do you have a question?
|
Nov 9 | 4:35 PM |
brack |
yes, mainly about views and programmatically adding views into layouts
|
brack |
basically i'm attempting to integrate an admob
adview into a view that has a listview. optimally, when an ad becomes
available, I'd like to shrink the table, and fade/slide in the ad
|
Mark M. |
by "the table" do you mean the ListView?
|
brack |
i've messed around a bit with making the
xml-defined ad slot visibility=gone, and changing the visibility in the
code, but the listview never updates
|
brack |
yep
|
brack |
i have a ListActivity
|
NetApex | has entered the room |
Mark M. |
you can see this pattern in _Android Programming Tutorials_
|
Mark M. |
I use it for hiding/showing the status update widgets in Patchy
|
Mark M. |
check out Tutorial 26
|
Mark M. |
I use an animation there as well, fading in/out in my case
|
brack |
roger; I probably should have checked that first, sorry about that.
|
Jay M. | has left the room |
brack |
oh great, yeah i'll definitely check that out
|
Mark M. |
though you could use an AnimationSet to do both a fade and a slide
|
Mark M. |
OK...this is one busy chat today
|
brack |
Oo fancy, I dig it. thanks, i appreciate it!
|
Mark M. |
NetApex, you haven't had a chance yet -- do you have a question?
|
NetApex |
Nothing at the moment
|
Mark M. |
Prasanna said he was just lurking, so...Ales, do you have another question?
|
Ales |
Can I access ImageView of another activity within other activity using findViewById or something?
|
Mark M. |
not really
|
Mark M. |
what are you trying to achieve?
|
Nov 9 | 4:40 PM |
Ales |
setImageResource
|
Ales |
but ok can be done another way i guess
|
Ales |
using Thread
|
Mark M. |
arbitrary inter-activity communication is not typical
|
Mark M. |
you pass data via startActivity(), and you can get data back via startActivityForResult()
|
Ales |
ok
|
Mark M. |
otherwise, the activities should be independent
|
Mark M. |
just as one Web page cannot update another Web page of a Web app
|
Ales |
It's actually a service
|
Mark M. |
You asked, "can I access ImageView of another activity within other activity"
|
Mark M. |
now, one of those activities has turned into a service?
|
Mark M. |
regardless...
|
Ales |
Is there a difference in this case
|
Mark M. |
yes
|
Ales |
oh i see
|
Mark M. |
a service still cannot, and should not, be updating widgets
|
Mark M. |
however, there are more options for services to notify activities about changed data
|
Ales |
So the best thing is to create a Thread from main activity and use handler?
|
Mark M. |
callback/listener objects, createPendingIntent(), broadcast Intents, etc.
|
Mark M. |
Um, threads have nothing to do with your question
|
Mark M. |
where and when you need threads is a completely different topic
|
Nov 9 | 4:45 PM |
Mark M. |
I will have a revamped set of chapters covering services in the next update to _The Busy Coder's Guide to Android Development_
|
Ales |
I just want to change image when service completes a taks that is all
|
Mark M. |
that will hopefully answer your questions here a bit better
|
Mark M. |
you assume your activity is still there, which may or may not be the case
|
Mark M. |
the new chapters will demonstrate some solid service patterns that perhaps you can follow
|
Ales |
It will since it's root activity
|
Mark M. |
anyway, that update to the book will be out in the
next couple of weeks, dependent a bit on when that loaf of Gingerbread
arrives
|
Mark M. |
Julius: do you have another question?
|
Julius |
yes
|
Julius |
View paste
|
Julius |
store => stored provide => provided
|
Mark M. |
I have not used ACTION_IMAGE_CAPTURE
|
Mark M. |
I have not used MediaRecorder for video capture
|
Julius |
ok... I have another question...
|
Julius |
I have an application which has a button which
takes the user to a form in the web browser (from a web server on the
Internet). When the user has filled in the form (account creation) he is
sent back into the application by the web form. The application then
takes data from the Intent in the onResume and logs the user in. This
works very nicely. However, if the user hits the Home key and then
selects the application it appears that a new instance of the
application is started as the user is no longer "logged in".
|
Mark M. |
a basic activity to take a picture is < 100 lines of code
|
Mark M. |
profiled in two of my books
|
Julius |
yes I trie, that but ran into all sorts of problems with landscape and portrait...
|
Mark M. |
where is your "logged in" status stored?
|
Julius |
it's in the Shared Prefrerences
|
Nov 9 | 4:50 PM |
Mark M. |
um, really?
|
Mark M. |
in that case, I have no explanation for your problem
|
Julius |
sorta
|
Mark M. |
you only have one set of SharedPreferences
|
Julius |
I mean yes
|
Julius |
it's not ideal but yes
|
Julius |
yes just one
|
Mark M. |
you must not be reading in the SharedPreferences the way you are thinking of
|
Julius |
it feels like another instance of the application is starting
|
Mark M. |
or perhaps you're not commit()-ing when you store it or something
|
Julius |
right
|
Mark M. |
doesn't matter
|
Julius |
yeah I checked that too :)
|
Mark M. |
you only have one set of SharedPreferences
|
Julius |
I'll just have to breakpoint some more
|
Julius |
yes
|
Mark M. |
sorry
|
Julius |
I have an application with two
|
Mark M. |
Suzanne: do you have another question?
|
Suzanne A. |
On my earlier question, about
BitmapFactory.Options and Bitmap.createScaledBitmap. Does doing this
programmatically in an app, as opposed to letting Android scale images
automatically, help prevent OutOfMemory errors? Or not, if both access
the same code in Android?
|
Julius |
in fact two apps with two SharedPrefs but this one only needs one
|
Julius |
np
|
Julius |
thank you
|
Mark M. |
um
|
Mark M. |
I suspect that you have finer-grained control over things if you do the scaling yourself
|
Julius | has left the room |
Suzanne A. |
okay ..
|
Mark M. |
but your question is difficult to answer in the abstract
|
Mark M. |
it's all about how many images, how you're using them, etc.
|
Suzanne A. |
right
|
Mark M. |
Ales: do you have another question?
|
Ales |
So to go a bit further with my last question
|
Ales |
Let's say i want to create a kind of progress icon
|
Nov 9 | 4:55 PM |
Ales |
If user clicks this icon, method starts in service
|
Ales |
While this method runs i would like to show "active" icon until it finishes
|
Ales |
What would be the best way
|
Mark M. |
I can't really say what is "best" just based on this information
|
Mark M. |
when you say "method starts in service" what do you mean?
|
Ales |
Let's say you have wheather app and refresh icon
|
Ales |
while service is parsing data from web server I would like to have "active" icon in my main activity.
|
Suzanne A. | has left the room |
Mark M. |
let's try this again
|
Mark M. |
when you say "method starts in service" what do you mean?
|
Mark M. |
did you call bindService() and are now literally calling a method on the Service object itself?
|
Mark M. |
or do you mean something else entirely?
|
Ales |
I call a method service.getWeatherInfo()
|
Ales |
Yes i do bind service before that
|
Mark M. |
OK
|
Mark M. |
then, one (may or may not be "best") solution is to use a callback or listener object
|
Nov 9 | 5:00 PM |
Mark M. |
your call to getWeatherInfo() passes an object to the service
|
Nov 9 | 5:00 PM |
Mark M. |
when the service is done getting the weather, it calls a method on that object
|
Mark M. |
use that to have your service asynchronously notify the activity of the results of the work
|
Mark M. |
which, among other things, can change your icon
|
Ales |
oh i see
|
Mark M. |
in the current edition of _The Busy Coder's Guide
to Android Development_, I show using a broadcast Intent for this, which
also works, but the callback is more efficient and private
|
Mark M. |
you will see the callback approach used in _Android Programming Tutorials_, in the Patchy samples
|
Ales |
You see ... here is why i used thread and handler to get info back
|
Mark M. |
Tutorial 18 and 19, specifically
|
Ales |
Did not not what else to do
|
Mark M. |
well, like I said, the books have examples of ways of doing it
|
Mark M. |
and, the next update to the original Busy Coder's Guide will have more patterns as well
|
Ales |
thank you
|
Mark M. |
OK, anyone have a last question before we wrap up the chat?
|
brack |
yeah if you have a minute
|
brack |
three things, really: just a point in the right direction would be great
|
brack |
1) resizing an image: anything i should search on specifically? is there a tutorial already in your book?
|
Nov 9 | 5:05 PM |
Mark M. |
nothing in the books, check earlier in this chat for discussion of it, and see BitmapFactory
|
brack |
2) my ongoing notification for my service isn't a marquee (ie text too big, doesn't scroll). should it scroll?
|
brack |
ok cool, will check bitmapfactory
|
Mark M. |
you lost me on 2)
|
brack |
sorry, meant to say: should it scroll automatically, or do i have to set a flag?
|
Mark M. |
do you mean a real Notification?
|
brack |
yeah
|
Mark M. |
if so, it's an icon, not text
|
Mark M. |
what text?
|
brack |
hm, perhaps we missed eachother on the
Notification thing. i'm referencing the top-tray notification area that
allows custom views, etc
|
brack |
i'm not taking advantage of a custom view currently. i'm using Notification with text
|
brack |
View paste
|
Mark M. |
right
|
Mark M. |
that text appears briefly when the Notification is first added
|
Mark M. |
it is on screen for 1-2 seconds
|
brack |
tickerText doesn't seem to do anything
|
Mark M. |
sure it does
|
Mark M. |
check out Notification/Notify1 sample from _The Busy Coder's Guide to Android Development_
|
brack |
ah, it ticks when it pops on screen? i didn't notice. i'm mainly trying to get the system tray one to work
|
brack |
ok cool
|
brack |
will definiteyl check that out
|
Mark M. |
yeah, it is only there just for a moment
|
brack |
last one: marquee for a textview
|
Mark M. |
what about it?
|
brack |
can't seem to get this to work... maybe i should paste code, or perhaps you already have a tutorial
|
Mark M. |
the effect only appears if the TextView is in the selected state
|
Mark M. |
or its parent is in the selected state
|
Nov 9 | 5:10 PM |
brack |
right, i had indeed read that at some point
|
Mark M. |
for example, if you try the Fancy/DynamicTab
sample and add a whole mess of tabs, you will see the selected tab's
caption do the marquee thing twice
|
brack |
which means the user must have had to interact with it to have it be scrolling
|
Mark M. |
yeah, otherwise if you used it a lot, the screen would be way too busy
|
brack |
ah- what would "selected" mean
|
brack |
user selected? or can i specify my textview as selected
|
Mark M. |
in the case of tabs, it's the selected tab
|
Mark M. |
you can try setSelected()
|
Mark M. |
that might have side effects
|
Mark M. |
haven't tried it
|
brack |
alright, will try that. i had it working for a
brief period, and eventually it broke. wasn't sure if there was a
specific trick to getting the text scrolling properly
|
Mark M. |
it probably just got stuck -- try WD-40
|
Mark M. |
:-(
|
brack |
and by had it working, i mean it was defined in XML and when the view loaded, it would make the text ticking as expected
|
brack |
haha
|
Mark M. |
er, :-)
|
Mark M. |
ok, that's it for today's chat
|
Octavian D. |
thanks Mark, good night
|
brack |
great, thanks a ton Mark. appreciate it; good night
|
Mark M. |
have a pleasant day, everyone!
|
Prasanna P. | has left the room |
brack |
you as well!
|
Ales | has left the room |
Octavian D. | has left the room |
brack | has left the room |
NetApex | has left the room |
Mark M. | turned off guest access |