Office Hours — Today, December 1

Tuesday, November 29

Mark M.
has entered the room
Mark M.
turned on guest access
Dec 1
10:00 AM
BenVonHandorf
has entered the room
Mark M.
howdy, Ben!
how can I help you today?
BenVonHandorf
Mark, I wanted to thank you for your books, for starters, and ask you a non-techncial question... how did you go about moving from beginner to intermediate and advanced in Android?
Mark M.
first, you're welcome
BenVonHandorf
I'm at the point where I've got a pretty good handle on the basic stuff, IMHO...
I can come up with 3 or 4 different approaches to any problem, but I dont' yet have that "journeyman" level of understanding that helps me decide which one to pursue./
Mark M.
well, "best practices" are still very much a work in progress in the Android community in general
BenVonHandorf
From your blog post, I've started following the various chatrooms and reading other stuff, but most books aren't covering the kind of stuff I'm after at this point... the patterns and best practices.
Mark M.
that's because Android is a bit young
10:05 AM
Mark M.
now, I will be trying to cover more of what we *do* know *today* of best practices in the Big Book Reboot
however, there will be gaps
gaps big enough that the gaps will have their own little gaps... :-)
and, today's best practices may not be tomorrow's best practices
BenVonHandorf
I can handle gaps... but there are so many bits to the SDK that it's hard to decide what's actually worth using and what is just crazy Google engineer thoughts.
Like ContentProviders. :)
Mark M.
ah, well, um
different people will have different perspectives on that
it's like asking what's the best beer
BenVonHandorf
So, no consensus has emerged?
Mark M.
certainly there's no consensus on every given possible point in Android
if you mean ContentProviders specifically, there are two main camps:
1. ContentProviders are fine for inter-process stuff but aren't the greatest for internal stuff
2. ContentProviders should be used everywhere
I am in the first camp
others are in the second
BenVonHandorf
So inside of an app, would you just pull cursors up to the UI from, say, a SQLite DB?
Mark M.
sure
BenVonHandorf
Or do you deserialize into POJOs?
Or...?
Mark M.
I tend to avoid converting to POJOs just for the sake of converting to POJOs, as that consumes more heap and CPU
so, for a simple CRUD app, I'd just work with the Cursor
BenVonHandorf
Agreed, but I'm fairly new to Java and wasn't sure if that was a stupid approach.
10:10 AM
Mark M.
there may be cases where there is so much application logic tied to the models that converting to POJOs will be the right answer
and certainly Android devices have tended to get faster
with larger heaps
BenVonHandorf
Sure, there are always exceptions... I can accept that... but the object conversion and the nice way the adapters work with Cursors seemed to make Cursors a better choice generally.
Mark M.
I agree
BenVonHandorf
So, another "approach" question... How would you go about syncing data in a local DB in the background? SyncProvider? Inexact alarms with a Service? I'm currently working down the SyncProvider method, and it seems OK, but I don't know enough to figure out if I'm going to hit a hard wall with it.
Mark M.
I haven't yet played with SyncProvider
I have spoken with people who have, and they have tended to use profanities in the discussion
BenVonHandorf
Uh oh.
Mark M.
but I don't recall any specifics of what they encountered
I hope to play with SyncProvider in 2012
shortly before the Mayan apocalypse occurs in December
:-)
BenVonHandorf
I just hope the Apocalypse runs Android. At least then all this effort learning the platform won't be wasted.
Mark M.
right now, if I had to implement something, I would use an inexact repeating alarm
yeah, but it will have Carrier IQ installed
BenVonHandorf
DOH!
I swear, the manufacturers really are trying to kill Android, aren't they?
Mark M.
Manufacturers are used to a world where they controlled matters more
it takes a while to change that attitude
10:15 AM
BenVonHandorf
<sigh>
So how do you go about keeping up? Mostly reading or mostly writing little apps to play with new features?
Chaitanya
has entered the room
Chaitanya
Hello
Mark M.
oh, it's a lot of trial and even more error
howdy, Chaitanya!
Chaitanya
Hi Mark. No questions yet, just dropping in
Mark M.
OK
Ben: I also do bits of consulting, which gets me into more areas that I might not have investigated as quickly otherwise
and I'm cutting back on training to be able to spend more time on engineering
for example, there's TouchFire
I'm working with them to get Android support going for their keyboard overlay thingy
I'll take the SDK SoftKeyboard example and get it to line up with their physical key placement
BenVonHandorf
Oh, awesome!
10:20 AM
Mark M.
open source the results, and try to spur developers who create good IMEs to offer a TouchFire compatible version
ordinarily, writing IMEs would be low on my list of priorities
but, I'll do some light experimenting here
BenVonHandorf
Seems like there are a lot of things like that going on with Android. One of the things I like about the platform.
Cool. I'll stop monopolizing your time, but do you mind lurkers in these chats?
Mark M.
I don't mind them
but, these chats are mostly for Q&A
so, lurkers often get bored, I suspect, if there's nobody asking questions :-)
BenVonHandorf
Understood... but sometimes seeing a question points you in a direction you didn't know existed.
Mark M.
agreed
BenVonHandorf
And the SDK is so broad and has so many different ways to do the same thing...
Chaitanya
I do have a thought I'd like your comment on Mark
Mark M.
I'm still posting links to the transcripts on the cw-android Google Group, though eventually I'll switch that to a feed of some sort
Chaitanya: go ahead!
Chaitanya
As a consultant developer, when asked to provide estimates on developing an Android app, am I justified in stating that given the same development skill, developing for the Android platform would require more hours than developing on iOS?
I know the platforms cannot be compared directly
Mark M.
oh, I have no idea
I can barely spell OiS
iSO
iOS
whatever
:-)
Chaitanya
but its a question I often wonder about
Mark M.
oh, it's a perfectly valid question, just not one that I can answer
Chaitanya
but if you had to wager...
Mark M.
well, it depends
10:25 AM
Mark M.
Android development might take more time for a couple of reasons:
Chaitanya
my justification is that since we have to support a broader range of devices, we have to put in more code to handle the various configurations
Mark M.
1. Some things are just plain harder, such as dealing with varying screen sizes
2. You might try doing things that you simply can't do in iOS, such as app widgets
OTOH, Android apps tend to skate by with, shall we say, less-sophisticated graphic design
and iOS apps may have to go a couple of rounds with the App Store folk for approval
in those cases, iOS might take more effort
on the whole, particularly if you are putting equal graphic design effort on the Android side, and you are targeting the full range of Android devices, Android probably takes more time
Chaitanya
I'm pretty adamant that the applications I design should use customized UI controls which leads to further development time. This might change once I play with the native UI of ICS.
oh speaking of which, how is the Galaxy Nexus treating you?
Mark M.
um, let's just say that I think the phone, ICS, or both, were slightly rushed to market
nothing huge
BenVonHandorf
FWIW: Things like the 9-patch images on Android made custom buttons in our app easier on Android than iOS (where every button text was a different image). Direct development time is harder to compare... different teams worked on it.
Mark M.
and, curiously, I haven't encountered the fabled volume bug
BenVonHandorf
Volume but?
bug?
Mark M.
yeah, the Galaxy Nexus has a tendency to spontaneously change volume, apparently
lots of coverage
seems to be tied to interference from other phones
a patch is forthcoming
Chaitanya
I did read today that they've started rolling out the fix OTA
10:30 AM
Mark M.
yeah, it'll be interesting to see how that works with mine, since mine is imported from the UK by Expansys
I've always had US phones before, and received OTA
updates
not sure if the UK phone will change that dynamic
Chaitanya
ok
Mark do you host Hangouts?
Mark M.
I'm not yet a G+ member
Chaitanya
Ok, I think that would be pretty helpful :)
10:35 AM
BenVonHandorf
Mark, are there any good regional conferences for Android development? Something like CocoaConf for iOS?
Mark M.
not in the US
BenVonHandorf
I'm hoping to go to IO next year, but that sold out so quickly last year... and all the other conferences are expensive and would involve travel/hotel/etc.
Mark M.
the droidcon series would be roughly equivalent
Raza R.
has entered the room
Mark M.
droidcon has one in Berlin, London, and... um... forget exactly which city hosted the recent Netherlands one
plus India
BenVonHandorf
I wonder why nothing US based yet...
Mark M.
howdy, Raza!
10:40 AM
Raza R.
View paste
Hello
I'm getting problem in getting location in emulator
it's showing null value
Mark M.
Ben: there are the occasional one-day events hosted by Meetups or GTUGs
Raza: OK
are you sending it a fix from DDMS or telnet?
and, if so, is your LocationListener registered before you send the fix?
Raza R.
yes i did both sent from DDMS as well telnet
how to register??
Mark M.
call requestLocationUpdates() on the LocationManager
Raza R.
View paste (54 more lines)
used following code
private TextView latituteField;
	private TextView longitudeField;
	private LocationManager locationManager;
	private String provider;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        latituteField=(TextView) findViewById(R.id.unknownLbl);
        longitudeField=(TextView) findViewById(R.id.unknownlon);
        
        //Get the location manager
        locationManager=(LocationManager) getSystemService(Context.LOCATION_SERVICE);
