Office Hours — Today, July 8

Tuesday, July 6

Jul 8
9:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
Stefan D.
has entered the room
Mark M.
howdy, Stefan!
Stefan D.
howdy Mark
I am the time zone messy
10:00 AM
Stefan D.
may i start?
Mark M.
but you are here now, and that is what matters
go right head!
er, ahead!
Stefan D.
thanks
so maybe you wanna have a look at the "architecture" of my app: http://img713.imageshack.us/img713/4165/ar…
basically i am using an App Widget as an entry point to launch two different apps
Mark M.
A and B are triggered by clicks?
Stefan D.
they are independent from oneanotherd
yes
Diaryappwidget
thats what the app widget looks like
CalvinS
has entered the room
Mark M.
that's mighty big
(BTW, howdy, Calvin!)
Stefan D.
Activity A is launched by the 2 buttons under core questions
it is intended to be big ;)
CalvinS
Hi!
Stefan D.
Activity B would be accessible via button under Trigger task(s)
Mark M.
ok
Stefan D.
the ? icon is a button as well
they start a Dialog (as an activity with dialog theme)
here comes the problem:
sometimes the PendingIntents attached to the buttons get mixed up
After coming back from Activity B a click on a core question button might take you back to Activity B, instead of A
Marc T.
has entered the room
Marc T.
hi everybody
Stefan D.
or the ? buttons display not the corresponding help text
10:05 AM
Mark M.
Stefan: your PendingIntents probably are wrapping Intents that are not sufficiently distinct
Stefan D.
so I am gessing that either the Pending Intents have to canceled (pendingIntent.cancel() )
Mark M.
(btw, howdy, Marc T!)
Stefan D.
ok
I use explicit intents
And Activity A and B are entirely distinct applications
or Activities wrapped into the same app
so how about canceling the PendingIntents? I create new PendingIntents on each AppWidget update
Mark M.
use FLAG_UPDATE_CURRENT or FLAG_CANCEL_CURRENT
Stefan D.
so now if created an ArrayList and add all PendingIntents to that list
Mark M.
when you create the PendingIntents
Stefan D.
as an extra to the wrapped Intent?
flag, i mean
Mark M.
no, FLAG_UPDATE_CURRENT and FLAG_CANCEL_CURRENT are flags you pass to getActivity()
when you create the PendingIntents
Ted
has entered the room
Mark M.
Mike R.
has entered the room
Stefan D.
ok
Mike R.
Hello
Stefan D.
is there any chance that my manifest is set up badly?
Mark M.
howdy, Ted and Mike R -- you are in line after CalvinS and Marc T
Stefan D.
could the manifest cause this behaviour?
Mark M.
Stefan: possibly, but I'd start with the PendingIntents
10:10 AM
Stefan D.
ok. last question: does canceling the PendingIntents before creating new ones have an effect?
Mark M.
it should be identical to FLAG_CANCEL_CURRENT
which is why I am steering you in the direction of using those flags
Stefan D.
ok, thanks a lot.
others, go ahead
Mark M.
ok, CalvinS -- do you have a question?
CalvinS
View paste
I have a ListView that is sourced from a database using a custom SimpleCursorAdapter.
I want to implement List Filtering and think you need to
1)	override CursorAdapter runQueryOnBackgroundThread(CharSequence constraint) to return a Cursor that takes the constraint into account
2)	override CharSequence convertToString(Cursor) to tell adapter which column to use as the value

I’m not sure if that is everything that needs to be done.  Do you have any sample code for this?
Mark M.
no, sorry, I have not played with list filtering yet
CalvinS
ok
Mark M.
don't know much about it
OK, Marc T -- do you have a question?
Ted
has left the room
Mark M.
OK, we'll get back to Marc T in a bit...
and with Ted now gone...
Mike R: do you have a question?
besides "will LeBron wind up with the Nets?" :-)
10:15 AM
Mark M.
tap...tap...tap... is this thing on?
Marc T.
just want to ask if you have plans on publishing a book about NDK dev't. Most of my dev't on android for the past few months are on NDK
Mark M.
Marc T: there will be chapters on the NDK in _Android Beyond Java_
however, if you have been working with the NDK for "the past few months", you know more about the NDK than I do, most likely
Marc T.
:) not really..just hacking a few things here and there
Mark M.
yeah, well, you assume I've done much more than that... :-)
Robert C.
has entered the room
Marc T.
even if I've been coding android stuff for more than a year, I still subscribe and look at your book from time to time
Mark M.
glad to hear it!
howdy, Robert C!
Robert C.
hi Mark
Mark M.
since Mike R seems to be away from his browser...
Robert C: do you have a question?
Mike R.
oh i'm back
Mark M.
OK, Mike R: do *you* have a question?
10:20 AM
Mike R.
yeah. starting getting crash reports and have one I can't figure out.
looks like this:
View paste (35 more lines)
v1.1
Jul 4, 2010 12:28:25 PM
1 reports/week
1 reports
java.lang.RuntimeException: Unable to resume activity {com.medpagetoday.medpage/com.medpagetoday.medpage.MyNews}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2508, result=3502, data=null} to activity {com.medpagetoday.medpage/com.medpagetoday.medpage.MyNews}: java.lang.NullPointerException
  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2950)
  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2965)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2516)
  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:4363)
  at java.lang.reflect.Method.invokeNative(Method.java:-2)
  at java.lang.reflect.Method.invoke(Method.java:521)