...
Mark M.
OK
Raza R.
View paste (33 more lines)
 // Initialize the location fields
        if(location!=null){
        	System.out.println("Provider"+provider+"has been selected");
        	int lat=(int) (location.getLatitude());
        	int lng=(int) (location.getLongitude());
        	latituteField.setText(String.valueOf(lat));
        	longitudeField.setText(String.valueOf(lng));
        } else {
        	latituteField.setText("Provider not available");
        	longitudeField.setText("Provider not available");
        }
    }
    /* Request updates at startup */
	@Override
	protected void onResume() {
...
Mark M.
Raza: the View paste link shows the full paste
Raza R.
yeap got it
Mark M.
once your activity is launched, and you have gotten past onResume(), if the activity is in the foreground, simulated fixes from DDMS/telnet should work
10:45 AM
Mark M.
also, make sure your emulator thinks it has a signal
IOW, it shows the 3G indicator and such
if the emulator shows no signal, then it will not respond to simulated GPS fixes
Raza R.
yes its showing 3G indictor
Mark M.
beyond that, I don't know what to tell you
your code seems OK
Raza R.
m getting following message, "Provider not available"
Mark M.
where are you getting this message?
oh, never mind
you're calling getLastKnownLocation()
that's not going to work
Raza R.
that program showing
Mark M.
you don't have a location by that point in time
just use the location supplied to the LocationListener in onLocationChanged()
10:50 AM
Raza R.
any possible solution for that
Mark M.
no
geLastKnownLocation() will frequently be null, on hardware and the emulator
er, sorry, that's getLastKnownLocation()
the only time you are fairly certain that getLastKnownLocation() will work is after you start receiving fixes via onLocationChanged()
bear in mind that it may take several seconds or longer for GPS to become available after you call registerLocationUpdates()
it might *never* be available if the device cannot get a GPS signal, or if the user has GPS disabled
Raza R.
ok, otherwise code was right na?
Mark M.
it seems OK
it resembles my book examples :-)
Raza R.
View paste
at the time of fixing geo location in DDMS, i supplied Lon Lat and altitude
my question is how to find altitude of the particular location?
Mark M.
call getAltitude() on the Location object
10:55 AM
Raza R.
is it possible to extract source file from apk ??
Mark M.
not really
an APK can be "decompiled" into something more readable than a bunch of binary bits
but you don't get Java syntax source code as a result of the decompile
any last questions?
Raza R.
View paste
What does this error mean?? ->  I/Database(369): sqlite returned: error code = 1, msg = near "intousersvalues": syntax error
11:00 AM
Mark M.
it means you have a syntax error in your SQL
NEAR, for example, only works in SQLite on FTS3 tables
or, perhaps "near" is just part of the error message
not sure
regardless, that's a wrap for today's office hours chat
the next one is Tuesday, 4pm US Eastern Time
Raza R.
Thanks for the help
BenVonHandorf
Thanks!
Mark M.
have a pleasant day, all!
BenVonHandorf
has left the room
Chaitanya
has left the room
Raza R.
has left the room
Mark M.
turned off guest access

Tuesday, November 29

 

Office Hours

People in this transcript

  • BenVonHandorf
  • Chaitanya
  • Mark Murphy
  • Raza Rahil Hussain