...
Mark M.
Is the v1.1 coming from your app, or indicating this is Android 1.1?
Mike R.
1.1 is my app
Mark M.
looking at the source code for ActivityThread and performResumeActivity()...
tough to decipher, particularly with a head cold
feels as though maybe the activity that called startActivityForResult() was destroyed, and they are having difficulty recreating it
does this exception happen often?
Mike R.
So far, i've gotten one report. the app method that's being called is:
Mark M.
I see "1 reports" for this week
Mike R.
View paste (13 more lines)
	public void onActivityResult (int requestCode, int resultCode, Intent data) {
		switch (requestCode) {
		case SETTINGS_ACTIVITY:
			if (MyNews.channelsChanged) {
				appService.saveConfiguration();
				prepareSubscriptionsList();
				channelsChanged = false;
				beginInitialProcessing();
			}
			break;
		case ARTICLE_LIST_ACTIVITY:
			prepareSubscriptionsList();
 			myAdapter.notifyDataSetChanged();
			prepareActivityDisplay();
			break;
...
10:25 AM
Mark M.
I wouldn't worry about it too much, if it only happened once, and there's no obvious tie to your code
Android is a complex system and certainly has bugs
Mike R.
ok thanks. i have another question, but I'll let others get in first
Mark M.
if it keeps repeating, see if you can glean any commonalities about environment (e.g., only older phones with less RAM)
OK, Robert C: do you have a question?
Robert C.
yes, thanks
I'm still working the wifi dropping problem.
I found that if I turn it off and just use the 3G, the player will go on forever.
That is exactly what we want.
If WiFi is turned on though, the phone eventually shuts it down and we loose our connection to the audio stream.
I've tried everything I can think of to keep WiFi on but it still cuts out.
Mark M.
and you're holding a WifiLock?
Robert C.
Most definitely.
When I wake the phone back up, the code tries to regain a lock.
Mark M.
are you also holding a WakeLock?
Robert C.
In that code, it determines that it already has a lock and so skips asking for another one.
I tried that as well and it had no effect.
I'm starting to think the phone or platform is to blame.
Mark M.
if you are holding a WakeLock, and the device is going to sleep, you have a fundamental problem
you might experiment with different WakeLock types
Robert C.
The screen locks and then after 30 seconds the WiFi goes away.
So your call is that the lock should work no matter what?
I could try with the strongest one and see what happens.
Mark M.
well, the WakeLock should at least keep the CPU running.
10:30 AM
Mark M.
however, PARTIAL_WAKE_LOCK gives no visible indication of whether the WakeLock is indeed working, since the screen goes dark in either case
you could try SCREEN_DIM_WAKE_LOCK
Robert C.
Yes, but I didn't see that as a problem. It was the Wifi cutting out. As I said, if the phone is using 3G, then the application will run for hours and not loose the audio stream.
Mark M.
yes, but I think there may be different power behavior characteristics for network access over 3G
Robert C.
I'll try different settings, but we really want to screen to go dark and be completely off.
Mark M.
understood
however, right now, you need to figure out whether your phone is busted :-)
Robert C.
Do you know of a way to cut back to 3G if the WiFi goes out?
:)
Mark M.
drop and re-establish your connection
Robert C.
HTC Incredible by the way.
So detect the drop and then retry it?
Mark M.
yes
off chance you may need to delay the retry by some number of milliseconds
Robert C.
That could work if I can detect it properly. Thanks. I have a few things to try at least. :)
Mark M.
not sure how quickly 3G gets re-established
I think there are broadcast Intents from either ConnectivityManager or WifiManager that may help
Robert C.
Well, the music gets buffered for 30 seconds I believe by the MediaPlayer. That means I have plenty of time to get a connection back.
Mark M.
but it is pretty strange that an active WakeLock and WifiLock are giving you the phenomena you are seeing
Robert C.
I like that idea as well. I'll see if ConnectivityManager can tell me something.
That is why I think it is the HTC Incredible but I'm hoping not.
Mark M.
well, I know of other bugs in the Incredible
so it's certainly not out of the question to be HTC's fault
Robert C.
Do you have a list of those bugs somewhere? Would be very interested to look at them and make sure something else in the program is not affected.
Mark M.
the only one I'm sure of is that you cannot use the number field on Notification
10:35 AM
Mark M.
it will not draw the number in the red dot over your status bar icon
on Incredible or EVO 4G
amply demonstrated by the sample code in my first book
Robert C.
I don't think that will be a problem for us. Thanks for the help!
Mark M.
I seem to recall other Incredible-related complaints on [android-developers], but my cold is making it difficult for me to think
OK...Stefan: do you have another question?
Marc T.
hmm can i ask a question while stefan is away (?)
Mark M.
hang on
CalvinS: do you have another question?
OK, Marc T -- go ahead
10:40 AM
Marc T.
yeah, just wondering how the Youtube widget and NEws & weather widget made their text animate? AlarmManager triggering the service every X seconds?
Mark M.
possibly
also, they might not be app widgets
we don't have the source for those
they could actually be features of the home screen
Marc T.
but home screen is open source right?
Stefan D.
I'd have another question if noone else will join. But people who haven't had their shot are 1st
Mark M.
depends on which home screen it is
I have not used the YouTube widget
the News/Weather widget is probably just AlarmManager
Marc T.
hmm, ok. thanks. Will just try that approach
Mark M.
Stefan: go ahead
Stefan D.
alrighty
I have an activity which is a modification from the ApiDemos' FingerPaint
It combines taking a picture and drawing on that photo afterwards
but I fail at handling bitmaps properly
10:45 AM
Stefan D.
I need to create a pretty small bmp from the jpg for 2 reasons:
1. a 5MP photo as a bitmap will not make the memory happy, to put it nicely
2. the image has to be scaled to the screen so a user can view the entire photo
that is the more important thing
so what I am trying to do is maintaining the actual image size (e.g. 5MP) and just scale the finger's drawing. And it will have to merged into one image. any hints?
Mark M.
what happens after the image is merged?
Stefan D.
right now I am using the bitmap inside of a canvas
it will be transfered to a server
Mark M.
your server?
Stefan D.
yes
Mark M.
do the merge there
much more CPU power
much better tools
Stefan D.
interesting
automated?
Mark M.
presumably
Stefan D.
what kind of data would my server require?
what would it expect?
2 seperate images?
Mark M.
the photo, the drawing, and details on how the drawing should be upsized to do the merge
plus any info you need for what the server should do with the result
Stefan D.
sure
10:50 AM
Stefan D.
how about that upsizing point?
Mark M.
inverse of whatever you downsized the photo to
Stefan D.
ok
sounds promising
what tool would you recommend on the server side?
Mark M.
well, I'd use ImageMagick, but that's because I'm not that good at this sort of thing and it's the only tool I know
:-)
Stefan D.
so the PHP script could call the command line version of ImageMagick and process the picture, I guess?
Mark M.
yes, or there may be a PHP library that can do it -- I'm not a PHP guy
Stefan D.
me neither
anyhow, nice approach. I'll give it a shot
thanks, mate
Mark M.
OK, any other questions?
Mike R.
I have one
Mark M.
go ahead
Stefan D.
no from my side
get well soon.
I'm out
Mike R.
if you'll recall, i have a service in my app.
Robert C.
Take care all!
Stefan D.
bye everyone
10:55 AM
Mike R.
it opens a sqllite database in oncreate and closes it in ondestroy
10:55 AM
Mike R.
in the meantime the service spins off several threads in response to requests from different app activities
Stefan D.
has left the room
Mike R.
one of these threads could take a long, long time to complete
while that thread is running, the user could leave the application
i had thought that the service would remain running until all of its threads terminate, but not so
Mark M.
certainly, onDestroy() cares not a whit about background threads
Mike R.
so this thread tries to access the database that ondestroy has already closed
i modified all my threads to check for the existence of the database. if the database is null, just return.
is there a more elegant way to signal any background threads to close?
Mark M.
well, that depends on what the background threads are doing
you can use stuff like AtomicBooleans, and have the threads look at those
Mike R.
they are calling a remote server and updating a database.
Mark M.
however, that assumes they are actively awake and are not blocked waiting on some event
Mike R.
doesn't really matter if they complete their work. they'll restart the next time the app is run
11:00 AM
Mark M.
your options are probably either to stick with what you have, or change it such that the database is only closed when the last thread is done with it
Mike R.
ok last quick question. In the Market Developer Console, what the difference between Downloads and Active Downloads?
that is, Active Installs
Mark M.
AFAIK, downloads is total number of times it was ever downloaded
active installs is downloads - uninstalls
Mike R.
ok thanks. by mark
Mark M.
active installs may run high, due to apps getting removed without a real uninstall (e.g., factory reset)
OK, that's a wrap for today's chat
Mike R.
has left the room
Marc T.
thanks for your time Mark, get well soon
Mark M.
two more next week
thanks!
have a pleasant day!
CalvinS
has left the room
Marc T.
has left the room
Robert C.
has left the room
Mark M.
turned off guest access

Tuesday, July 6

 

Office Hours

People in this transcript

  • CalvinS
  • Marc Tan
  • Mark Murphy
  • Mike Renda
  • Robert Casto
  • Stefan Dierdorf
  • Ted