[android-developers] Re: Smaller tabs, such as the Facebook official app

2010-02-15 Thread Bob Kerns
My Nexus is rooted, so as keianhzo points out, perhaps that has
something to do with it. Or perhaps doing 'adb root' first would
suffice.

Anyway, from the External Tools launch configuration in Eclipse:
Name: hierarchyviewer
Location: ${workspace_loc:/Tools/android-sdk-windows/tools/
hierarchyviewer.bat}
Working Directory: blank
Arguments: blank
Nothing needed on the other tabs, either

I should get rid of the .bat file and invoke Java directly, but this
just worked...

On Feb 14, 6:52 pm, Mark Murphy mmur...@commonsware.com wrote:
 Mark Murphy wrote:
  I just tried the Android 2.1 SDK hierarchyviewer on the Nexus One and
  DROID, and hierarchyviewer refuses to work with either of them.

 I should point out that I've tried these from a Linux host. Perhaps
 Windows works better for this. I never bothered trying another host,
 after Mr. Guy's comments.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Android Consulting/App Development:http://commonsware.com/consulting

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Failed to fetch URL https://dl-ssl.google.com/android/repository/repository.xml

2010-02-15 Thread Bob Kerns
It seems you have quite unrealistic expectations of the community, and
aren't even willing to help yourself.

Let's see here:

1) Your sysadmins block direct web access to the Internet

2) You route your web requests through some unknown piece of software
using one of several protocols to forward your requests,

and

3) You expect the community to fix it all up for you? Who's being
selfish?

I have a solution for you: stop blaming the community. We can't help
you with any of that.  Talk to your sysadmins. They CAN help you.

They may not be willing to. That doesn't make them the bad guys,
either; I don't know their situation.

But at least the have all the facts available to them, and access to
investigate and fix.

Finally: it would take you all of 2 minutes to look at repository.xml,
and choose the download URL you want from that file. Just replace
'repository.xml' with the appropriate sdk:url.../sdk:url value.

If you want to help yourself -- go home, or to a public library or a
coffee shop or something, and download it onto a USB key.

I think I can safely speak for the community, when I say the community
doesn't like being flamed for things that are not the community's
fault.

On the other hand -- if, in the course of your investigations, you
have SPECIFIC questions, with sufficient context, we're still glad to
answer. The community doesn't hold grudges, much.

Ashish Srivastava wrote:
 This is really bad behavior. None of you are trying to solve the
 problem for people with Proxy + Authentication enabled. It's really
 that people are being truly selfish. Shame on the community.

   On Jan 4, 9:31 am, teryz teryzpl...@gmail.com wrote:
 
I have a problem using AndroidSDKUpdater (revision 4). For the
record I'm under win xp 32-bits, jdk 1.6.
I set up the Force https://... sources to be fetched using http://
This seemed to work fine but as I am behing a (corporate)proxyI also
filled theproxyserver and port settings, however thisproxyrequires
a user/passwordand I can't find a way to give Android Updater aproxy
authentication as no authentication box pops up when I try downloading
updates and I have a
 response code: 407 for 
URL:http://dl-ssl.google.com/android/repository/repository.xml;
when refreshing sources.
 
If someone can help...
 
Teryz.
 
On 4 déc 2009, 09:30, Cédric Berger cedric.berge...@gmail.com wrote:
 
 2009/10/29 Cédric Berger cedric.berge...@gmail.com:
 
  2009/10/29 Cédric Berger cedric.berge...@gmail.com:
  I can't download through aproxyrequiring authentication.
 
  I had to select force http, and put user/passwordforproxyin JVM
  command line. This way I can get the list of available updates.
  But when trying to download, it stays stuck (looks like it waits 
  for
  user/password, but no prompt).
 
  Oh in fact it is ok. Through a secondproxy(with authentication too)
  it worked. Looks like the firstproxy(a bit more restrictive) blocked
  the downloading url. (I could not check why since the URL is not
  shown)
 
 What is the download URL ?
 Because I still have problems with theproxyI use. I can download
 updates metadata, but when trying to install, it hangs.
 I suspect theproxyblocks the download URL (but 
 nothttp://dl-ssl.google.com/android/repository/repository.xml)... how
 can I check what this download url is  (so I could ask for correction
 in theproxyrules) ?
 
 

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: android 3DOF controller - call for developers

2010-02-15 Thread Bob Kerns
Posted at: 
http://groups.google.com/group/elenhos/browse_thread/thread/c3605f6fa39a6b62

Short version use the (magnetic) force, Luke! :) (Not a perfect
solution).

On Feb 15, 4:41 am, Jubei nkatza...@gmail.com wrote:
 As far as I know, without using the camera/trackball/touchscreen it's
 not very easy to add more DOF.

 If you have any ideas we'd be happy to hear your thoughts on the app's
 google group
 ]http://groups.google.com/group/elenhos

 Any ideas would be more than welcome.

 Nicholas

 On Feb 6, 4:43 pm, Bob Kerns r...@acm.org wrote:



  Just a thought -- why only 3 degrees of freedom? You've got these nice
  accelerometers...they can do more than sense a gravitational field...

  I've bookmarked it to have a look at your code. I'll keep you in mind
  if I have anything to contribute at some point.

  On Feb 5, 7:07 pm, Jubei nkatza...@gmail.com wrote:

   Just wanted to let the community know that Ive released the source
   code and I'd be more than happy to accept code contribution to the
   project (even if the source isn't very readable).

  http://code.google.com/p/androidcontroller/

   If anybody is interested in helping out drop me a line.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: system hangs while giving Android build

2010-02-15 Thread Bob Kerns
When I change the SDK version for a project, it hangs. I end up
killing Eclipse and restarting, then doing  a Clean, and all is fine.

(I have to start remembering to turn off the automatic build in these
cases).

Perhaps you're seeing something similar? Maybe if a build tool gets an
error at the wrong point in the process, Eclipse ends up waiting for
something that's not going to happen?

On Feb 15, 4:05 am, Saikat saikat0...@gmail.com wrote:
 But other people here, are using 1 GB RAM and the build is fine in
 their system. Nobody is seeing any system stuck kind of problem. My
 hard disk is also fine.

 On Feb 10, 5:13 pm, James Wang jameswangc...@gmail.com wrote:



  I did have the same experience before. I think 1G is not enough and
  your disk should be good enough.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: static context access

2010-02-15 Thread Bob Kerns
I presume you're setting this up in the Application, right? Indeed,
passing in the application at that point is just what I was about to
suggest.

Actually, I see nothing at all wrong with doing this. Just post it to
the main thread's Handler, and do everything except interception
there.

Just make sure that your code that runs in the main thread is bullet-
proof. (And anything it then passes off to other threads). That's just
a matter of having a catch (Throwable ex) {...} and logging, but not
passing on, any errors that occur.

I've done this sort of thing in a number of environments. I would even
go so far as to term this a cross-platform best practice.

In terms of thread handling and communication, this is no different
than anything else you'd do in another thread. When you have something
to do in the normal context, you post it.

The one thing that CAN get tricky, is trying to recover from failures.

Another possibility is to set up your own Handler in your own thread.
Then you can do things like post Toast notifications, etc. while
leaving the main thread alone.

I've done this, and it worked, but then decided I didn't have any good
reason for it. However, this could be useful if the main thread is
stuck in a loop. But if you do it right, you can start off going to
the main thread, and switch to this later.

On Feb 15, 12:20 pm, laphroaig15 laphroai...@gmail.com wrote:
 Didn't eat my wheaties this morning.  I can simply pass in the
 reference during the construction of the handler.

 Mark, thanks for the feedback.  I agree that broadcasting through an
 excepted context is a little dicey, but it seems to work for now.  I
 can't think of a better alternative context-less thread - android
 communication short of something horribly inefficient like file
 polling, but I'm open to suggestions.  I am building a whatever app
 to report exceptions, so using Flurry or DroidDrop would defeat the
 purpose.  You are right in that, tragically, whatever cannot self-
 reference its own automated exception reporting capabilities.  ;)

 thanks for the input,

 -Jess

 On Feb 15, 2:01 pm, Mark Murphy mmur...@commonsware.com wrote:



  laphroaig15 wrote:
   Is there some way to interact with the android packages to
   retrieve a context in a static manner?

  Not really. The Application object is a singleton, as is any Service you
  have running, but I am not aware of ways to obtain those from a static
  method.

  Moreover, please do not try binding to a service from an exception
  handler. Broadcasting an Intent may be safe, but I'm not completely
  confident of that, either.

  Even simpler is just to use Flurry or DroidDrop or whatever to report
  your exceptions.

  Trying to have an Android component respond to an exception may prove
  troublesome, particularly if the exception is thrown from the Android
  component in question.

  --
  Mark Murphy (a Commons 
  Guy)http://commonsware.com|http://twitter.com/commonsguy

  Android Development Wiki:http://wiki.andmob.org

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Regarding expansion of google market

2010-02-15 Thread Bob Kerns
I  must be missing something. What do you mean by the expansion of
google market?

I presume you're referring to Google's Marketplace? If you go to
flurry.com or admob.com, you can find nice charts of the explosive
growth in the Google Marketplace.

New apps are added at a very high rate.

So I'm guessing I'm not understanding what you mean by expansion. Is
this some promised expansion of capabilities? That would be most
welcome!  For example, being limited to just two screenshots does both
the seller and the buyer a grave disservice.

On Feb 15, 9:24 am, karthikr karthik.scintill...@gmail.com wrote:
 Hi Guys,

 I have been waiting for the expansion of google market and to my shock
 I see that there is almost no activity on the same for the past couple
 of months. We just keep hearing that expansion will happen, but
 absolutely no news on the same.

 Does someone out there have any updates, and can comeone from google
 reply for this query that we have been asking a million time, just
 once...

 Regards,
 R.Karthik

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: port forwarding

2010-02-15 Thread Bob Kerns
Never say never -- it would be appropriate for a mySQLAdmin tool, say,
talking over wifi.

Anyway, my answer to Mr. L. Newbie's question, is:

1. You could probably find and/or port such a thing. MySQL's Connector/
J is pure Java. It might rely on some standard J2SE stuff that's not
present on Android, in which case you'd have to come up with
substitutes.

2. GET/POST is *not* the only way -- but it is the best way, the tried
and true way, and what most other people are doing. Google
RESTful (I'm surprised it's that easy to get a good search result,
but it is). The alternative would be to use SOAP, but I wouldn't do
that unless you already know why you want to do that (such as
compatibility with an existing service or environment).

This will also drive the design of your application in a direction
which is more mobile-friendly. It's not really a matter of mobile vs
LAN -- really, I don't recommend the use of direct database
connections except between tightly-coupled components -- such as
between your web service, and its back-end database server. Doing
direct SQL poses everything from security risks to temptations to
depend on aspects of your data model which shouldn't be exposed,
leading to massive compatibility problems, and the need to update all
clients at the same timethe list of reasons goes on and on.

On Feb 15, 3:55 pm, Mark Murphy mmur...@commonsware.com wrote:
 linux newbie wrote:
  1. Is there mysql-connector/jdbc for android?

 It doesn't matter -- you shouldn't use it even if it exists.

 As I've now written for the third time in the past 36 hours or so
 (previous two on StackOverflow):

 Never never never use a database driver across an Internet connection,
 for any database, for any platform, for any client, anywhere. That goes
 double for mobile. Database drivers are designed for LAN operations and
 are not designed for flaky/intermittent connections or high latency.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Android Consulting/App Development:http://commonsware.com/consulting

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Smaller tabs, such as the Facebook official app

2010-02-14 Thread Bob Kerns
??? I use it on my Nexus One all the time. Perhaps it doesn't work on
older devices?

On Feb 14, 8:36 am, Mark Murphy mmur...@commonsware.com wrote:
 If you can find an APK with the smaller tabs, you can always toss that
 into an emulator and use hierarchyviewer to try to figure out how they
 pulled it off. Alas, hierarchyviewer does not work on devices. :-(

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to debug unexpected exceptions (source not found)

2010-02-12 Thread Bob Kerns
Thanks for the jdwpspy suggestion; I'll collect some more data when I
get a chance. Debugging-the-debugger is just my cup of tea, though
normally I have the sources at hand. (Grabbing the full Android
sources is on my to-do list).

However, your test case isn't one that I would expect to reproduce.
Instead of throw new ArithmeticException(), which isn't really any
different from cases I know to work, try the OP's case:

int b = 0;
int a = 1/b; //ArithmeticException

That's when I observed the problem. My theory is that it is specific
to handling of low-level arithmetic, rather than the normal user-code
throw. Just a theory, but more plausible than the idea that the bug is
more pervasive.

(Of course, the observer error explanation is still on the table, as
always).

BTW, a documentation suggestion: Most of the stuff in the Dalvik
Debugger Support document you pointed me at is only going to be of
interest to geeks like me, but some of it is helpful for anyone trying
to debug -- the synchronized method handling, the merging of return
instructions, performance differences, etc. And one I noticed (and
expected) but don't see documented, though it touches on a special
case of it: variables can disappear as you step in the code, when
their values will never be used againn. From register optimization, I
expect.

I think a brief article with the highlights -- including points like
the debug protocol being debugger-agnostic -- would be a good addition
to the developer documentation. Perhaps extend the Debugging Tasks
article a bit.

On Feb 12, 3:11 pm, fadden fad...@android.com wrote:
 Two other thoughts:

 (1) I've seen Eclipse display the exception defined by the Android
 classes and the exception defined by some other VM (either its own or
 whatever JDK is configured).  Make sure you've got the right source
 for the exception.  Since ArithmeticException is working for you I'm
 guessing this isn't at issue, but figured I'd mention it.

 (2) If you're really curious you can use jdwpspy to do a man-in-the-
 middle dump of JDWP traffic.  It sits between DDMS and the debugger.
 It's not a lot of fun to debug the debugger, but it's there if you
 find yourself drowning in free time and a desire to do marginally
 unpleasant things.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: android and proguard...

2010-02-12 Thread Bob Kerns
I was thinking of user code that does e.g.
(Integer)R.string.class.getField(MY_ID_ + i).get().

You may not have any, or think you don't, but since there's so little
benefit to be had, it seems a good candidate for exclusion. Especially
since those names are around elsewhere anyway.

On Feb 12, 2:48 pm, Dianne Hackborn hack...@android.com wrote:
 On Thu, Feb 11, 2010 at 11:01 AM, Bob Kerns r...@acm.org wrote:
  Yeah, it's a good idea to leave R completely untouched. That includes R
  $string, R$drawable, R$id, etc. etc. There are things look at that
  those via reflection, so the names matter, and there's no significant
  bytecodes to optimize anyway.

 For what it's worth, nothing in the platform cares about the R classes.
  Those are only generated for the application's convenience; the platform
 doesn't touch them, and will run happily if they even disappear completely.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: android and proguard...

2010-02-12 Thread Bob Kerns
Hmm, curiously curious must be a reference to me... :)

Is it known which specific Proguard optimization is at fault, so it
can be disabled as a less drastic workaround than disabling
optimization entirely?

On Feb 12, 1:24 pm, fadden fad...@android.com wrote:
 For the curious: sdphil was kind enough to provide the APK and the
 ProGuard-modified classes.  It appears that the dx program, which
 converts Java bytecode to Dalvik bytecode, is emitting a bad sequence
 of instructions.  The verifier is correctly identifying the situation
 and rejecting the class.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Can I reset android device programatically?

2010-02-12 Thread Bob Kerns
Ye gads, I hope not!

On Feb 12, 5:00 am, Boris boris.tarasev...@gmail.com wrote:
 Hi!

 Is there some way to reset android device programatically?
 I'm looking need some way to delete any private data (contacts,
 calendar items, media) from the phone.

 Thanks,
 Boris

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to debug unexpected exceptions (source not found)

2010-02-12 Thread Bob Kerns
I meant to reply to this earlier.

I've seen this before as well, long before Android. So it was one of
the first things I checked; I initially expect it to be the problem!
As you surmised, I had the right one.

On Feb 12, 3:11 pm, fadden fad...@android.com wrote:
 (1) I've seen Eclipse display the exception defined by the Android
 classes and the exception defined by some other VM (either its own or
 whatever JDK is configured).  Make sure you've got the right source
 for the exception.  Since ArithmeticException is working for you I'm
 guessing this isn't at issue, but figured I'd mention it.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to debug unexpected exceptions (source not found)

2010-02-11 Thread Bob Kerns
All supposedly true.

I was catching all caught and uncaught RuntimeExceptions.
ArithmeticException is a subclass of RuntimeException, so it SHOULD
have stopped at the point of the throw.

It did not. It stopped later, when a RuntimeException was thrown with
the original ArithmeticException as its cause. I believe this is a
bug, and the correct behavior is as you describe.

Breaking on ArithmeticException explicitly, DID break. I'm guessing
this is an interaction between the VM and JDWP implementations, though
I didn't experiment to figure out the scope of the issue.

Thanks for the pointer to dalvic/docs/debugger.html. I'd observed the
behavior from merging return statements, and understood it; it's nice
to see it confirmed in writing!

I was trying to avoid getting too detailed in my explanation -- but
it's also good to have all that detail out there for the broader
audience.

I'm not sure if you were aiming your explanation at me, or augmenting
my explanation to the OP. If the former, perhaps I should mention that
my background in compilers, runtimes, and debuggers goes back to the
1970s. I maintained and implemented two Lisp systems at MIT, working
with Guy Steele (author of the Java spec), among others. I've done
stuff with on-the-fly byte-code generation in Java, JVMTI, and other
alphabet soup I can't recall.

So maybe it'll carry some weight when I say: nice job on explaining
and clariying the details I glossed over.

Overall, I've been quite impressed with the JDWP implementation. I
have been pleasantly surprised at how few deviations there have been
between debugging on  Dalvik and JVM.

Completely OT, but you might appreciate this: Thanks to the folks
behind and magicandroidapps.com, I have ITS -- the PDP-10 operating
system that MacLisp ran on at MIT in the 1970's -- running on my Nexus
One. I've recently acquired a snapshot of the necessary ITS
directories, and hope to get MacLisp up and running on my Nexus One --
faster than on the original systems!

On Feb 10, 7:36 pm, fadden fad...@android.com wrote:
 On Feb 9, 7:09 pm, Bob Kerns r...@acm.org wrote:

  You may not be seeing what you want because you stop too soon, before
  it's really created the exception.

 The debugger stops at the point of the throw.  There is no exception
 variable to examine because there's no exception variable in the
 source code for the debugger to refer to.

 The exception object is passed to the debugger when the exception
 happened event is sent up, so it's free to display it however it
 chooses to.  I expect different debuggers deal with this in different
 ways, but so long as they're using JDWP to talk to the VM they all get
 the same set of information.

 (FWIW, you can connect any debugger you like through DDMS.  It's
 probably easiest to make sure there's only one person talking to the
 VM at a time if you close Eclipse and use the stand-alone ddms
 command.  I've used jdb, IntelliJ IDEA, and a couple others.)

  I didn't paste it into this message, but I did look at what was in the
  exception, I just clicked on the little triangle to expand. It showed
  the message (Divide by zero), and also showed that the stacktrace
  field hadn't been filled in yet (which I expected).

 The stack trace elements are populated on demand.  Since most
 exceptions are never displayed, it's inefficient to go through the
 trouble of formatting a nice stack trace.  There's an array of int[]
 hiding in there that has the actual info.

  But, I do spot one anomaly here: I have it set to break on
  RuntimeException. ArithmeticException is a RuntimeException, but it
  didn't break. It didn't break until it tried to rethrow it, further up
  the stack.

 Make sure you're trapping both caught and uncaught exceptions.  An
 exception is considered caught if there's a finally block anywhere
 below it, and there are dx-generated finally blocks in all
 synchronized methods.  You end up breaking on a lot of stuff you don't
 care about, but sometimes it's the only way to really catch the
 exception.

 Some notes about the debugger can be found in the source tree in
 dalvik/docs/debugger.html
  http://android.git.kernel.org/?p=platform/dalvik.git;a=blob_plain;f=d...

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: android and proguard...

2010-02-11 Thread Bob Kerns
While Fadden addresses what you did to annoy the verifier, let's
consider what you can do to get past it.

I'd start with asking yourself WHY are you using Proguard? What are
you prioritizing -- size reduction, speed, or obscurity?

Proguard has a number of options to control just what it does to your
byte code in the classes.

I haven't tried it in this context, but I can offer the datapoint that
in the AdMob SDK sample, they supply optimize=false (equivalent to -
dontoptimize), which should turn off everything that might tickle
this. If you're up for experimenting, read the manual, and turn off
individual optimizations until you find the optimization that causes
the trouble. This would be useful info for Fadden together with
your .class files.

I'd say the code/ optimizations are the most likely to be the culprit.

If obfuscation is your primary goal, you may be good to go by just
turning off all optimizations.

On Feb 10, 6:35 pm, sdphil phil.pellouch...@gmail.com wrote:
 trying to integrate proguard into my android project.  seems to
 generate a binary, but when I go to run that binary on the device, I
 get --

 02-10 18:31:52.219: INFO/Test(10604): gui.StartScreen.clean shutdown:
 true
 02-10 18:31:52.229: INFO/Test(10604): gui.StartScreen.intent: false
 02-10 18:31:52.229: WARN/dalvikvm(10604): VFY: copyRes1 v0-v7 cat=3
 type=2
 02-10 18:31:52.229: WARN/dalvikvm(10604): VFY:  rejecting opcode 0x0c
 at 0x0045
 02-10 18:31:52.229: WARN/dalvikvm(10604): VFY:  rejected Lgl;.a
 (Landroid/content/Context;Ljava/lang/String;)Landroid/graphics/Bitmap;
 02-10 18:31:52.229: WARN/dalvikvm(10604): Verifier rejected class Lgl;
 02-10 18:31:52.229: DEBUG/AndroidRuntime(10604): Shutting down VM

 It starts up with a black screen and then just seems to hang - finally
 comes up with Force Close / Wait dialog (ANR).

 It almost seems like it can't get at the resources??

 I'm a bit at a loss about what to do...

 ideas?

 tia.

 p.s. please don't respond with the merits of using proguard or not...

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: android and proguard...

2010-02-11 Thread Bob Kerns
Obfuscation shouldn't cause verifying errors (which is what the OP was
reporting), it should cause ClassNotFoundExceptions and related stuff.

Yeah, it's a good idea to leave R completely untouched. That includes R
$string, R$drawable, R$id, etc. etc. There are things look at that
those via reflection, so the names matter, and there's no significant
bytecodes to optimize anyway.

But I would definitely NOT say you should avoid obfuscation -- though
you should consider that option. If you use it, you do have to
understand it. But you also have to understand the same issues for
shrinking. You have to enumerate all the seeds from which its
analysis needs to start. This includes every class name in
AndroidManifest.xml and the public methods that the framework calls on
those classes. But those methods should be protected already because
they're coming from base classes in android.jar, which you should be
telling Proguard to use as a library.

So it should be enough to just protect those class names from
obfuscation, plus any custom views you reference from layouts, and
similar issues.

I may take a crack at coming up with an XSLT script to generate the
Proguard script -- assuming I decide it's worth the trouble. What sort
of reductions in size are people seeing in practice in Android?

Obfuscation to protect against reverse engineering is clearly NOT
worth it to me at the price point of the typical Marketplace app!

If you do obfuscate, be sure to produce and preserve the mapping files
so you can interpret stack traces.

On Feb 11, 3:10 am, Daniel Drozdzewski daniel.drozdzew...@gmail.com
wrote:
 Hey there,

 I am beginning with Android, but have some proguard experience, so
 here is what I think:

 You can use optimisations and shrinking as much as you like, but avoid
 obfuscation.
 Just think, how many classes in your code are referenced using their
 names in AndroidManifest.xml. Proguard will happily rename those and
 overload agressively, but your manifest XML file remains untouched.
 All classes that are mentioned in the manifest file MUST remain
 unobfuscated.

 This is just a theory, but you could test it, by adding '-
 dontobfuscate' into your proguard settings and checking the effects.
 By default the obfuscation is ON.

 Please let the list know about your findings.

 Daniel

 Make sure that your Proguard config ALWAYS, NO MATTER WHAT doesn't
 touch R.class for any of its work.

 On 11 Feb, 02:35, sdphil phil.pellouch...@gmail.com wrote:



  trying to integrate proguard into my android project.  seems to
  generate a binary, but when I go to run that binary on the device, I
  get --

  02-10 18:31:52.219: INFO/Test(10604): gui.StartScreen.clean shutdown:
  true
  02-10 18:31:52.229: INFO/Test(10604): gui.StartScreen.intent: false
  02-10 18:31:52.229: WARN/dalvikvm(10604): VFY: copyRes1 v0-v7 cat=3
  type=2
  02-10 18:31:52.229: WARN/dalvikvm(10604): VFY:  rejecting opcode 0x0c
  at 0x0045
  02-10 18:31:52.229: WARN/dalvikvm(10604): VFY:  rejected Lgl;.a
  (Landroid/content/Context;Ljava/lang/String;)Landroid/graphics/Bitmap;
  02-10 18:31:52.229: WARN/dalvikvm(10604): Verifier rejected class Lgl;
  02-10 18:31:52.229: DEBUG/AndroidRuntime(10604): Shutting down VM

  It starts up with a black screen and then just seems to hang - finally
  comes up with Force Close / Wait dialog (ANR).

  It almost seems like it can't get at the resources??

  I'm a bit at a loss about what to do...

  ideas?

  tia.

  p.s. please don't respond with the merits of using proguard or not...

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: android and proguard...

2010-02-11 Thread Bob Kerns
Yeah, come to think of it, there's probably no need for my XSLT script
idea. Thanks.

On Feb 11, 8:51 am, Lance Nanek lna...@gmail.com wrote:
 Class names referenced in the manifest and other XML files are
 probably what most of those -keep public class * extends
 android.app.Activity like configuration lines are for in the various
 examples of using ProGuard with Android out 
 there:http://proguard.sourceforge.net/manual/examples.html#androidapplicationshttp://blog.javia.org/android-proguard-with-useful-stack-traces/

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: System.out.println(...) statements within the onCreate

2010-02-10 Thread Bob Kerns
Yes, but it's much less useful, because it always gets tagged with
system.out. It really should be discouraged, especially in production
code.

Imagine if you've got a dozen things running (I've got more), and they
all used System.out instead of Log?

On Feb 10, 7:39 am, intbt in...@tacberry.com wrote:
 You can use System.out - The output also appears on Logcat (not
 console) with a system.out tag.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Dialog problem

2010-02-09 Thread Bob Kerns
The four stages of Android UI Enlightenment:

0) You dutifully use getApplicationContext() his Activity to pass
along to the SDK.
1) You realize you don't NEED to call getApplicationContext() from
your Activity to pass along, 'this' should work.
2) You realize it is WRONG to call getApplicationContext() from your
Activity to pass along, because that's not the right context to pass
along -- your Activity is.
3) You wonder why the documentation and various failing examples keep
saying to use getApplicationContext()?
4) I am still stuck at stage 3. Can you enlighten me?

Really, can't someone take a half-hour and go through all the
occurrences of getApplicationContext() in documentation, Javadoc, and
examples, and fix them? Except for the Javadoc for
getApplicationContext(), nearly all occurrences should probably be
'this'.

On Feb 9, 1:32 pm, TreKing treking...@gmail.com wrote:
 On Tue, Feb 9, 2010 at 3:24 PM, André pha...@hotmail.com wrote:
   Context mContext = getApplicationContext();

 You're probably seeing something about a BadToken in the debug log, yes?
 DO NOT use getApplicationContext(). Use your current activity or the context
 from one of your views.

 I swear someone runs into this every single day ...

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to debug unexpected exceptions (source not found)

2010-02-09 Thread Bob Kerns
If you are in the debugger, either at a breakpoint or having stepped
over some code that justs threw an exception, I have yet to see a case
where, after stepping through using the Step Over button, you don't
eventually come to a frame that has the exception in it.

You can then use the Display window to do ex.printStackTrace(). The
stack trace will indicate where. You can actually click on the
displayed stacktrace in the console to take you to the source, if it's
available!

You can do the ex.printStackTrace() in the catch clause of your
debugging try/catch statement, too -- but the above technique avoids
the need to modify and re-run your code.

But it's better to catch it in the act. In the Breakpoints pane, click
on the Exceptions Breakpoint icon (it looks like an exclamation
point). Enter your selection -- or even Exception if you want to see
every single one. Of course, then you have to re-run your code. Except
sometimes you can re-execute a higher-level frame, and not restart.
Just be aware that the code may not do exactly the same thing in that
case, depending on what side-effects the code has already done.

I usually run with an Error breakpoint as well.

On Feb 8, 11:29 pm, RustedInSeattle guoxiaot...@gmail.com wrote:
 Hi all,
       I am pretty new to Android, the thing that bugs me the most
 about the IDE is that I am not able to get any information about an
 unexpected exception when it gets thrown, I can put a try catch block
 around identified code that generates it, but in many cases it takes
 time to find the line of code that generates the exception. is there
 any other way I can get the exception information?  in JDT when an
 unexpected exception is thrown the call stack displays the exception
 class name. but in ADT this doesn't work.
      Thanks in advance!

 -Xiaotian

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Google I/O Device microSDHC card

2010-02-09 Thread Bob Kerns
You don't need to worry about which kind of memory. It's really a
question of which kind of device. I wish manufacturers and resellers
were more consistent about terminology.

SDHC is an update to SD that allows higher capacity (HC). Anything
over 4 GB has to be SDHC -- unless it's over 32 GB, in which case it
hass to be SDXC.

Odds are your phone supports SDHC; it's been around for a while.
Devices and memory cards supporting SDXC should start appearing this
spring.

Each new reader is able to read the lower-capacity card types as well.

There's a chance you may see cards 32 GB that can be handled by your
phone. The 32 GB limit in the SDHC standard is arbitrary.

SDXC will take us up to 2TB.

What is the bandwidth of a freight train loaded with 2TB microSD
cards???

On Feb 8, 10:02 am, Monika Adamczyk moni...@gmail.com wrote:
 I have a Google I/O phone which came with the original 2 GB micro SD
 card. I would like to get a larger capacity card and while shopping
 for it I noticed that some of them are just micro SD and some are
 micro SDHC. The user manual I downloaded from the HTC website has not
 specification on the type of SD card that are supported.
 Can someone tell me if the phone I have works with both types or can I
 only use micro SD card?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to debug unexpected exceptions (source not found)

2010-02-09 Thread Bob Kerns
Frank, could this be the little snag I just encountered in replying to
RustingInSeattle? Where it doesn't catch RuntimeExceptions thrown from
the low level (or maybe any level), unless there's an exact match of
class?

Can you try your scenario again, this time once you identify the
exception class being thrown, set a breakpoint on that specific class,
and repeat?

I'm not sure exactly where the bug here would lie -- I don't think the
ADT plugin supplies anything, so I think it would be on the Android/
SDK side.

It's annoying, sure enough. Probably a bit less so if we know it's
there, but it would be a real pain for difficult-to-reproduce bugs.

Still, getting at the original stack trace, once it's finally printed
somewhere, should get you back to your code. If something silently
swallows that exception (retry code, perhaps), of course you're out of
luck.

On Feb 9, 6:38 pm, Frank Weiss fewe...@gmail.com wrote:
 @Bob I don't think you really nailed the problem. I ran into what I think is
 a similar issue. The stack trace showed the location of the throw deep in
 the Android API, without a hint of a stack frame from my code. I suppose the
 problem is because some of the Android code runs in different threads, so
 that the exception was probably due to some data structure from my code that
 the API later trips over in another thread.

 I tried downloading the Android source code and adding it the the Android
 project source code path. This solved the no source found error in the
 Eclipse debugger, but unfortunately, the source code line where the
 exception supposably was thrown didn't show any reasonably rational Android
 code. I suppose the reason might have been that I pulled down the wrong
 version of Android source.

 In the end, my problems were due to not using the API correctly. In one case
 it was trying to manipulate the UI from the AsyncTask.doInBackground method.
 In another case it was because it was calling populate several times on a
 Overlay object instead of just once after all the items had been added.

 I'd still like to see an answer to the OP because it might be quite
 educating to step through the Android source code. I usually figure out what
 went wrong by looking at the the code that actually threw the exception and
 seeing the data structure that caused it to barf.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: JSONObject order

2010-02-09 Thread Bob Kerns
Your code is incorrect if you're relying on ordering. I'll get to
that, but first some background which may come in handy:

HashMaps are unordered. If you want to preserve order, there's
LinkedHashMap, which retains the order, so when you iterate over the
map, you get the order in which they were inserted. And there's
TreeMap, which will enforce a sorting order for you, independent of
what order they're supplied in.

Unfortunately, that doesn't help you, since the JSONObject
implementation uses HashMap.
But you can iterate over the keys you get back with JSONObject.keys(),
and store the keys in a TreeSet, sorted according to your preferences,
or in an ArrayList, and call Collections.sort() on it, and then
iterate over the result. That's a simple, robust solution, if the
client knows what order the keys should be in.

But that doesn't give you the original order. The options I see there
are:

* A modified version of the JSON code. I don't recommend it,
especially not to deviate from the standard, but if you have no
control over what you're being sent, this may be your only
alternative. Just take the current code, and whenever it does 'new
HashTable()', do 'new LinkedHashTable()'.

* Modify your protocol to pass the desired key order explicitly (as
the value of another key on the object, or on some single larger
object, etc.). Call JSONObject.keys(), and iterate over that. This is
the most robust solution, but requires server-side cooperation, and
increases the payload size a bit.

I may be slightly misremembering, but if I recall correctly,
preservation of the key ordering was NOT part of the Javascript/
ECMAscript standards -- but was so widely implemented and relied on
that in the most recent round they made it part of the standard-to-be.
HOWEVER, JSON is *NOT* Javascript, it is a data interchange language.
From the JSON web site:

An object is an unordered set of name/value pairs

So this is not a JSON bug; it is behaving as expected, for
compatibility across a wide range of languages. So you'll either have
to change your protocol, or accommodate your deviation from the
standard.

On Feb 9, 7:49 pm, Kasra Rahjerdi johncena4presid...@gmail.com
wrote:
 Hello,
 I am currently turning a valid-JSON expression from a web page into a
 JSONObject using org.JSON. This object has a really weird order. Each
 time my expression changes the order of the strings in the JSONObject
 change too. Right now, the debugger tells me that the first two
 elements in the JSONObject's hashmap are null, and I am seeing the
 third item in my JSON expression as the first item in my view.

 All my items still show up in my ListView, they just all show up in
 weird ways.

 Is this a common issue? Is there any way to sort my JSONObject? (My
 keys are all numbers in descending order).

 Thank You,
 Kasra

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: JSONObject order

2010-02-09 Thread Bob Kerns
I forgot about your last sentence by the time I got finished
(descending order keys), so you'll be able to apply the simpler
approach:

On Feb 9, 10:26 pm, Bob Kerns r...@acm.org wrote:
 But you can iterate over the keys you get back with JSONObject.keys(),
 and store the keys in a TreeSet, sorted according to your preferences,
 or in an ArrayList, and call Collections.sort() on it, and then
 iterate over the result. That's a simple, robust solution, if the
 client knows what order the keys should be in.

 On Feb 9, 7:49 pm, Kasra Rahjerdi johncena4presid...@gmail.com
 wrote:

  Is this a common issue? Is there any way to sort my JSONObject? (My
  keys are all numbers in descending order).

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to run android application from super user(administrator) mode

2010-02-08 Thread Bob Kerns
The broken pipe exception means the process on the other end is
gone.

This won't give a SecurityException, because it's not Java that's
checking the permissions.

Connect to the phone via 'adb -d shell' and type 'su' followed by
Enter.

What happens? (You may need to add the tools directory from your SDK
to your path first, or type the entire path to adb.exe -- or
equivalent if you're using Linux or OSX. Use -e instead of -d if using
the emulator instead of a phone. See the docs if you have more than
one).

If it just works, then download Better Terminal Emulator (I think
there's a free version but the better one is better) and try it from
there. What happens?

Check your $PATH variable, and use that to locate where the su program
is located. Supply that in your exec() call.

But be aware that the path is likely to be different on phones rooted
via a different procedure! Using 'su' -- and doing anything requiring
root permission, or anything using anything added by a rooting
procedure, is not supported, so you'll have to do considerably more
legwork to iron out the compatibility issues.

Not to mention, you'll be limited to customers who have voided their
warranties and rooted their phones.

On Feb 8, 2:51 am, Asif k asifk1...@gmail.com wrote:
 I got somewhere on the net following code, I tried to execute but it
 throws broken pipe: IOException at

 os.writeBytes(single + \n); line

 Following is the code..

 Process process = Runtime.getRuntime().exec(su); DataOutputStream?
 os = new DataOutputStream?(process.getOutputStream());
 DataInputStream? osRes = new DataInputStream?
 (process.getInputStream()); for (String single : commands) {

 os.writeBytes(single + \n); os.flush(); res.add(osRes.readLine());

 } os.writeBytes(exit\n); os.flush(); process.waitFor();

 Any idea..
 Please help...
 Asif

 On Feb 4, 6:23 pm, Asif k asifk1...@gmail.com wrote:



  Is it possible to spawn a new process from the activity with su mode
  and then run the script??
  i had given the shell script as bellow but does not give fruitful
  output,

  stored in the device: /data/local/hello.sh
  #!/system/bin/sh
  (ifconfig wlan0 up)su
  exit

  and form Java code,

  Process process = Runtime.getRuntime.exec(/data/local/hello.sh);

  Can anyone please help me on this

  Thanks,
  Asif
  On Feb 4, 11:39 am, Asif k asifk1...@gmail.com wrote:

   Hi all,

      I am running a shell script stored in the device from android
   application by creating instance of Process class.
     But my script has commands which will be executed only in su mode.
   any idea how to accomplish this?

   Thanks,
   Asif- Hide quoted text -

  - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How do I modify the -encoding argument to javac in the Android Ant build system

2010-02-08 Thread Bob Kerns
The Ant manual is here:

http://ant.apache.org/manual/index.html

Unfortunately, I can't link directly to the javac task without losing
the navigation panes, but it's under Core Tasks / javac

You want the encoding= attribute on the javac task.

Why on earth someone would put encoding=ascii on a Javac task is
beyond me. UTF-8 is a direct superset, and what I encourage *EVERY*
Java developer to use, exclusively. Maybe Google is trying to
encourage English as a common language.

You can fix it in your individual build.xml, or you can fix it in the
template file in the SDK (for each platform version you download) in
templates/android_rules.xml.

In Eclipse, you'll want to go to Windows / Preferences / General /
Workspace and set the Text File Encoding to UTF-8. It defaults to
whatever your platform makes the default, which I claim isn't a good
idea for developers; we seldom develop exclusively for a single
platform these days, and our users are likely to have a different
setting anyway. The only sane approach is to use UTF-8 everywhere.

Think of it as a little ritual that every developer needs to go
through when setting up a new development environment or tool -- make
sure all the tools are using UTF-8.

On Feb 8, 4:27 am, paulbutcher paulrabutc...@googlemail.com wrote:
 Apologies if this is a stupid question - I'm an Android and Ant
 newbie.

 I have utf8 encoded source files that I need to compile with the
 Android Ant build system. By default, the encoding is set to ascii.
 I'd be very grateful for a pointer to whatever I need to do to let the
 build system know that my files are utf8.

 Incidentally, it works fine if I build in Eclipse, but I need to build
 from the command line.

 Thanks!

 paul.butcher-msgCount++

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Are processes kept alive when nothing is being done?

2010-02-08 Thread Bob Kerns
Actually, I believe you should go further, and say it has a POSITIVE
impact on the user.

It takes time to tear down and recreate a process that may be reusable
a short time later. And Android can possibly do the teardown at a less
busy moment.

The only downside I see is that we developers will have to learn to
explain this to users who think we're being sloppy.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Adjusting contents of ListView at runtime

2010-02-08 Thread Bob Kerns
Before you go and follow TreKings excellent suggestion (he beat me to
it), you might try in an else clause, setting the visibility to GONE.

I bet you're seeing recycling of the item views. Which underlying item
from the LispAdapter a particular View instance is using can change,
as they get reused by the ListView to display different items. So my
guess is, you're probably setting it when a (id % 5) == 0 item comes
up, and not resetting it when an (id % 5) != 0 item is used instead.
You may not be realizing this is happening if you're using
super.getView(...) to get the view to operate on and return.

Still, you should do it TreKing's way. In addition to his excellent
reasons, you're violating AdMob's guidelines -- which call for no more
than two in the event of a scrolling list, one at the top, one at the
bottom of the list.

The number of ads on a single page should not exceed one if the ad is
fixed to the screen top or screen bottom. If the page scrolls, there
should be a maximum of one ad on the top and one ad on the bottom, and
both ads should not appear on the same page.

http://helpcenter.admob.com/content/policies-tips-developers-publishers
(Admittedly, a bit hard to find -- look for the 'help' link next to
your login name on the upper right).

I'd say that's really a logical consequence of the following rule
(rule #1):
Ads should not be placed close to or underneath buttons or any other
object that users may accidentally click while interacting with your
app or site.

I've seen an app that deliberately violated this. Users noticed, and
weren't happy about it. I don't think violating it is a path to
maximizing your revenue. You don't want advertising to detract from
the value of your app to the user; they'll just stop using it instead.


On Feb 8, 12:38 pm, Kasra Rahjerdi johncena4presid...@gmail.com
wrote:
 I had not thought about doing it that way at all. That sounds like a
 much better approach than my current method.

 Thank You,
 Kasra

 On Feb 8, 11:00 am, TreKing treking...@gmail.com wrote:



  On Sun, Feb 7, 2010 at 11:52 PM, Kasra Rahjerdi 

  johncena4presid...@gmail.com wrote:
   The ListView's row
   layout is a LinearLayout that has two things in it, one AdMob layout
   and one TextView

  So EVERY row in your list has an ad but you only want to show every fifth
  one? I assume that is so there's only one ad show on the screen at a time?
  May I suggest you go about this a different way? Use the list view header or
  footer object as the ad or add a completely separate LinearLayout above or
  below the ListView that has the ad.

  Besides the issues you've described, what happens on a large-screen device
  that shows more than five rows at a time? User gets two or more ads at a
  time. What happens on small-screen device or when switching orientation such
  that the screen height is smaller than normal? You may not display any ads
  at all.

  Either way seems inconsistent. My $0.02.

  --- 
  --
  TreKing - Chicago transit tracking app for Android-powered 
  deviceshttp://sites.google.com/site/rezmobileapps/treking

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Sqlite Error

2010-02-08 Thread Bob Kerns
Good advice -- always be on the lookout for cleanup that can be done
in a finally, even if you don't see it as strictly necessary!

Actually, you can usually simplify this slightly:

Cursor c = ...;
try {
   dostuff(c);  // Do something with the cursor
} finally {
  c.close();
}

There's no timing window or anything here. The variable 'c' won't be
assigned unless there's a successful return of a cursor, and there's
no opportunity for a throw between that and the operations on the
cursor.

Separating the assignment and moving it into the try body does require
that you test for null in the finally clause. Occasionally it's worth
the extra hassle, so you can combine the finally with another try/
catch -- but usually it's better to simply use a separate try/catch
for each. In C++, assignments can generate exceptions, so doing the
assignment within the try is a good habit, and sometimes essential. In
Java, this is not a concern, so we can optimize for making it as easy
as possible to write and read the code, and thus encouraging liberal
use of the pattern!

BTW, try/catch are not expensive in the non-throw case. It generates
static code ranges that are looked up during handling throw, and
doesn't involve any extra execution steps if no throw is done. So
always just try for the cleanest code.

On Feb 8, 10:12 am, Jason Proctor jason.android.li...@gmail.com
wrote:
 well, like the error says, the cursor is being garbage collected but
 it hadn't been closed or deactivated.

 you must close your cursors!

 and do it in a finally block so that they still get closed even if
 other code throws an exception.

 for example --

 Cursor c = null;

 try
 {
    c = resolver.query (...);

    // ...run through the query}

 finally
 {
    if (c != null)
    {
      c.close ();
    }

 }

 not exactly like this, but you get the idea.

 hth
 J





 Hi,

 In my program i'm using sqlite database.

 After using that Sqlite program when i'm using some other layout it
 is showing the below exception.

 02-06 14:17:59.320: INFO/dalvikvm(853): Uncaught exception thrown by
 finalizer (will be discarded):
 02-06 14:17:59.371: INFO/dalvikvm(853):
 Ljava/lang/IllegalStateException;: Finalizing cursor
 android.database.sqlite.sqlitecur...@43c4e358 on DB1 that has not
 been deactivated or closed
 02-06 14:17:59.729: INFO/dalvikvm(853):     at
 android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
 02-06 14:17:59.800: INFO/dalvikvm(853):     at
 dalvik.system.NativeStart.run(Native Method)
 02-06 14:17:59.878: INFO/dalvikvm(853): Uncaught exception thrown by
 finalizer (will be discarded):
 02-06 14:17:59.900: INFO/dalvikvm(853):
 Ljava/lang/IllegalStateException;: Finalizing cursor
 android.database.sqlite.sqlitecur...@43b9cf30 on DB2 that has not
 been deactivated or closed
 02-06 14:17:59.909: INFO/dalvikvm(853):     at
 android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
 02-06 14:17:59.919: INFO/dalvikvm(853):     at
 dalvik.system.NativeStart.run(Native Method)
 02-06 14:17:59.968: INFO/dalvikvm(853): Uncaught exception thrown by
 finalizer (will be discarded):
 02-06 14:17:59.989: INFO/dalvikvm(853):
 Ljava/lang/IllegalStateException;: Finalizing cursor
 android.database.sqlite.sqlitecur...@43b9c5e8 on null that has not
 been deactivated or closed
 02-06 14:18:00.049: INFO/dalvikvm(853):     at
 android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
 02-06 14:18:00.049: INFO/dalvikvm(853):     at
 dalvik.system.NativeStart.run(Native Method)
 02-06 14:18:00.088: INFO/dalvikvm(853): Uncaught exception thrown by
 finalizer (will be discarded):
 02-06 14:18:00.109: INFO/dalvikvm(853):
 Ljava/lang/IllegalStateException;: Finalizing cursor
 android.database.sqlite.sqlitecur...@43b95fc8 on null that has not
 been deactivated or closed
 02-06 14:18:00.119: INFO/dalvikvm(853):     at
 android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
 02-06 14:18:00.140: INFO/dalvikvm(853):     at
 dalvik.system.NativeStart.run(Native Method)

 wat's this?..
 how to over come this?
 any one can explain me?..

 --
 Thanks  Regards
 Sasikumar.S

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=enhttp://groups.google.com/group/android-developers?hl=en

 --
 jason.vp.engineering.particle

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Do multiple overlays slow map response?

2010-02-08 Thread Bob Kerns
Sounds likely -- though actually profiling your performance would be a
good idea.

Why not collapse them into a single overlay?

On Feb 8, 8:17 am, ian stilbit...@gmail.com wrote:
 As I add successive overlays to track my progress over a map. the
 performance slows. Anybody know if this likely due to the burden of
 pushing all those overlays around?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: need help with porting gmail app android 1.6 code to android 2.0 and market on emulator

2010-02-08 Thread Bob Kerns
I haven't tried it, but you might be able to copy gmail from a rooted
2.x device. It came pre-installed on my Nexus One. I'm guessing that
the reason it's not normally present on the emulators is that reading
your mail on an emulator isn't generally something you'd want to be
testing, rather than any copyright/license restrictions, but I don't
actually know.

A ClassDefNotFound error generally does NOT mean that the class was
not found -- that gives an ClassNotFoundException. Generally, it means
that an exception happened while trying to load the class. Your
stacktrace above isn't helpful to you, because Java STILL doesn't
chain the original exception into the error, so the only way to track
them down was to catch the exception being thrown in the debugger.
Which is a bit painful, since you have to cast your net widely, and
exceptions are normally thrown in the process of classloading,
especially for ClassNotFound execption, which may be thrown many times
during the loading of a single class (once per classloader tried).

Chaining in the original exception would be a  1 line fix; I don't
know why they don't do it.

I think they don't want the Market app on emulators for some security
reason or other, but I really don't know. I suspect just copying that
one won't work. It's one reason I went and got a development phone
early in the process.

On Feb 8, 12:37 pm, social hub shubem...@gmail.com wrote:
 Hi ,

 I am trying to port 1.6 gmail app to android 2.0 on the emulator.

 I was able to install but when i execute the app i get no classdef found
 error
 1)
 E/AndroidRuntime(  494): Uncaught handler: thread main exiting due to
 uncaught exception
 E/AndroidRuntime(  494): java.lang.NoClassDefFoundError:
 com.google.android.providers.gmail.MailProvider$1
 E/AndroidRuntime(  494):     at
 com.google.android.providers.gmail.MailProvider.onCreate(MailProvider.java: 
 221)
 E/AndroidRuntime(  494):     at
 android.content.ContentProvider.attachInfo(ContentProvider.java:710)
 E/AndroidRuntime(  494):     at
 android.app.ActivityThread.installProvider(ActivityThread.java:4267)
 E/AndroidRuntime(  494):     at
 android.app.ActivityThread.installContentProviders(ActivityThread.java:4042 )
 E/AndroidRuntime(  494):     at
 android.app.ActivityThread.handleBindApplicat

 How to resolve the class def error i can fidn the relevant jar files unde
 /system/framwork is there an environment variabel that
 can be set in the emulator prob thats missing a link

 2)Is there a gmail app apk thats available for android 2.0 if so how do i
 find the apk file to install

 3) how do i get the market app to the emulator

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Sqlite Error

2010-02-08 Thread Bob Kerns
Which one to use is a matter of taste and convenience. Just make it as
easy on yourself to do it as possible, so you'll always do it!

That IOException in stream.close() is very important. Consider a
buffered stream. Until you do a close(), some of your output is still
in your buffer. If that output can't be written, you'll get an
IOException, so you're not fooled into thinking your output succeeded
and your data is safely in the file.

It's not just buffered streams, however, because buffering can happen
anywhere -- underlying libraries, operating system, network, driver,
etc. Until that close successfully completes, IO errors are are still
possible, and may indicate that your data was not successfully
written.

Generally, you want to handle IOException at a higher level than the
try/finally that does the close. Often, it should be in a different
method entirely -- one where you can do something about it -- retry,
report the problem to the user, etc.

In fact, if there's not a specific strategy at hand for dealing with
an exception, it should be handled at as high a level as possible.

Java's check/unchecked exceptions are a bit unfortunate, in that
regard. It's often better to wrap an exception in a RuntimeException
and rethrow, than to either try to handle it locally, or to change
your method signatures by adding a 'throws IOException' all over the
place.

Swallowing exceptions is probably NOT what you want your wrappers to
do. Not unless they're either very far out in your stack, or are also
implementing a specific recovery strategy. (Returning null or false is
generally not the best way to do that!)

I have, several times now, written a WrappedException class that
largely hides the fact that it's not the original exception, but is an
unchecked exception.  Let's say you've got some code that throws
either SQLException or IOException. It may also throw
FileNotFoundException (which is an IOException), and this is declared
in your method. Rather than duplicate the two catch clauses, you can
write:

try {
   .. code that is declared to throw SQLException and IOException ..
} catch (Exception ex) {
  throw new
WrappedException(ex).rethrow(FileNotFoundException.class).rethrow();
}

If it's a FileNotFoundException, the first rethrow will rethrow the
original exception (ex).
If it's a RuntimeException or Error the second rethrow throws the
original exception (ex).
If it's an InvocationTargetException or NoClassDefError or a few
others where you never want the immediate exception, the second
rethrow thows the cause exception (ex.getCause()).

Unfortunately, I've always done this for employers, so I don't have a
full implementation to hand out. I should recreate it soon, however.

This approach gives you a consistent way of dealing with checked
exceptions you're not prepared to deal with in the current context.
Swallowing them, or even logging them, hides bugs.

Generally, you shouldn't print or log them at the deeper levels,
either. That should generally be done at the outermost level, where
they're really handled, so they only get logged once.

On Feb 8, 5:48 pm, Jason Proctor jason.android.li...@gmail.com
wrote:
 indeed -- i did investigate moving to this pattern, but i found that
 putting the assignment inside the try() allowed me to change my mind
 about having a catch() clause too with no other code changes inside
 the method.

 i have wrappers for common items that are closable, such as streams,
 readers/writers, cursors, etc, which check for null and swallow any
 exceptions, so it's only one line inside the finally().

 quite why stream.close() throws IOException is kinda beyond me though :-)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: build.properties being ignored?

2010-02-08 Thread Bob Kerns
It doesn't work for me, either, but I've got to get my daughter to bed
so can't look at it in detail at the moment. (I *will* have to tackle
this shortly, however, to get my own product out the door!)

One thing to keep in mind: Once an ant property is set, it can NEVER,
EVER be changed.

(There are some add-on tasks available to modify that, but that's very
much outside the model and intent for ant. Not one I entirely agree
with, but important to understand).

Anyway, keep in mind that in ant, first definition wins.

Let us know if you find the solution/answer before I do.

On Feb 8, 4:50 pm, paulbutcher paulrabutc...@googlemail.com wrote:
 I'm building using Ant and trying to use build.properties to override
 some default values, and failing miserably. What am I missing?

 Here's what I've tried:

 1) Create a project with:

  android create project --target 1 --name MyAndroidApp --path 
  ./MyAndroidAppProject --activity MyAndroidAppActivity --package 
  com.example.myandroid

 2) Add the following line to the bottom of build.properties:

  out.dir=foo

 3) Build with ant debug

 The output stubbornly still ends up in the bin directory.

 The comment in build.properties says:

 # You can use this to override default values such as
 #  'source.dir' for the location of your java source folder and
 #  'out.dir' for the location of your output folder.

 Which seems pretty straightforwards. What am I missing?

 Thanks in advance!

 paul.butcher-msgCount++

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Variable values just get lost!??!?

2010-02-06 Thread Bob Kerns
In addition to the comment/correction by Streets of Boston...

It's unclear from your description just where you're storing your non-
static variables. The right way would appear to be in your
ServerConnection instance, since that's the static singleton. Your
activity will have a much shorter lifespan.

There's a fair bit more that's unclear to me from your description as
well. It may be that you need to create and bind a service
(android.app.Service). I'm not sure you're using ServerConnection,
and server connection in the sense of a connection to an
android.app.Service, or to a service on some other system accessed via
your socket connection.

I'm not sure why you had trouble passing data from your activity to
your service. If it was an android.app.Service, look at aidl.

Without an android.app.Service, your entire application could be going
away in between times, if it's not in the foreground. Be sure you
understand the application and activity lifecycle. Your choice of
whether to use an android.app.Service should be based on how the
application lifecycle matches up with when you need this connection to
exist and what you're doing with it.

If you need it to persist solely to avoid authentication, consider
getting a time-limited authentication token back instead, and
persisting that. This would allow your activity, service, connection,
and entire application to go away, and be restarted, and the user
would still avoid re-authenticating. You can refresh the token with a
new time-limited token on each reconnect or access, so timeout will
only happen if the user is idle for an extended period. This can give
a more robust user experience.

Still, I think there's a good chance the problem is that you wrote:

public static ServerConnection getInstance() {
  if(m_connection == null)
  return new ServerConnection();  // instead of m_connection =
  return m_connection;
}

I hope this helps, somehow. I know it's hard to do when you're lost,
but if you can better describe your circumstance, you can get more
useful answers. (Sometimes, doing so even leads you to your own
answer!)

On Feb 6, 4:08 am, Florian Lettner fl.lett...@gmail.com wrote:
 Hey guys,
 I seriously need help with a quite strange problem. I created a client
 which communicates with a server. Therefore, I have three classes. An
 activity providing a nice dialog to configure some data, a background
 service which checks the connection status periodically and a server
 class which handles the socket connection. Originally, the background
 service owned a server connection object but because I could not
 manage to provide data from the activity to the service, I decided to
 create the server connection class as singleton.

 The user is now able to change data in the activity (IP, Port,
 Username, Password) which shall be transmitted to the server object,
 if the save button is pressed. The data is read correctly, the
 activity calls the setter of the server class and the logcat also says
 that this data is correctly applied to the variable that stores the
 data in the server class. However, if I try to start the socket
 connection still the old values are stored in my variables although
 they've been overwritten before. What I am doing wrong, or how can I
 fix this?

 My singleton looks like this.

 static ServerConnection m_connection;

 public static ServerConnection getInstance() {
       if(m_connection == null)
           new ServerConnection();

       return m_connection;

 }

 All getters/setters and other variables are non-static.

 Best regards,
 Florian

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Network Unreachable (Socket.net Exception)

2010-02-06 Thread Bob Kerns
This error indicates that some router along the path (possibly your
local machine) has no route to the network you're trying to reach.

If you're running on a rooted phone, you can run traceroute host to
see the route to the host, if you have it; the busybox version works
well. This will show where the problem lies.

If the routing failure is on the local phone, 'route' will tell you
about the local routing tables, if you're using the BusyBox version of
'route'. You can also get it via 'cat /proc/net/route', but in a much
harder-to-understand format. Don't bother trying to figure out how to
use the built-in version; it's incomplete.

If it's not on the phone, it's not a phone problem. In any event, it's
definitely not an application problem, but a network failure (assuming
you're not trying to connect to some crazy address). It's something
you need to handle gracefully.

If the problem is not on the phone, and you're using wifi, you should
be able to observe the problem from any host on that network (at least
if it's getting the same default gateway, which would normally be the
case). So I'd try that first, rather than dealing with the limited
environment on the phone.

On Feb 6, 1:58 am, himanshu jain himanshu@gmail.com wrote:
 Hi ,
                I am trying to connect to server through
 HttpUrlConnection, but after sometimes it throws Socket.Net
 Exception :Network Unreachable. I tired alarm manager to wake up the
 phone and get the wifi lock but none seems to work .

 Tell me what to do what should i check and alternative ?.

 thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android Nexus One Update is causing problems!

2010-02-06 Thread Bob Kerns
Is the entire application disappearing, or is it just this activity?
onDestroy() doesn't necessarily get called in the former case.

On Feb 6, 1:31 am, sdphil phil.pellouch...@gmail.com wrote:
 I recently got the Nexus One Update which provides amongst other
 things - pinch gestures.

 One other unlucky surprise I got is that the app I am writing behaves
 differently.  When I call finish() my activity's onDestroy() should be
 getting called.  On 1.5, 1.6, 2.0 and 2.1 (before the nexus update)
 this works fine, but on 2.1 with the Nexus One it just doesn't call
 onDestroy.  I have a button on one of the activity pages that when you
 click it, it is supposed to finish the activity and I verified it's
 calling finish(), but onDestroy() never gets called.

 thoughts?

 tia.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Background on layout is scrunching contained content

2010-02-06 Thread Bob Kerns
The right thing to do is to adjust your 9patch with the 9patch tool to
indicate what the padding should be. Those are those pixels on the
right and bottom.

I haven't actually tried setting them to be wider than the stretchable
area, but I'd expect it to work.

But the other issue I've found is that it seems it doesn't actually
draw 9PatchDrawables in the background, but rather the foreground!
Thus, my translucent stretchable area was being drawn on top of my
window content. I made that transparent, but the actual background in
another layer behind the content as a graphic. It makes sort of a
twisted sense, but:

1) It's not documented
2) It's so counterintuitive I consider it a bug on those grounds
alone.

The twisted sense that it makes is that it enables using the
background with a 9patch to implement borders with clipping, by
drawing them on top of the content. And, in fact, moving the graphic
to the background DID result in content on top of border.

But Jeez, Louisedon't use background to draw in the foreground!

On Feb 6, 10:31 am, Mark Nuetzmann mark.nuetzm...@gmail.com wrote:
 After a quick search I saw some comments of what not to do... but in
 my case it WORKED PERFECT.  Rather than setting the layout background
 in the xml as I had originally done (and what I would have preferred
 to do). I took a little of the code from another post and set the
 background in code.  This worked awesome.

         Bitmap bkBitmap = BitmapFactory.decodeResource(getResources(),
 R.drawable.content_bg);
         NinePatchDrawable bkDrawable = new NinePatchDrawable(bkBitmap,
 bkBitmap.getNinePatchChunk(),  new Rect(0,0,0,0), null);
         bkDrawable.setAlpha(96);

 findViewById(R.id.content_container).setBackgroundDrawable(bkDrawable);

 When I do this the LinearLayout is getting a padding rect of (0,0,0,0)
 from its background and lays out its child views like normal; exactly
 what I wanted.  The background 9-patch now acts only as a background
 rather than a constraint on the contents of the LinearLayout.

 Regards,
 Mark

 On Feb 6, 12:15 pm, Mark Nuetzmann mark.nuetzm...@gmail.com wrote:



  I have a LinearLayout that I set a background to a 9-patch drawable.
  It appears that the LinearLayout is somehow forcing its contents to
  display within the center space defined by its background.  This is
  really creating problems as the content is being scrunched or
  compressed to a much smaller space that what I anticipated.  I do not
  have any margins or padding set on the LinearLayout so I know the only
  place it could be getting this is from the background.  All I wanted
  was for the background to be a background and not some how contribute
  to how the LinearLayout laid out its views.  Is there a way to tell
  the LinearLayout NOT to pull sizing information from its background?
  I see that the class NinePatchDrawable has a getPadding() but NO
  setPadding().  I assume that the LinearLayout is getting the padding
  from NinePatchDrawable and using that to contrain the contents of the
  layout to a smaller area.  Can I override this without subclassing
  this class?

  Regards,
  Mark

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: persisting application data that will remain after app removal

2010-02-06 Thread Bob Kerns
Along those lines, you can persist it, keyed by a unique ID based on
the handset, externally in an activation server.

But I agree with Frank about emphasizing the value and making the user
WANT to purchase, rather than focusing on a customer going to lengths
to steal it. They probably weren't going to buy it anyway, and your
time is generally better invested in making a great app for your
paying customers.

Meanwhile, if your thief likes your app that much, he's probably
showing it to some of this friends -- not all of whom will be thieves,
at least in parts of the world where you're likely to get much
revenue.

That's not true in every case, but it's seldom worth hassling legit
customers to discourage bad ones. If you have to do something, a quiet
activation server has minimal impact on legit users.

On Feb 6, 11:34 am, Frank Weiss fewe...@gmail.com wrote:
 You can really only discourage a determined person from using a time-limited
 application, unless you use more sophisticated DRM-like approaches. There
 are a couple of simple things you can do. Add a nag dialog that periodical
 reminds the user the trial expires in x days, or expired x days ago, along
 with a link to upgrade and purchase a license for the application. Limit the
 features to the extent the user can reasonably evaluate the application,
 while enhancing the value proposition of buying the full version. Require a
 trial activation key, emailed to the user, and required to activate the
 application after it is installed. This increases the effort of simply
 re-installing the application.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Background on layout is scrunching contained content

2010-02-06 Thread Bob Kerns
That is what I firmly believed -- until extensive testing convinced me
otherwise: that NinePatchDrawable's are, unlike everything else, drawn
in the foreground.

I recognize it's an extraordinary claim, requiring extraordinary
evidence.

However -- my testing indicated that, no matter HOW I supplied the
9patch -- XML, style, programmatically -- to setBackground(), it was
drawn in the foreground.

If I did the drawing *myself*, then everything behaved as expected.

The only reason I can see this hasn't provoked an uproar (besides
possible hallucinations on my part, which I haven't quite ruled out),
is that the advice is to leave the center center tile transparent.

It's on my todo list to report this -- together with the other bug
that bit me at the same time -- that if the first drawable resource is
a 9patch, it is loaded as a transparent DrawableColor (!!) No resource
ID conflict or other explanation that I can find. Putting an a.
9.png, or hand-constructing the NinePatch from a .png, were the
workarounds I could find; I went with the former.

You're going to need an isolated test case to believe me -- I
understand that. Unless you can shoot me full of holes before I spend
the time doing that, which will save me a lot of time... :)

But imagine the frustration trying to debug both issues at the same
time, believing there was only one problem!

On Feb 6, 1:10 pm, Romain Guy romain...@android.com wrote:
 Without seeing your code it's hard to know what's going on, but
 background drawables are never drawn in the foreground.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Background on layout is scrunching contained content

2010-02-06 Thread Bob Kerns
I can assure you that's what I believed, expected, and still want to
believe! And yet, supplying, at the same line of code, to the exact
same view, an BitmapDrawable vs a NinePatchDrawable, produced
dramatically different results.

You'll have to see a demo app to believe it. Hopefully, I'll just end
up with egg on my face for even mentioning it prematurely, but it was
hard to convince myself, too.

Thanks for letting me know the other problem was fixed. Do you know
offhand what versions it existed in, or should I go searching for the
bug report? (Though it seems people have been rather lax about
reporting just WHEN things were introduced and fixed. Since we seem to
still have platforms stuck at 1.5, that becomes rather important
information. Fortunately, my workaround is relatively innocuous).

It took an awful lot to convince myself THAT bug was real, too.

On Feb 6, 2:57 pm, Romain Guy romain...@android.com wrote:
 I can assure you that NinePatchDrawables are NOT drawn in the foreground.

  The only reason I can see this hasn't provoked an uproar (besides
  possible hallucinations on my part, which I haven't quite ruled out),
  is that the advice is to leave the center center tile transparent.

 There is absolutely NO such advice. I can't event think of a 9patch
 used in the Android platform that has a transparent center tile.

  It's on my todo list to report this -- together with the other bug
  that bit me at the same time -- that if the first drawable resource is
  a 9patch, it is loaded as a transparent DrawableColor (!!)

 This has been fixed.

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

 Note: please don't send private questions to me, as I don't have time
 to provide private support.  All such questions should be posted on
 public forums, where I and others can see and answer them

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Background on layout is scrunching contained content

2010-02-06 Thread Bob Kerns
gah, meant to reply to this part, too:

Please refer to the documentation:
http://developer.android.com/intl/de/reference/android/graphics/NinePatch.html

Normally, the middle is transparent so that the patch can provide a
selection about a rectangle. 

As you can see, I didn't make it up.

Anyway, let me get back to you. Looking at the system's 9patches is
something I should have thought to have done, and what I'm seeing
appears to be further evidence that I'm crazy. Except about that other
bug and the documentation advice (which you might want to fix, since
that doesn't seem to be the normal use case!)

On Feb 6, 2:57 pm, Romain Guy romain...@android.com wrote:
 There is absolutely NO such advice. I can't event think of a 9patch
 used in the Android platform that has a transparent center tile.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: android 3DOF controller - call for developers

2010-02-05 Thread Bob Kerns
Just a thought -- why only 3 degrees of freedom? You've got these nice
accelerometers...they can do more than sense a gravitational field...

I've bookmarked it to have a look at your code. I'll keep you in mind
if I have anything to contribute at some point.

On Feb 5, 7:07 pm, Jubei nkatza...@gmail.com wrote:
 Just wanted to let the community know that Ive released the source
 code and I'd be more than happy to accept code contribution to the
 project (even if the source isn't very readable).

 http://code.google.com/p/androidcontroller/

 If anybody is interested in helping out drop me a line.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: sticky client IP address?

2010-02-04 Thread Bob Kerns
 is
swapped out for a public one:. 208.54.14.97 at the moment.

The 10.* addresses in the routing table are interesting. They appear
to be DNS servers, with their own redundant routing table entries. I'm
not sure why that's done -- perhaps to minimize the risk of having
some additional connection, say a VPN, conflict? These DNS servers are
using private IP addresses -- they, too, are not reachable from the
outside. For DNS servers to operate, they need access to the internet.
So clearly, there is at least one level of NAT translation that is
happening further out than the cellular component. The traceroute
below makes it clear that for T-Mobile, the final public IP is not
assigned until we get to their edge at Level3.

(ATT is similar, but uses the 172.0.0.0/12 block of private
addresses.)


traceroute to google.com (74.125.53.106), 30 hops max, 38 byte packets
 1  10.176.80.136 (10.176.80.136)  2904.633 ms  79.284 ms  90.241 ms
 2  *  10.176.80.181 (10.176.80.181)  164.367 ms  10.176.80.133
(10.176.80.133)  211.121 ms
 3  10.176.80.129 (10.176.80.129)  247.650 ms  209.778 ms  240.052 ms
 4  10.176.6.165 (10.176.6.165)  229.767 ms  10.176.6.169
(10.176.6.169)  249.786 ms  211.975 ms
 5  10.176.6.177 (10.176.6.177)  247.773 ms  206.909 ms  10.176.6.181
(10.176.6.181)  250.091 ms
 6  10.176.96.209 (10.176.96.209)  212.005 ms  249.786 ms
10.176.96.193 (10.176.96.193)  199.982 ms
 7  10.176.96.220 (10.176.96.220)  199.677 ms  209.869 ms  252.411 ms
 8  10.176.0.25 (10.176.0.25)  200.226 ms  199.799 ms  199.859 ms
 9  ge-6-24.car2.Seattle1.Level3.net (4.79.106.37)  209.930 ms
278.015 ms  ae-1-51.edge1.Seattle3.Level3.net (4.68.105.12)  239.960
ms
10  GOOGLE-INC.edge1.Seattle3.Level3.net (4.59.232.34)  230.927 ms
209.656 ms  ae-2-52.edge1.Seattle3.Level3.net (4.68.105.44)  219.940
ms
11  209.85.249.34 (209.85.249.34)  217.712 ms  209.85.249.32
(209.85.249.32)  210.205 ms  GOOGLE-INC.edge1.Seattle3.Level3.net
(4.59.232.34)  219.666
ms
12  209.85.249.32 (209.85.249.32)  249.695 ms  209.85.249.34
(209.85.249.34)  219.818 ms  210.113 ms
13  209.85.250.144 (209.85.250.144)  259.704 ms  216.239.46.212
(216.239.46.212)  216.553 ms  209.85.250.126 (209.85.250.126)  236.145
ms
14  216.239.48.165 (216.239.48.165)  217.347 ms  209.85.250.146
(209.85.250.146)  231.872 ms  64.233.174.131 (64.233.174.131)  351.989
ms
15  *  *  72.14.232.6 (72.14.232.6)  641.358 ms
16  pw-in-f106.1e100.net (74.125.53.106)  179.932 ms  72.14.232.6
(72.14.232.6)  101.441 ms  pw-in-f106.1e100.net (74.125.53.106)
99.853 ms

From the TCP/IP standpoint, each of these is a hop, and it doesn't
matter whether there's any encapsulation, encoding, recoding, etc. End-
to-end, it behaves as a IP path, capable of transporting TCP.

On another (related) topic:
So why does my iPhone sometimes get two PDP connections, with two IP
addresses? Is this a part of normal handoff? Initial cell selection?
Does my Nexus do it, too, and I just haven't caught it in the act yet?

On Feb 4, 1:55 am, Mike michael.mo...@navteq.com wrote:
 Hi,

 My answer wasn't incorrect... you are simply misunderstanding what
 end-to-end means in this context.  This is getting a bit off topic,
 but it's interesting stuff.

 TCP/IP begins and ends at the edge of the cell network, on the network
 providers Internet gateway.  Between the gateway and the phone itself
 there is no TCP/IP.  This is the exact reason why you CANNOT build TCP/
 IP connections from a server to a phone.  You can ONLY build
 connections from a phone to a server.

 For further clarification 
 seehttp://en.wikipedia.org/wiki/Packet_Data_Protocol#PDP_Context

 When the gateway receives the outgoing request from the phone, the
 gateway assigns its own IP address and a port number to the request
 and puts it on to the Internet as a standard TCP/IP data packet.  This
 context may exist for some time on the gateway, or it may be flushed
 very quickly, there is no way to predict.  It's not even possible for
 the application on the phone to know what IP address is being used on
 its behalf.

 The packet coming back to the phone is stripped of its TCP/IP envelope
 at the gateway and then put on the cell network using whatever packet
 technology the cell network uses.  This is the very meaning of the
 word gateway... it is a gateway between two completely different
 networks that work in completely different ways, it is a protocol
 converter.

 - Mike
 NAVTEQ Network for Developershttp://NN4D.com

 Disclaimer: I work for NAVTEQ and these are my personal opinions which
 do not necessarily reflect NAVTEQ’s views

 On 4 Feb, 07:13, Bob Kerns r...@acm.org wrote:



  This isn't correct, or is misleading. It's kind of like saying
  ethernet doesn't use TCP/IP or WiFi doesn't use TCP/IP or dialup
  modems don't use TCP/IP or DSL doesn't use TCP/IP or Cable doesn't
  use TCP/IP.

  If you drop below the level of TCP/IP, to how the data is physically
  moved, then yes, you are below TCP/IP, and in that sense, cell
  networks don't use TCP/IP

[android-developers] Re: Help needed with parsing some XML data !

2010-02-04 Thread Bob Kerns
The problem is, I can't reproduce your problem.

I don't know why you don't know how to see a stack trace in Eclipse,
so I'm not quite sure how to tell you how. :=)

* You should be in the Debug perspective.
* Select the Breakpoints view in the Debug perspective.
* Click on the little exclamation point icon on the Breakpoints view
toolbar, and enter Exception, to add a breakpoint on all Exception's
being thrown.
* Debug the program, and do any interactions required to trigger the
problem.
* Stacktrace will appear in the stacktrace window.

If, however, I edit your code to do:
InputSource in = new InputSource(url.openStream());
in.setEncoding(utf-8);
xr.parse(in);

Exception in thread main
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException:
Invalid byte 2 of 2-byte UTF-8 sequence.
at
com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:
674)
at
com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:
362)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:
1742)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanLiteral(XMLEntityScanner.java:
1064)
at
com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanner.java:
813)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanAttribute(XMLDocumentFragmentScannerImpl.java:
1539)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:
1316)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2747)

at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:
648)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:
510)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:
807)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:
737)
at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:
107)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:
1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
$JAXPSAXParser.parse(SAXParserImpl.java:522)
at Foo.main(Foo.java:25)

Which isn't the same error at all.

I think the problem may start earlier in the file, and be detected
here. I concur with Frank about validating your XML separately.

But good luck with googling it. Other SAX parsers, notably including
Python, give the same error, plus lots of people have invalid input,
so you get a huge amount of noise. Looking at the SAX source to see
exactly how you get the error might help.

On Feb 4, 1:12 am, MobDev developm...@mobilaria.com wrote:
 hehe,
 my bad I said Netbeans but I actually use Eclipse :P
 Still used to J2ME with NetBeans thats why I mixed up...
 Anyways, I do get the error (exception) which I already posted in one
 of my first posts :
 At line 40, column 23: not well-formed (invalid token)

 They *MUST* be valid printing Unicode
 characters. No random control characters -- for example, ISO-8859-1
 byte values 0-31 (decimal). This will ALWAYS fail -- it is NOT well-
 formed XML. If that's the cause of your exceptions
 Well I did paste the error-generating xml entry which for example is :
 Country ID=2 CName=Åland eilanden/

 It would help
 if you posted the URL to the XML 
 Unfortunately I am not allowed to do so :( It's a URL which is
 actually in use by our already exisiting software...

 Also I noticed my previous post was posted three times ! My apologies
 for that, I actually can't remember pushing the Send button three
 times :P

 On 3 feb, 19:02, Bob Kerns r...@acm.org wrote:



  Yeah, that's not what I mean by a test case.

  Seehttp://junit.orgasa starting point.
  (The Android SDK includes some limited version of JUnit I don't
  recognize. It's adequate for this purpose, but the full, modern
  version is better. For non-device testing, you're not restricted to
  the supplied one.)

  Basically, a test case is code that you can run to *automatically*
  test some specific aspect of a system. In this case, checking against
  a known set of XML (so it doesn't change), looking for the known
  desired result, and reporting failures (expected conditions not
  matching) and errors (unexpected exceptions thrown).

  This removes the variables from the equation. You're not depending on
  how things display, either in the UI nor in the log stream and
  windows. You're not dependent on a human to notice a problem.

  An best of all, you can automate it to always run when you build, so
  if you break later, you'll find out

[android-developers] Re: DNS Query

2010-02-04 Thread Bob Kerns
Ah, this provides a lot more context -- but not all of it!

Normally, this sort of thing is handled through DHCP or similar. I
don't know if you have access to the server providing the information
-- are you the carrier?

To change the DNS resolution policies in any way, will require root
access, and have global impact. Do you own these devices? Or are you
developing an app for public consumption?

The one (nearly) sure-fire way to do this, is to query the DNS server
yourself, in the application. The (nearly) is because firewalls can
intervene.

I would urge you to avoid any sort of temporary change to the global
DNS resolution. It's one thing if you have control over the device and
pre-configure it for the users. But temporary changes to DNS
configuration has a way of going bad when events happen in other than
the expected order. And if you get two applications trying to impose
THEIR will on an entire platform, it's a formula for chaos.

I don't know how DNS resolution is configured on Android, but this may
be useful:

# getprop | grep dns
[net.change]: [net.dnschange]
[net.dnschange]: [878]
[dhcp.eth0.dns1]: []
[dhcp.eth0.dns2]: []
[dhcp.eth0.dns3]: []
[dhcp.eth0.dns4]: []
[net.dns1]: [10.177.0.34]
[net.rmnet0.dns1]: [10.177.0.34]
[net.rmnet0.dns2]: [10.165.17.242]
[net.dns1.161]: [10.177.0.34]
[net.dns2.161]: [10.165.17.242]
[net.dns2]: [10.165.17.242]
[net.dns1.79]: [10.177.0.34]
[net.dns2.79]: [10.165.17.242]
[net.dns1.31939]: []
[net.dns2.31939]: []
#

If you're connected via wifi, the dhcp.eth0.dns* entries are filled
in instead; the above is with Wifi disabled.

Still -- and I don't know the 3GPP protocols here, but if they're not
deviating too much from how things were designed, any old DNS server
should be able to supply you with the information. The DNS server you
contact will, based on the domain requested, contact the appropriate
DNS server and obtain the information, cache it, and relay it to the
requester.

Perhaps this is not suitable for this for some reason, but if so,
realize the reason it's hard is because 3GPP is doing it wrong --
that is, using tools in ways they weren't intended. Maybe it's all
worthwhile; I don't know, I'm just trying to give you helpful context
and info, not technical judgments.

Fun historical fact: In 39 days (March 15), it will be the 25th
anniversary of the very first DNS registration, Symbolics.com. (The
domain name was recently purchased). I worked at Symbolics from
1981-1987, so it's an occasion I remember well.

On Feb 3, 11:07 pm, Android Development indodr...@gmail.com wrote:
 Bob, making a DNS query by the application is a standardized procedure of
 3GPP (3rd generation partnership project). All Mobile devices need to query
 a DNS server installed in the VoIP network to find the address of the server
 which will process their requests. This DNS server is under the control of
 the VoIP service provider and provides the IP address of the VoIP server.

 Devices are pre-configured with the domain name of their home network (
 atlanta.com for example). They need to find the IP address of the server on
 that domain by firing a DNS query. The DNS server's IP address is also
 a configurable parameter in all soft clients.

 My question was regarding this use case.

 This procedure is standardized as the DNS/DHCP procedure of discovering the
 outbound proxy server by the mobile client.

 With this background, if I need to query a DNS server installed on a given
 IP address on the network, is it technically feasible ? Or will the
 operating system automatically resolve the next hop based on the resolv.conf
 file (if it is configured there) if i try and send a request to atlanta.com?



 On Wed, Feb 3, 2010 at 10:55 PM, Bob Kerns r...@acm.org wrote:
  I didn't mean that to be harsh, BTW. Knowing that an approach is out
  in left field, and why, is useful information. Some of the most useful
  information you can get, as a beginner, since it narrows the focus of
  what you have to learn, a lot!

  On Feb 3, 9:21 am, Bob Kerns r...@acm.org wrote:
   Then you are doing something VERY strange.

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android 2.0.1 SocketTimeoutException received with FTP Data channel

2010-02-04 Thread Bob Kerns
Ah, given that both sides are loopback, TCP/IP doesn't really even
enter into it in a meaningful way. I think the problem pretty much has
to be with your client.

I began suspecting that once you mentioned that closed connections
stayed open until you killed the process. A RST on one should trigger
a close on the other side.

I've had good luck with openSSH, and though I've not used it heavily,
I've heard good things from others, so I think it's a solid choice.
But google around, there are others.

Another possibility is to use OpenVPN. This will let your clients talk
directly to the target server or servers, rather than to a local
forwarded port. This is a lot more flexible, if that's a good thing.
If you want to lock down and limit access, you're better off with port
following.

On Feb 3, 10:55 pm, mericksonj mericks...@gmail.com wrote:
 The lack of an application-level timeout does explain why software
 will generally hang.

 The error message that I've seen the most is as follows:
 java.net.SocketTimeoutException: The operation timed out

 Now,  in my tests with a PC, the sockets are generated and torn down
 dynamically with the client always connecting with its random port to
 the same passive port on the server.

 The android device will not tear the connection down however after the
 exception.  The session will stay up indefinitely as established on
 both ends until I kill the port forwarding process.

 There does also appear to be situations where I can get a directory
 list received from the server to show up on the client device
 (subsequent cwd commands work, but list will fail), but it seems to be
 intermittent and very erratic.  Which leads me to take more notice of
 the buffer messages rather than a specific point in the code that
 breaks down.

 As for NAT or Firewall issues, all client communications are looped..
 meaning that with the TCP tunneling in place, all FTP packets are sent
 to 127.0.0.1 where it is picked up by SSH for crypto and encaps into
 another IP packet.  Once at the SSH server, the outer packet is
 stripped, contents are decrypted and sent to the FTP server.  The FTP
 server (same box as the SSH server) thinks it came from 127.0.0.1 and
 uses that same IP for its replies.  I guess that's just the long way
 of saying that each device thinks it's talking to itself, so there's
 no NAT or firewall confusion.  At least not until I move the FTP
 service off my SSH server, but even then IP masquerading in the
 proftpd_conf will fix the NAT issue.

 I really think a TCP dump would help the issue.. at least I could see
 how big the FTP packets are, if they're being fragmented, and when/
 where they're being sent.  I just found the tcpdump on the emulator,
 how can I filter out the non-interesting packets?

 I would like to try similar port forwarding tests using adb or other
 tools, is there a recommended tutorial on how to use the port
 forwarding there?  will it be able to simulate what I'm doing with
 SSH?

 Also maybe trying a different SSH client would help, is there anyone
 besides connectbot that accepts RSA keys and allows TCP port
 forwarding?

 --
 Regarding the security discussion, I think in my setup I'm pretty safe
 since all FTP packets are looped within client/server platforms as
 described above, but you do make a case for FTPS w/out encryption that
 could maybe alteast mask the username and password within the system
 or in case I ever do move the FTP server off the SSH box, then again,
 it is at least on a trusted network once the SSH server decrypts it.

 Again, Thanks!
 --James

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android 2.0.1 SocketTimeoutException received with FTP Data channel

2010-02-04 Thread Bob Kerns
Are there any SSH clients that DON'T support RSA keys and port
forwarding?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: alphabetic scrollview navigator

2010-02-03 Thread Bob Kerns
I didn't see a redirect bug -- but gmail failed to include the final
')' in the link, so the anchor survived, but failed.

So what is it with these redirects, anyway? It's always sending me to
some random locale -- fr one day, de today. Fortunately -- they're all
in English.

I'm using Chrome, on Windows 7.

On Feb 2, 5:44 pm, Jason Proctor jason.android.li...@gmail.com
wrote:
 thanks!

 btw is the documentation redirect bug there for everyone? i reported
 it, no response yet. that URL takes me back to the top of
 AbsListView.html, as the anchor fails to survive the redirect to --

 http://developer.android.com/intl/zh-CN/reference/android/widget/AbsL...

 (with the intl/zh-CN)

 kinda irritating...





 http://developer.android.com/reference/android/widget/AbsListView.htm...)

 On Tue, Feb 2, 2010 at 5:37 PM, Jason Proctor
 jason.android.li...@gmail.com wrote:
   is the scrollview with the alphabetic list on the right and annotated
   scrolling a standard component? or is there any support for implementing 
  it?
   sorry i've not had chance to take a look in the 2.0 API...

   thanks
   --
   jason.vp.engineering.particle

   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.com
   For more options, visit this group at
   http://groups.google.com/group/android-developers?hl=en

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

 Note: please don't send private questions to me, as I don't have time
 to provide private support.  All such questions should be posted on
 public forums, where I and others can see and answer them

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 jason.vp.engineering.particle

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Suspicious TCP RST packets while device is sleeping.

2010-02-03 Thread Bob Kerns
Well, I don't grok NAT enough to conclude that it's wrong. But I don't
see why they'd do it -- unless they're trying to minimize traffic.
Seems kinda trivial -- and likely more than offset by the later
attempted transmit.

I'm not sure what problem you're trying to solve. It can certainly
happen that one side thinks a connection is open while the other
thinks it's closed. The recipient sends a RST, the sender gets a
connection reset and life goes on.

Is it the delay in discovering the disconnect that's the issue?

On Feb 2, 7:43 pm, Dan Sherman impact...@gmail.com wrote:
 Hey Bob,

 Thanks a lot for the response :)

 After a few more hours tonight working on the problem, I've got a bit more
 information to present.

 From everything I'm seeing, it looks like the issue has to do with NAT'ing
 at the network level (tmobile I'd imagine).  The connection is definitely
 NAT'd, the client sees itself as one outgoing IP (14.130.xxx.xxx) and port,
 and the server sees an incoming connection from a different IP/port
 (208.54.xxx.xxx).

 My best guess is that tmobile is killing the connections at the NAT level
 after not seeing traffic running on it for a certain period of time (5
 minutes in this case).  This wouldn't be a problem, as you said, a reconnect
 works just fine.  And in fact, the higher-level long-lived session control
 is already in place, and the client reconnects/etc properly when sensing a
 disconnect.

 The problem comes in based on _how_ the NAT is killing the connection.
  Keeping a wake-lock on device to prevent sleeping, and watching TCPdump on
 both sides shows the server receiving a RST packet, but no RST packet is
 sent to the client.  The client sits there, assuming the connection is still
 active, indefinitely.  The second it tries to do something (user-prompted,
 or via a ping timer), it sends a PSH packet to the server, and the server
 responds with a RST (it closed the connection when it got the RST from the
 NAT).

 Obviously if the NAT were to send RSTs both directions, this wouldn't be a
 problem, the client would notice the disconnect, and reconnect.  But from
 everything I can tell, it notifies the server, and leaves the client
 completely unaware that the connection has been dropped...

 I understand that the NAT needs to clear out old/stale connections, but
 sending a RST uni-directionally seems a bit incorrect to me...

 Any ideas?

 - Dan



 On Tue, Feb 2, 2010 at 10:25 PM, Bob Kerns r...@acm.org wrote:
  This is expected behavior. TCP connections time out if the connection
  is lost, or either side dies. That way, you don't have systems
  drowning in dead connections.

  The RST packet is telling you that the server has forgotten about the
  connection. The client may even report it directly, if it realizes
  that it hasn't heard from the server, so you may get a connection
  reset error even without seeing an actual RST from the server.

  The default timeout is usually 5 minutes, which squares with your
  observations. In general, you should not try to solve your problem by
  increasing the timeout, but rather by reestablishing the connection,
  and maintaining long-lived sessions at a higher level.

  I'd recommend, if possible, dropping your AlarmManager ping task, in
  favor of reopening your connection. You'll consume less resources --
  including battery. If you want to minimize the cost of reopening
  connections, you can send a ping whenever you happen to wake up,
  reopening if necessary. But that doesn't scale that well -- you'll be
  able to have more simultaneous clients if you strike a suitable
  balance between keeping connections alive, and the cost of reopening
  them. For rare interactions, you can support more clients if you open
  connections on actual need, and close them promptly when not needed.

  It all depends on exactly what you're trying to optimize, and the
  environment in which you're operating. The only constant is -- you
  can't DEPEND on keeping connections alive. View it as an optimization,
  rather than how your application works.

  And then make sure it is actually an optimization! So often,
  optimizations are a waste of a developer's time.

  I'd also recommend avoiding thinking about TCP at the level of packets
  (or segments), RST, etc., if at all possible. Unless you're trying to
  diagnose a flaky router, or issues with radio connectivity, or things
  at a similar level, it's better to focus at a higher level, at least
  at the socket level -- is it opening, established, closed, reset?

  On Feb 2, 1:05 am, Dan Sherman impact...@gmail.com wrote:
   Hey guys, trying to track down a rather elusive problem here...

   I've been playing around with long-standing TCP connections to a server.

   The client opens a TCP connection to the server, sets a timeout at a
   reasonably long period (30 minutes), and adds an AlarmManager task to
  ping
   the server every 15 (a ping is just a junk packet the server responds

[android-developers] Re: Splitting connections?

2010-02-03 Thread Bob Kerns
Well, you' have to modify your routing tables. I see there's /system/
bin/route, and it worked to add a default gateway, running as root.
You WILL have to be root; if you haven't rooted your phone, you will
need to.

/system/bin/route seems to lack many of the normal features -- the
BusyBox one seems more complete.

Depending on your environment, your network administrators may not be
happy with you if you do this. In some scenarios, they might even be
justified -- but then you shouldn't have access with your phone in the
first place.

I'd be happy to hear there's a saner way to do this, but I don't think
there is. Usually, you'd just turn off WiFi, but that won't work if
you need both from the same app at the same time!

On Feb 2, 9:42 am, Eric Crump synesthe...@gmail.com wrote:
 I have an app that runs on a closed network with no internet access.
 I connect to it through wifi.  My app also uses Google Maps.  Is there
 a way to make the MapView still pull from my 3G connection while the
 rest of the app uses the wifi?  The issue is once connected to the
 wifi, maps tries to pull from the internet and can't get there so my
 MapView is always blank.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Help needed with parsing some XML data !

2010-02-03 Thread Bob Kerns
Well, you found one way to get the encoding in there. A few more:

InputSource.setEncoding(iso-8859-1)
new InputStreamReader(stream, iso-8859-1);

I'd argue that it should have gotten it from the ?xml...
encoding=iso-8859-1? -- I'm a bit surprised it didn't. But it's
something I'd never rely on if I know the encoding.

Anyway, re: your problem below. It's probably working right, up to the
point of the log statement.

The log stream is probably taking those bytes, and then later they're
being interpreted as UTF-8. or it's taking the characters from the
string, and interpreting them as UTF-8 (via String.getBytes()) and
passing them off to a log stream that doesn't know about UTF-8.

Try logging to a file. Or better yet, create test cases, and verify
the correct operation of your code via test suite, rather than via log
statements.

But if you have any control or influence over the server -- fix the
problem there. ISO-8859-* should be of purely historical interest in
interpreting old documents. The first draft of ISO-10646 came out
nearly 20 years ago, and UTF-8 has been around for nearly 18 years.
The world is international. It's time to put a stake in the heart of
these national encodings.

On Feb 3, 2:55 am, MobDev developm...@mobilaria.com wrote:
 Btw I also have tried this instead :

  try {
                 URL url = new URL(http://www.myserver.com/xmlstream;);
                 URLConnection conn = url.openConnection();
             InputStream is = conn.getInputStream();
             Xml.parse(is, Xml.Encoding.ISO_8859_1, new ExampleHandler
 ());
         } catch (Exception e)
         {
             throw new RuntimeException(e);
         }

 This time it wont just crash but for example if I print the output
 (through Log) I get

 Found attribute : Ã…land eilanden
 and
 Found attribute : Albanië instead of Albanié

 So any input on this ?

 On 3 feb, 10:44, MobDev developm...@mobilaria.com wrote:



  Actually this is the code for the second approach :

  /* Create a URL we want to load some xml-data from. */
  URL url = new URL(http://www.myserver.com/xmlstream;);

  /* Get a SAXParser from the SAXPArserFactory. */
  SAXParserFactory spf = SAXParserFactory.newInstance();
  SAXParser sp = spf.newSAXParser();

   /* Get the XMLReader of the SAXParser we created. */
  XMLReader xr = sp.getXMLReader();
   /* Create a new ContentHandler and apply it to the XML-Reader*/
  ExampleHandler myExampleHandler = new ExampleHandler();
  xr.setContentHandler(myExampleHandler);

  /* Parse the xml-data from our URL. */
  xr.parse(new InputSource(url.openStream()));
  /* Parsing has finished. */

  And the error I get is :
  At line 40, column 23: not well-formed (invalid token)

  which is around this XML line :
  Country ID=2 CName=Åland eilanden/

  So where should I specifiy its an ISO-8859-1 ?
  Also I have been debugging the app, but I actually cannot see the
  stacktrace, could you please direct me on how to show it on NetBeans ?
  Every time I try to look at the exception thrown I will see several
  variables but StackTrace will be null...

  On 3 feb, 06:17, Bob Kerns r...@acm.org wrote:

   While I would expect your second approach to work, it's important to
   note that IT IS NOT REQUIRED TO WORK.

   The XML standard does not require XML processors to support anything
   other than UTF-8 or UTF-16.

   In this day and age, I would STRONGLY discourage use of anything other
   than UTF-8, or, rarely, UTF-16.

   Another factor to consider is how you're getting access to those
   characters. You must do this one of two ways:

   1) Using a Reader set to read 8859-1
   -or-
   2) Using an input stream, giving the raw bytes to the parser, letting
   it decode the 8859-1 characters.

   You WILL FAIL (and this is probably your problem, would be my guess)
   if you try to read using a Reader that's expecting UTF-8.

   A stacktrace should show which problem you have.

   On Feb 2, 6:42 am, MobDev developm...@mobilaria.com wrote:

Hi,
I am downloading a xml-type file from a webserver which starts out
with :

?xml version=1.0 encoding=iso-8859-1 ?

afterwards I get a list with loads of countries, some countries do
contain some letters like é and á.

I have tried to extract the data of the xml in two ways :
1 - simply download the whole thing into a String, which will result
in those characters being seen as something like [] or on the Android
emulator (and device) I will see a triangle with a ? in it...

2 - fetch the list with the SAXParser and XMLReader which will just
throw an exception telling me that there is some content error...
specifically at the line where the first country is with such a
character...

So is there some way to get this to work ? Can I read the iso-8859-1
encoded xml into the Parser ? Or is there some way to encode/decode
the received data into something actually usable ?
Any idea where the problem might

[android-developers] Re: DNS Query

2010-02-03 Thread Bob Kerns
Then you are doing something VERY strange.

DNS is a service provided to hosts (systems, i.e. your phone) by the
network. It is not something that is under the control of the
application. Generally, a DHCP server (or the wireless carrier) will
supply you with your IP address, default router, DNS servers, and
other network configuration when you connect. It's a property of your
NETWORK environment.

Of course, applications are free to use IP addresses, and to obtain
them however they choose -- including implementing a DNS client
themselves. This, of course, raises the question -- how do you locate
your special DNS server -- and why is it special? Is it even
reachable in a particular environment? To prevent DNS spoofing
attacks, some network administrators may block external DNS requests,
and force you to go through their DNS servers.

Generally speaking, ANY DNS server should be able to resolve ANY
public DNS entry. And ONLY your local one that your network would tell
you about, would be able to tell you about special, local, DNS
entries.

About the only use I can see for such a scheme would be to contact a
botnet controller. Or, more likely, to work around a mis-configured
local network -- perhaps due to a poorly set-up VPN.

But in any event, an application should NOT try to hijack the entire
system's DNS resolution by hacking *hosts/**resolv**.**conf. This is
not playing nice with others. There's a reason -- many reasons --
these files require root access.

On Feb 3, 7:28 am, Android Development indodr...@gmail.com wrote:
 What if the application requires to send a query to a DNS server installed
 at a particular IP address.

 how do i configure my DNS server in *hosts/**resolv**.**conf  from the
 application ?*
 ***
 *



 On Wed, Feb 3, 2010 at 8:40 PM, Lewske Wada r...@run.sh wrote:
  Hi Radhika,

  radhika wrote:
   Hi All,

   Am a  beginner in this area. I am trying to find out how a DNS query
   is sent from the android device.

   Am unable to locate the code.

   Can someone help me by showing me the code where a DNS query is sent.

   For example, may be from some application like browser?

  I believe you simply have to use InetAddress.getByName(String Host) ?
  Like I did use InetAddress's getLocalHost() in resetConnection()
  funcion in my local app? :

 http://run.sh/repos/Runftp/src/sh/run/Runftp/FtpConsoleText.java

  Anyway the Socket() automatically resolves the hostname when given.

  Ryu

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: DNS Query

2010-02-03 Thread Bob Kerns
I didn't mean that to be harsh, BTW. Knowing that an approach is out
in left field, and why, is useful information. Some of the most useful
information you can get, as a beginner, since it narrows the focus of
what you have to learn, a lot!

On Feb 3, 9:21 am, Bob Kerns r...@acm.org wrote:
 Then you are doing something VERY strange.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Educational Resources

2010-02-03 Thread Bob Kerns
We have a lot of questions here of a fairly basic, non-Android-
specific nature.

I think it would be helpful to compile a list of resources on various
topics, that we could refer people to (and try to get them to look at
before asking here  -- yeah, I know...)

Areas I see:

* TCP/IP and networking
* Cellular communications (I could use some of these, I bet)
* XML processing (XML itself, and the API's: DOM, SAX, XMLPull)
* Java

Done right, referring people to such a listing would be far more
useful to them than answering their immediate question. (I'm not
saying, don't answer -- but teach them to fish out their own answers!)

Of course, http://google.com would be right at the top of the list.
But a lot of time beginners don't realize how much information is
available to them -- or they're overwhelmed by the amount of
information available at the wrong level for them, and no way to judge
quality.

Except for cellular comm (where I have the opposite problem), I've
been around this stuff too long to have any reasonable resource
suggestions. I'd send you to the standards documents... :)

Can people help out with suggestions? Can Google people give them some
visibility on the list?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Help needed with parsing some XML data !

2010-02-03 Thread Bob Kerns
Yeah, that's not what I mean by a test case.

See http://junit.org as a starting point.
(The Android SDK includes some limited version of JUnit I don't
recognize. It's adequate for this purpose, but the full, modern
version is better. For non-device testing, you're not restricted to
the supplied one.)

Basically, a test case is code that you can run to *automatically*
test some specific aspect of a system. In this case, checking against
a known set of XML (so it doesn't change), looking for the known
desired result, and reporting failures (expected conditions not
matching) and errors (unexpected exceptions thrown).

This removes the variables from the equation. You're not depending on
how things display, either in the UI nor in the log stream and
windows. You're not dependent on a human to notice a problem.

An best of all, you can automate it to always run when you build, so
if you break later, you'll find out right away, while you know what
you changed. And you can make changes freely, with the security of
knowing that you won't have to go through some long test/debug cycle.

I didn't answer your question about getting a stacktrace earlier,
because you said NetBeans. I'm old enough to remember when NetBeans
was the hot new thing -- but too old to remember how to do anything
with it. Try using Eclipse and the ADK. It will show you the stack
trace in the same way it shows any other stack trace, as if you were
debugging locally. (I would expect NetBeans to, as well).

Or you can catch the exception, and use exception.printStackTrace() to
get it into the log (I'm surprised it's not already there).

This isn't really an Android problem, and it's not necessary to debug
it there. If you write your failing test cases, you can debug them on
your desktop computer, get them working, and you should be set to go
on the device.

Another thing to realize is that not all character values you can come
up with, are legal XML content. They *MUST* be valid printing Unicode
characters. No random control characters -- for example, ISO-8859-1
byte values 0-31 (decimal). This will ALWAYS fail -- it is NOT well-
formed XML. If that's the cause of your exceptions, your two choices
would be to fix it on the server (probably by encoding this binary
data) or to preprocess the fake-XML into real XML before you feed it
to the XML parser.

\
On Feb 3, 6:49 am, MobDev developm...@mobilaria.com wrote:
 well to begin with : thx for the expalanation :D
 I was wondering about your statement :
 Try logging to a file. Or better yet, create test cases, and verify
 the correct operation of your code via test suite, rather than via log
 statements. 
 I already tried in a test case, which was to write the incoming data
 to a AlertDialog, but the result was that those characters are shwon
 on-screen with a rectangle with a ? in it... My idea (and test case)
 would be to stream a list of countries, and afterwards show this
 list onscreen so the user can select one...
 Our problem is that the whole system I am using is based on the ISO
 norm and cannot be changed to UTF-8 in a short period of time...
 Or am I misinterpreting your test cases and test suite ? And if so
 how should it have been interpreted ?

 On 3 feb, 13:26, Bob Kerns r...@acm.org wrote:



  Well, you found one way to get the encoding in there. A few more:

  InputSource.setEncoding(iso-8859-1)
  new InputStreamReader(stream, iso-8859-1);

  I'd argue that it should have gotten it from the ?xml...
  encoding=iso-8859-1? -- I'm a bit surprised it didn't. But it's
  something I'd never rely on if I know the encoding.

  Anyway, re: your problem below. It's probably working right, up to the
  point of the log statement.

  The log stream is probably taking those bytes, and then later they're
  being interpreted as UTF-8. or it's taking the characters from the
  string, and interpreting them as UTF-8 (via String.getBytes()) and
  passing them off to a log stream that doesn't know about UTF-8.

  Try logging to a file. Or better yet, create test cases, and verify
  the correct operation of your code via test suite, rather than via log
  statements.

  But if you have any control or influence over the server -- fix the
  problem there. ISO-8859-* should be of purely historical interest in
  interpreting old documents. The first draft of ISO-10646 came out
  nearly 20 years ago, and UTF-8 has been around for nearly 18 years.
  The world is international. It's time to put a stake in the heart of
  these national encodings.

  On Feb 3, 2:55 am, MobDev developm...@mobilaria.com wrote:

   Btw I also have tried this instead :

    try {
                   URL url = new URL(http://www.myserver.com/xmlstream;);
                   URLConnection conn = url.openConnection();
               InputStream is = conn.getInputStream();
               Xml.parse(is, Xml.Encoding.ISO_8859_1, new ExampleHandler
   ());
           } catch (Exception e)
           {
               throw new RuntimeException(e

[android-developers] Re: Android 2.0.1 SocketTimeoutException received with FTP Data channel

2010-02-03 Thread Bob Kerns
You're reinventing the wheel here, back before they invented circles.

SFTP uses the same port as SSH (22 is the standard, but you can
substitute if you want to throw off port-scanners) -- you would not be
opening another port.

FTP is *extremely* problematic in the modern world. Originally, it
required that the SERVER open a port back to the CLIENT.

This almost always fails, these days, due to NAT, firewalls, etc. But
it is still the default in many clients. Even if you managed to make
it work, it would be highly insecure -- your data would NOT be going
through your secure channel, and you must open up ports on the client!

You'd have to use so-called passive FTP. You may even find clients
that don't implement it.

You're certainly going to be plagued with client differences. You're
certainly doing kinda-a-the-same-thing, but with a lot more
complexity, security issues, and problems.

Really -- if you have control over the server side, DO NOT implement
FTP.

On Feb 3, 9:01 am, mericksonj mericks...@gmail.com wrote:
 The TCP port is entered correctly as 2121 when I connect to FTP, the
 FTP cpntrol session is started properly according to the server logs.

 I am not using SFTP since I have disabled the sub-system on my SSH
 server.

 I am trying to use SSH TCP forwarding alone to establish and maintain
 the ftp session sice most FTP clients won't support 1024 bit RSA key
 authentication.

 I am considering FTPS, but I'm not sure I want to open up another port
 to the internet.  The SSH service is the only one I currently allow
 through the firewall.

 Can you tell me more about the Java error message I'm getting? or
 maybe if there are any android native FTP apps I can use?

 Thanks!
 --James

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android 2.0.1 SocketTimeoutException received with FTP Data channel

2010-02-03 Thread Bob Kerns
This is the standard result when trying to do active FTP and the
server cannot connect to the random port the client is listening on.

Yes, in standard FTP, the client must act as a server.

On Feb 3, 9:15 am, mericksonj mericks...@gmail.com wrote:

 This works just fine on the Droid, and I am very impressed with my
 android experience so far, I just can't get an FTP- Data session to
 connect without this timeout error.

 Thanks again!
 --James

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Canvas drawing

2010-02-03 Thread Bob Kerns
While that is indeed a useful tool to have in reserve in one's toolbox
-- generally, as in this case, it's better to set a breakpoint in the
debugger, and have a look around.

Even better, in this case, would be to ALSO set a method entry
breakpoint on View.invalidate(int, int, int, int) -- and maybe on
View.invalidate() and View.invalidate(Rect), though I suspect those
would be redundant. (I tried looking at the disassembled code,
forgetting that the Android.jar in the SDK is purely stubs, but you
can check the source, or just set breakpoints on all three, and if
View.invalidate() and View.invalidate(Rect) are calling
View.invalidate(int, int, int, int) as I expect, eliminate them to
streamline your debugging.

Either something is calling invalidate() for you, or something else is
causing onDraw() to be called, and either way, you'l have your basic
answer in seconds.

Remember, normally you don't call invalidate(...) yourself -- it's
called by the system when it detects that a portion of the screen
needs to be redrawn -- for example, after removing a window from on
top of yours, or a layout change.

Throwing an exception like you suggest is particularly useful when
you're not in a position to directly debug -- for example, logging
rare problems, especially ones that occur in production use. It could
also come in handy if stopping at a breakpoint changes the overall
behavior.

On Feb 3, 2:17 pm, Dan Sherman impact...@gmail.com wrote:
 You could see whats calling it with a quick:

 try {
 throw new Exception();} catch (Exception e) {

 e.printStackTrace();



 }
 On Wed, Feb 3, 2010 at 5:11 PM, jamesc jame...@gmail.com wrote:
  Perhaps you're indirectly calling invalidate() in the onDraw(),
  resulting in a redraw loop?

  On Feb 3, 10:00 pm, Neilz neilhorn...@googlemail.com wrote:
   What else can cause onDraw() to be called, if I'm not triggering it
   with invalidate()?

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Binding list views to large data sets

2010-02-03 Thread Bob Kerns
Ah, the difference between theory and practice is that in theory,
there IS no difference, but in practice, there IS.

What platform did you do this on?

I was afraid getCount() was going to turn out to be slow. But I'm
puzzled that it's slow, but SELECT COUNT(*) FROM TABLE is relatively
quick. Clearly, the database is capable of better behavior.

It's pretty typical for reverse cursor motion to be more expensive,
but this is rather larger than I'd have expected.

The discontinuity at 12000 rows, in each direction, makes me suspect
it's using a max window size of 12,000, which is nuts on a phone, and
really wants to be configurable.

I'm also wondering if CursorWindow.freeLastRow() is ever being called
-- and if not, what would happen if we were to call it at suitable
points.

You didn't indicate whether you are using PreparedStatements -- if
not, some of the overhead may come from parsing and managing the
queries. Or, given a weak implementation -- it might not matter
anyway.

I wonder if we could supply our own CursorWindow subclass that behaves
better? The documentation is rather lacking...

Another factor to consider here is the database's caching. If you use
LIMIT to only query a small portion, you could make a derived cursor
that (excluding transaction differences) behaves more reasonably in
terms of how much it fetches. But then you'll be executing changing
queries over and over, so you may be doing more work on the back end.
Given the memory constraints, I suspect each subsequent query will
cost about the same as the first...

Maybe, to be scientific about this, I should write my own tests, we
compare notes, trade programs, and get a bunch of people to try them
on different platforms. I might have time if I don't answer any
questions for a while... :=)!

This is an important use case; it's worth understanding well. I wonder
if anyone has already covered this ground?

On Feb 3, 1:47 pm, THill thill.dr...@gmail.com wrote:
 What you say makes sense Bob, but testing seems to indicate the
 Android SQLite implementation isn't so proper.

 I have a simple app that creates 20001 rows in a table, each with an
 int _id  2 varchar fields.

 Getting the count of rows via db.rawQuery(select count(*) from
 table, null) and getting the value from the resulting cursor takes
 0.2s.

 Getting the count of rows using
     cursor=db.rawQuery(select _id, field1, field2 from table,
 null);  //NOTE: no 'where' or 'order by'
     count=cursor.getCount()
 takes 4.5s.

 During this time, the log has messages:
     E/CursorWindow(  695): need to grow: mSize = 1048576, size = 29,
 freeSpace() = 19, numRows = 11832
     E/CursorWindow(  695): not growing since there are already 11832
 row(s), max size 1048576
     E/Cursor  (  695): Failed allocating 29 bytes for text/blob at
 11831,1
     D/Cursor  (  695): finish_program_and_get_row_count row 8169

 So, getCount() is certainly not optimal, and appears to be allocating
 something based on result set size.  The list view requests the count
 of items up front, so a slow getCount() can impact the UI if you just
 trust SimpleCursorAdapter on large, simple queries.

 When scrolling down the list, each bindView results in a
 cursor.moveToPosition() call.  Doing this in a test app shows that
 moving to 1000, 2000, ..., 2 each takes 1ms -- except when going
 from 11000 to 12000, which takes 2s.  No additional log messages.

 Where it gets u.g.l.y. is when moving from position 2 backward to
 0.  2, ..., 12000 take 1ms, but moving from 12000 to 11000,
 1, ..., 0 *each* take 4.5s (!).  This is really fun to observe
 when scrolling backward in the list from 12000.  Once you hit some
 point, every row takes 4.5s before it is shown.

 When this starts happening, every move results in log messages like:
     D/dalvikvm(  320): GC freed 251 objects / 13256 bytes in 116ms
     E/CursorWindow(  763): need to grow: mSize = 1048576, size = 29,
 freeSpace() = 21, numRows = 11631
     E/CursorWindow(  763): not growing since there are already 11631
 row(s), max size 1048576
     E/Cursor  (  763): Failed allocating 29 bytes for text/blob at
 19630,1
     D/Cursor  (  763): finish_program_and_get_row_count row 370

 This would again indicate the cursor is not agnostic to the result set
 size.  I'll be doing more testing with many smaller query cursors
 behind a single adapter, but there appears to be a clear threshold.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android 2.0.1 SocketTimeoutException received with FTP Data channel

2010-02-03 Thread Bob Kerns
It sounds like you've narrowed it down a fair bit -- and that your
problem isn't really FTP, if your observations actually match reality.
(Always a concern...so much time wasted...shudder...)

Are we talking about a TCP/IP timeout exception? That won't be
affected by delays in crypto, etc. That would indicate a loss of TCP/
IP connectivity. If your data connection is in state ESTABLISHED, then
it's not a connection timeout. If it's not an application-level
timeout (which I don't recall FTP having, but it's been a while), then
it would mean that nothing is getting through -- perhaps a NAT or
firewall issue? I've seen NAT/Firewall issues block data connections
even for passive FTP, though I don't know just how.

I really hesitate to suggest it, but maybe you want to use a tool like
tcpdump? It should at least help narrow down the problem.

On Feb 3, 2:52 pm, mericksonj mericks...@gmail.com wrote:
 @Ryu
 I am using runFTP from the market place as well as andFTP, droidFTP,
 Padersync, and esfile explorer.  All show the same syptoms from the
 FTP server point of view, but give different error messages in andoid
 if they don't just hang there frozen.

 @Bob
 Thanks for the replies Bob!

 FTP is the protocol of choice for many, many, reasons, and I know the
 SSH port forwarding works where PC clients are able to connect
 properly. I admit it is not elegant, but it works with commonly
 available (read: free) server and client software, and meets my
 security requirements.

 I do rely on passive mode FTP data transfers so that the client
 doesn't need to start a listener, but the server is only configured to
 allow one (or few) TCP port option (all FTP passive replies have the
 same IP/PORT) to establish the data connection that will be encrypted
 as well.

 The FTP server is logging debug messages and it does show the data
 connection is open (netstat on both the server and android EMU also
 show an established TCP connection).

 I do believe that it is close to working on android, except that
 something lags (possibly due to the delay with crypto processes) and
 then the timeout exception occurs, but I don't know enough aobut the
 DALVIKVM or the client software to look into it deeper myself.

 If you can point me at additional tools I can use to further
 troubleshoot I would appreciate it.

 Thanks!
 --James

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android 2.0.1 SocketTimeoutException received with FTP Data channel

2010-02-03 Thread Bob Kerns
If you allow anonymous logins, security is not a concern. There's no
need to encrypt, and passive FTP is adequate -- but HTTP is a better
choice these days, for most purposes. Or WebDAV, which is based on
HTTP, but gives you access as a virtual filesystem..

FTP is not secure at all. It's a way for people to not just steal your
data -- but also steal your passwords. Unless you use it via a secure
SSH tunnel -- in which case, you've just reinvented SFTP.

Rule of thumb: If you ask for a password, and care who knows that
password -- don't use FTP.

On Feb 3, 4:51 pm, Lewske Wada r...@run.sh wrote:
 Is SFTP such an excellent standard?

 It is based on SSH and user database so it takes time to authenticate
 and therefore there's no anonymous logins allowed in SSH.

 FTP needs a connection originated from the server in port mode,
 but it's secure enough as long as you use a dedicated ftp-data port 20.
 The problem is you cannot access from inside packet filtering network.
 If you open passive ports, you have to tell which ports to open to
 the server like PassivePorts xxx in for example /etc/proftpd.conf.

 Ryu



 Bob Kerns wrote:
  You're reinventing the wheel here, back before they invented circles.

  SFTP uses the same port as SSH (22 is the standard, but you can
  substitute if you want to throw off port-scanners) -- you would not be
  opening another port.

  FTP is *extremely* problematic in the modern world. Originally, it
  required that the SERVER open a port back to the CLIENT.

  This almost always fails, these days, due to NAT, firewalls, etc. But
  it is still the default in many clients. Even if you managed to make
  it work, it would be highly insecure -- your data would NOT be going
  through your secure channel, and you must open up ports on the client!

  You'd have to use so-called passive FTP. You may even find clients
  that don't implement it.

  You're certainly going to be plagued with client differences. You're
  certainly doing kinda-a-the-same-thing, but with a lot more
  complexity, security issues, and problems.

  Really -- if you have control over the server side, DO NOT implement
  FTP.

  On Feb 3, 9:01 am, mericksonj mericks...@gmail.com wrote:

  The TCP port is entered correctly as 2121 when I connect to FTP, the
  FTP cpntrol session is started properly according to the server logs.

  I am not using SFTP since I have disabled the sub-system on my SSH
  server.

  I am trying to use SSH TCP forwarding alone to establish and maintain
  the ftp session sice most FTP clients won't support 1024 bit RSA key
  authentication.

  I am considering FTPS, but I'm not sure I want to open up another port
  to the internet.  The SSH service is the only one I currently allow
  through the firewall.

  Can you tell me more about the Java error message I'm getting? or
  maybe if there are any android native FTP apps I can use?

  Thanks!
  --James

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: sticky client IP address?

2010-02-03 Thread Bob Kerns
This isn't correct, or is misleading. It's kind of like saying
ethernet doesn't use TCP/IP or WiFi doesn't use TCP/IP or dialup
modems don't use TCP/IP or DSL doesn't use TCP/IP or Cable doesn't
use TCP/IP.

If you drop below the level of TCP/IP, to how the data is physically
moved, then yes, you are below TCP/IP, and in that sense, cell
networks don't use TCP/IP.

However, they CARRY TCP/IP traffic. And that's what those IP addresses
are -- IP addresses. You can establish TCP connections.

TCP/IP is actually two protocols. IP is the lower-level of the two,
handling addressing and routing. It is completely agnostic as to how
the packets are transported. You could use carrier pigeons. Really!

http://www.rfc-editor.org/rfc/rfc1149.txt

I don't know if anybody's done it -- but it wouldn't surprise me.

TCP is on top of IP, and gives you reliable transmission and end-to-
end connection semantics.

Now, perhaps you meant to contrast the situation with VOIP, where
voice is carried over IP. Indeed, voice data is not (normally) carried
over cell networks as TCP/IP, though it's possible. (Not necessarily
acceptable, but possible).

But every phone with a data plan is using the cell networks to carry
TCP/IP.

Your gateway address will be the address of the gateway server, but
your IP address will be your IP address that your server uses to send
traffic to you.

I don't know the current state of the art for how stable your phone's
IP address will be. I can tell you that my phone switches cell sites
surprisingly often, but I've not watched the IP addresses
simultaneously.

But you don't switch IP addresses when you move from Access Point to
Access Point on the same WiFi network. In theory, you could retain the
same IP address for the life of your phone, with a sufficiently clever
and powerful cell network.

In practice, however, that's unreasonable. But perhaps someone can
tell me just when it changes. And why, after rebooting, I have TWO?
One for each tower? We're at the limits of my networking knowledge
when we come to the specifics of how it's layered on top of the
cellular network.

BTW, Vertifi, this Class B/Class C terminology is long obsolete;
addresses have not been allocated by that scheme for many years. It
consumed too much IPv4 address space. Instead, the number of prefix
bits is specified, like 192.168.0.0/24 -- where 24 is not necessarily
a multiple of 8. I don't know if your server farm people are expecting
Class C to refer to distinct networks, or simply using the term as a
holdover, but treating it as the arbitrary distinction that it is. But
certainly we should not import any significance to those IP addresses
being allocated from some larger block than /24. They could all be
from the same subnet, so far as the cellular network is concerned.
This would be some network in some bunker somewhere, with a bunch of
NAT servers, with multiple hot connections to various pieces of the
backbone.

The IP address assigned to the phone will be an address specific to
the link between you and the next piece of equipment that actually
treats your data as TCP/IP traffic. My iPhone reports it as
10.135.130.117; I've never seen it other than a 10.0.0.0/8 non-
routable private address. This is translated via NAT further upstream,
so servers on the other end see a routable IP address; at the moment,
mine is 98.210.255.162.

In theory, this can be different for every TCP connection! But there
are a few things that care about connections with the same originating
system -- active FTP being one. So normally, this synthetic IP address
doesn't change, so long as you have one active TCP or recent
connection, or recent UDP traffic, but after you've been idle or a
bit, it purges its mapping tables, and on your next connection, you
appear to come from a new IP address.

This is really no different than any large enterprise NAT networking
environment. Just bigger.

Anyway -- while there are holes in my explanation, I don't think
there's anything inaccurate.  But I hate being wrong, so please jump
in with any corrections or additions!

On Feb 3, 7:38 am, Mike michael.mo...@navteq.com wrote:
 The simple answer is that cell networks don't use TCP/IP.  What you
 see is the IP address of the gateway server that happens to have
 generated the request.  This could change on every request and is not
 time based.

 Hope it helps.

 - Mike
 NAVTEQ Network for Developershttp://NN4D.com

 On 3 Feb, 15:35, Vertifi c...@eascorp.org wrote:



  Hello,

  I have an app which performs some online functions to a web server
  farm we operate using URLConnection.  I'm finding that the client IP
  address of the phone seems to change after a fairly brief period of
  inactivity.

  For example, please see these timestamps and the corresponding client
  IP addresses:

  2010-02-03 09:46:47 / 32.152.30.98
  2010-02-03 09:47:05 / 32.152.30.98
  2010-02-03 09:57:21 / 32.152.218.197
  2010-02-03 09:59:53 / 32.152.23.19

  This is sitting in a stationary 

[android-developers] Re: Cellular-WiFi Switch

2010-02-03 Thread Bob Kerns
I can partially answer your question.

1) It happens automatically. With WiFi on, no IP routes are present
for the 3G network. The 3G network adaptor is disabled. Turn off WiFi,
and the  WiFi network adaptor is disabled, and the 3G adaptor is
activated.

To my modest surprise, the networks are not simultaneously present,
and so the routing table only holds one set or the other. (At least on
my Nexus One). This doesn't appear to be how my iPhone works.

2) Any active connection drops under such a switch. The other end no
longer knows how to reach the phone. There are ways this COULD be
handled, with the help of an intermediary server, which would
basically provide Network Address Translation services. I believe
something similar is going on within the cellular carrier's IP traffic
handling, but I don't know for sure.

3) Yes. Modulo problems the Nexus One has with T-Mobile's 3G service,
which are due to be fixed shortly.

4) No alert or notification whatsoever, assuming the user has already
given permission to use this network, and supplied the credentials if
necessary. The Wifi icon in the status bar will appear/disappear, and
the 3G icon disappear, but nothing designed to call your attention to
the change in status.

On Feb 3, 1:46 am, subho subhendu...@gmail.com wrote:
 Hi All,
 I'm doing a research on Cellular-WiFi switch and finding any mechanism
 to handle cellular hand off.As far as i've found,an http request is
 routed through WiFi network if connected even gprs/cellular connection
 is present.My queries are :

 1)Does this switch happens automatically ? If yes,which part of
 framework or code does that?
 2)Does the http request drop in such situation due to cellular hand
 off ? Is there any way to handle such hand off ?
 3)Does gprs cellular connection reconnects automatically when WiFi
 gets disconnected ?
 4)Which type of alerts or notifications normally user gets in such
 situations ?

 Yours feedback and inputs will be of great help for me in this
 activity.

 Thanks,
 Subho

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Download and Display 9 Patch Images

2010-02-03 Thread Bob Kerns
You have to create a NinePatch from the bitmap, and then a
NinePatchDrawable from the NinePatch.

http://bit.ly/9nS9xm
http://bit.ly/cL5sR2

You're just treating it as a graphic, rather than a NinePatch. The
resource system does this for you automatically if it recognizes the .
9.png filename; otherwise, you'll have to do it yourself.

On Feb 3, 8:15 pm, brian karlo gutierrez brikz...@yahoo.com wrote:
 Hello Everyone,

     I have a question regarding 9 patch images. Is it possible to download 9 
 patch png files from a webserver then display it as a background of a layout 
 while keeping the information inside the file like the stretchable pixel? I 
 have tried using a 9 patch image coming from the resource drawable directory 
 of my project and it displays correctly...stretching only those pixels marked 
 as stretchable but when I tried to download a 9 patch image from my web 
 server then the application will use the downloaded 9 patch image the 
 stretchable pixels does not take effect..i mean instead of stretching only 
 those pixels that where marked as stretchable it stretched the whole image...

 the code im using is this one:

 URL url = new URL( imgurl );
 URLConnection con = url.openConnection();
 con.connect();
 this.mStream = con.getInputStream();
 Drawable image = BitmapDrawable.createFromStream(this.mStream, imgfn);
 this.mStream.close();
 this.mImageLayout.setBackgroundDrawable( image );

 Hoping for some help.

 Thanks,

 Brian

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How can Camera API support two camera device?

2010-02-02 Thread Bob Kerns
I think you want:
http://bit.ly/9LfmQ0

The framework supplies two values,  VideoSource.CAMERA and
VideoSource.DEFAULT. If you're developing this device, I think you
should take CAMERA to mean default camera, probably with a way for
the user to select which is the default. Other values (i.e. integers
greater than 1) would specify a specific camera.

If someone else developed it -- you'll have to ask them what they did,
or try using 2, etc. for the VideoSource and see what happens.

On Feb 1, 8:04 pm, Joker chin...@gmail.com wrote:
 Hello friends, please help me...
 The android camera API is bound to one camera device, but in some
 situation we have lots of camera device in a netbook or handset. We
 can't use the same application with different camera device
 dynamically. For example, we can select the camera device in the VLC
 (Video LAN Client) on windows because there is directshow on it, but
 we can't do that on android by camera API without changing the
 framework. Guys, is there any mistake at my understand? Is there any
 plan to modify framework to support this situation ?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to format the second partition on an SD Card using terminal emulator?

2010-02-02 Thread Bob Kerns
I'm a little unclear on why you'd want to do this you can access
the first partition from Windows already.

But anyway -- why not format the second partition from Windows? That
is, hook the SD card directly to a Windows box (or a Linux box, or a
Mac, or any less-limited environment!) and format the second partition
there? In most cases, you'll even have a UI to help you out, and make
sure you picked the right partition, etc.

On Feb 1, 4:22 pm, TejasM tejas.man...@gmail.com wrote:
 How to format the second partition on an SD Card using terminal
 emulator?

 I have been trying to format the second partition I created on an sd
 card using the terminal emulator.

 I have tried all the normal mkfs, mkpartfs, mkdosfs all of them say
 command: not found.

 Though 'dd' works and clears the data it also destroys the File
 Allocation Table.

 I was trying to format the second partition of the sd card so that I
 can still use the sd card on my windows machine and view the files in
 the second partition.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Suspicious TCP RST packets while device is sleeping.

2010-02-02 Thread Bob Kerns
This is expected behavior. TCP connections time out if the connection
is lost, or either side dies. That way, you don't have systems
drowning in dead connections.

The RST packet is telling you that the server has forgotten about the
connection. The client may even report it directly, if it realizes
that it hasn't heard from the server, so you may get a connection
reset error even without seeing an actual RST from the server.

The default timeout is usually 5 minutes, which squares with your
observations. In general, you should not try to solve your problem by
increasing the timeout, but rather by reestablishing the connection,
and maintaining long-lived sessions at a higher level.

I'd recommend, if possible, dropping your AlarmManager ping task, in
favor of reopening your connection. You'll consume less resources --
including battery. If you want to minimize the cost of reopening
connections, you can send a ping whenever you happen to wake up,
reopening if necessary. But that doesn't scale that well -- you'll be
able to have more simultaneous clients if you strike a suitable
balance between keeping connections alive, and the cost of reopening
them. For rare interactions, you can support more clients if you open
connections on actual need, and close them promptly when not needed.

It all depends on exactly what you're trying to optimize, and the
environment in which you're operating. The only constant is -- you
can't DEPEND on keeping connections alive. View it as an optimization,
rather than how your application works.

And then make sure it is actually an optimization! So often,
optimizations are a waste of a developer's time.

I'd also recommend avoiding thinking about TCP at the level of packets
(or segments), RST, etc., if at all possible. Unless you're trying to
diagnose a flaky router, or issues with radio connectivity, or things
at a similar level, it's better to focus at a higher level, at least
at the socket level -- is it opening, established, closed, reset?

On Feb 2, 1:05 am, Dan Sherman impact...@gmail.com wrote:
 Hey guys, trying to track down a rather elusive problem here...

 I've been playing around with long-standing TCP connections to a server.

 The client opens a TCP connection to the server, sets a timeout at a
 reasonably long period (30 minutes), and adds an AlarmManager task to ping
 the server every 15 (a ping is just a junk packet the server responds to
 with an application-level ack).  Nothing fancy, and everything works
 correctly on the emulator.  The client stays connected to the server for as
 long as I've left it alone (a few hours easily).

 However, as soon as it runs on device, I receive some interesting behavior
 when the device is sleeping (CPU completely off if I understand correctly).

 If I let the device connect, and go to sleep (can't be 100% certain it is
 asleep, but I wait a good few minutes).  And have the server send an
 un-expected packet to the client, the client most definitely wakes up,
 processes the packet, and sends a response.  The wakeup noticibly takes a
 few extra seconds, but this isn't an issue.

 The issue comes in if I let the device sleep for a more extended period of
 time (somewhere around 5 minutes).  At this time, I see the server drop the
 connection as reset, and the client sit there sleeping.  As soon as the
 device is woken up (by my intervention), and I try to do any network
 actions, it notices the connection isn't good anymore, and starts a
 reconnect (hard-coded to reconnect).

 I've been running tcpdump on both the client, and the server.

 The interaction is as follows:
 Server's point of view:
 - Client connects (a few packets back and forth, application level, etc)
 - 5ish minutes pass (device is sleeping)
 - Client sends a reset packet (connection is torn down, expected)

 From the client's point of view:
 - Connection startup (a few packets back and forth, application level, etc)
 - Device goes to sleep

 The client never sees the TCP reset packet.  Once woken by something
 external (me, the AlarmManager task, etc), the client immediately sees a RST
 packet from the server, tears down the connection, and starts over.

 Anyone care to chime in with ideas as to what is happening?  My only
 thoughts are that someone in between is killing the connection due to not
 seeing any data send between the two after a certain amount of time, however
 the time between the last packet, and the RST isn't a consistent period...

 This behavior is happening when running a G1 on Tmobile's 3g US network.  It
 happens when the server code is running both remotely (machine in Texas), as
 well as when its running on local machine (Florida).

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at

[android-developers] Re: Password Security / Encryption / Decompile?

2010-02-02 Thread Bob Kerns
First, I hope you're not actually talking about FTP. FTP is not
secure, no matter WHAT you do. SFTP -- FTP over SSH -- on the other
hand, can be done securely.

This is one of the use cases for using certificates. Rather than a
username/password in the code, you embed an X.509 certificate, which
you use to authenticate for initial setup.

When you connect the first time, you supply the device ID, and get a
new, per-device certificate. This is what you actually use to
communicate with the servers. (The device generates a private key,
produces a certificate request with it, and the server returns a
signed certificate, signed by the server's private key).

Ideally, you'd use the Android AccountManager to store this
certificate.

If a phone is lost or stolen, you can cut off its access by revoking
that certificate.

You use a new certificate with each release, so your exposure to the
risk of people reverse-engineering a cert is, at least, somewhat
limited. If you need more security, so that only authorized people are
allowed to get on, then you need an additional factor, outside the
application -- such as an emailed registration key, a one time pad, a
cryptographic key dongle -- whatever suits your particular
requirements for security and convenience.

Likewise, your server should have a certificate (and private key).
This ensures against someone impersonating your web site.

Finally -- your protocols should include a nonce -- a one-time value
that changes with each request, and should be echoed (and checked) in
the response.  You can generate this with SecureRandom. This protects
you against replay attacks. Even if you don't think replay attacks are
important -- do it anyway, since it's so very easy to do.

On Feb 2, 6:02 am, WC whitc...@gmail.com wrote:
 I am developing an app that uploads files to an FTP server, and the
 app will have the ftp user name / password in the code. I'm
 investigating making the FTP user name and password as secure as
 possible (including an encrypted value for each in a strings.xml and
 decrypting in the app when it needs to connect to the FTP server).

 My concern is this is not actually secure at all, it seems someone
 could unzip the .apk, decompile it, view the strings.xml and java code
 that decrypts it - and thereby obtain the ftp login info.

 So my question is.. am I approaching this wrong way? Is there a
 standard method of ensuring passwords that are hard coded into an app
 can be secure? (note - in this case this is not a password a user of
 the app would enter, the FTP password is universal to all that install
 it so it is included in the app).

 Apologies if this is a noob question but I don't know my way around
 this whole decompiling / hacking android apps thing. Any input would
 be greatly appreciated!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Help needed with parsing some XML data !

2010-02-02 Thread Bob Kerns
While I would expect your second approach to work, it's important to
note that IT IS NOT REQUIRED TO WORK.

The XML standard does not require XML processors to support anything
other than UTF-8 or UTF-16.

In this day and age, I would STRONGLY discourage use of anything other
than UTF-8, or, rarely, UTF-16.

Another factor to consider is how you're getting access to those
characters. You must do this one of two ways:

1) Using a Reader set to read 8859-1
-or-
2) Using an input stream, giving the raw bytes to the parser, letting
it decode the 8859-1 characters.

You WILL FAIL (and this is probably your problem, would be my guess)
if you try to read using a Reader that's expecting UTF-8.

A stacktrace should show which problem you have.

On Feb 2, 6:42 am, MobDev developm...@mobilaria.com wrote:
 Hi,
 I am downloading a xml-type file from a webserver which starts out
 with :

 ?xml version=1.0 encoding=iso-8859-1 ?

 afterwards I get a list with loads of countries, some countries do
 contain some letters like é and á.

 I have tried to extract the data of the xml in two ways :
 1 - simply download the whole thing into a String, which will result
 in those characters being seen as something like [] or on the Android
 emulator (and device) I will see a triangle with a ? in it...

 2 - fetch the list with the SAXParser and XMLReader which will just
 throw an exception telling me that there is some content error...
 specifically at the line where the first country is with such a
 character...

 So is there some way to get this to work ? Can I read the iso-8859-1
 encoded xml into the Parser ? Or is there some way to encode/decode
 the received data into something actually usable ?
 Any idea where the problem might be ?

 Thanks in advance for any hints, tips, code or explanation :D

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Binding list views to large data sets

2010-02-02 Thread Bob Kerns
On Feb 2, 2:00 pm, Mark Murphy mmur...@commonsware.com wrote:
...
  A Cursor represents the entire result set. If you run a query for
20K rows
  and 5 columns, you will instantiate 100K objects at the time the
query is
  actually run.
...

Actually, that shouldn't be quite right. (I know you know this, but
were focused on making your main point. I just want to clear up any
confusion).

A Cursor should represent a result set + a movable index in that
result set. The major reason for using a cursor, is precisely to AVOID
simultaneously allocating space for all 20K or 20M or 20B rows.

Now, a naive implementation is, certainly, to load in all the results
from a query. But a PROPER implementation will:

1) analyze the query
2) form a query plan -- sort of a mini program for generating the
query result.
3) on request for the first row, begin executing the plan, one or a
few rows at a time. The portion of the query results that have been
read are the window.
4) Once you've read the data from one row, and move to the next, the
storage can be freed.

(Everything but the final reading should happen on the database side,
to avoid doing unnecessary work on the query).

Note that, at no time, have you allocated 20K rows worth of objects.
Yet, by the time the task is done, IF you actually read ALL the
objects, you you'll have allocated each of those 20K rows's objects.
In fact, if you move back an forth, you may allocate a good deal MORE.
But the garbage collector will save you, and your peak usage will only
be a few rows worth.

It's important to note that a cursor can't completely save you from an
expensive query! Behind the scenes, the database may have to do some
very storage-expensive work -- like sort the results of a complex
query. To do this, it may need to first collect ALL the rows, and then
sort. Indexes may help in some cases. This is the sort of thing that
makes database programming an interesting challenge sometimes...

But even in this case, there's a benefit to getting your results via a
cursor. You may need to have a complete list of rows - but you won't
need to turn those rows into Java objects until you need them. So you
won't need as much storage all at once.

This all works very synergistally with your CursorAdaptors! Just
stuffing all 20K rows into a ListView isn't going to save you
anything. But if 10 items fit on your screen, only asking for about 10
items is going to save you a factor of 2K in peak storage. And if you
only look at one or two screens, the performance difference will be
huge!

Anyway, you've just convinced me to go get your book. It's got to be
worth it, just for a pre-written EndlessAdaptor implementation! (Yes,
I can download it, but..)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Getting permission to install Android SDK on University computers

2010-02-02 Thread Bob Kerns
Um, this is a University, and they require permission from a company
to teach about their products???

Seriously, you (or maybe who you are talking to) must be
misinterpreting their policy. Sure, they don't want any bootleg
software. For purchased software, an invoice, license key, etc. But
for free software, the free software's license agreement I'm quite
certain has to be enough for them.

Your IT department does not have the resources to handle the volume of
paperwork that would result if every free software installation
required this sort of runaround.

Take the easier approach: Call up your IT guys -- explain that the
software is free, open source,  and what documentation of this would
they like? Probably just the URL would do the trick:
http://developer.android.com/intl/de/sdk/terms.html

A license *is* permission. It may be contingent on paying a fee -- or
not, as in this case.

If you really DO get a nonsense answer, insist that either THEY do the
legwork, or go up the food chain. Because somewhere up there, someone
won't be wanting all that wasted overhead on silliness.

On Feb 2, 1:34 pm, tansaku tans...@gmail.com wrote:
 Hi Rogerio,

 Thanks for your input, I'll certainly try that, but the policy appears
 to be that they will only install things if they have written
 permission from the company in question ...

 CHEERS SAM

 On Feb 2, 11:18 am, Rogério de Souza Moraes rogerio.so...@gmail.com
 wrote:



  Hi Tansaku,

  the Apache License isn't enough to them them? If you have apache servers
  running in your university, you can use the same arguments to use Android
  SDK and ADT in your university, or who use it had to contact the Apache
  Foundation and ask for the statement too?

  Regards,

  Rogerio

  2010/2/2 tansaku tans...@gmail.com

   Hi there,

   I'm teaching an Android course at Hawaii Pacific University, and I
   want to install the Android SDK and ADT on university computers, but
   the University policy requires explicit permission from Google.

   Does anyone know who I could contact at Google to get an official
   statement that it was okay to install the software on University
   computers?

   Many thanks in advance
   Best regards
   Sam Joseph, Ph.D.

   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs
cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AsyncTask and simultaneous network downloads

2010-02-01 Thread Bob Kerns
I don't understand. Why not just supply your own CookieStore -- why
rewrite so much? http://bit.ly/cymmRg

I don't recall having used this -- when I last used HttpClient, I
didn't have any need to share cookies.  So maybe I'm missing some
problem.

HttpClient is complex because HTTP is complex. I'm sure you only
handle a small subset of everything that's in the HTTP 1.1 spec.

If you have control over the server side as well as the client, or
only need a very limited set of functionality, that's fine. Simple
uses of HTTP are quite simple.

However, if you're making a reusable framework you not only need to
handle the full range of the spec -- you also need to give the user
the flexibility to configure and modify its behavior.

That's why there's stuff like setCookieStore(), and a similar stack of
configurable processors to what you'd find in a HTTP server such as
Tomcat or Jetty.

BTW, my preference would be to separate content handling from HTTP
access. Content handlers are useful in other circumstances, too. I bet
you actually made your content handling system separate, and made your
top HTTP layer use it. But you could get the same synergy with
HttpClient.

In fact, Content Handlers are so useful, that the Java library already
defines the java.net.ContentHandler interface.

So why did you drop all the way down to java.net.Socket, rather than
using java.net.HttpURLConnection, which already integrates with
content handling, handles the HTTP and HTTPS protocols, AND provides a
way to set the cookie handling? It sounds like you've pretty much
duplicated its functionality.

You can even write one-liners:
   new URL(http://www.example.com/myresource;).getContent();


On Jan 28, 1:28 pm, Jason Proctor jason.android.li...@gmail.com
wrote:
 the main HttpClient showstopper for me was its buggy cookie
 implementation - i needed to share cookies between WebKit and
 HttpClient, and HttpClient wouldn't play nice. however, i also
 thought the API was awkward to use. last thing, i took a look at the
 code. someone really managed to turn something relatively simple into
 a gothic monstrosity.

 so i wrote my own (simple) HTTP implementation on top of
 java.net.Socket. it's very simple and doesn't support any fruity
 options, but it integrates with my progress reporting system, and
 automatically shares cookies with WebKit. it has a pluggable content
 handler system so you can easily get binary, JSON, strings, etc, from
 resources with one line of code.

 my apps now depend on it -- i use it from within AsyncTasks all the
 damn time and it's solid.





 Jason,

 Rolled your own? Can you share/elaborate? There seems to be other
 issues with HttpClient. I am looking at either integrating
 Jersey/JAX-B client side to send REST calls (my server side is all
 Jersey/JEE6/JAXB based), but if that is too bulky for the app, then
 I was looking at using URLConnection.. but I haven't tried using
 that for REST calls with Basic Auth, various headers, xml/json body,
 etc.

 On Thu, Jan 28, 2010 at 1:01 PM, Jason Proctor
 mailto:jason.android.li...@gmail.comjason.android.li...@gmail.com
 wrote:

 i hope not, because the code makes a new HttpClient instance per
 ArtRetrievalTask. i suppose it could be trying to be clever,
 realising that the requests are going to the same place, and
 utilising HTTP 1.1 to bundle the requests into the same connection.

 if that's really what's happening (and i suspect not, somehow), and
 maybe only the server logs can tell for sure, then i hereby state
 for the 67th time how happy i am that i dumped HttpClient and rolled
 my own HTTP.

 Perhaps the requests are being serialized by HttpClient? I wonder if
 there's a way to determine the actual thread a particular
 AsyncTask's doInBacground process runs on, like maybe a thread id?

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to
 mailto:android-developers@googlegroups.comandroid-develop...@googlegroup 
 s.com
 To unsubscribe from this group, send email to
 mailto:android-developers%2bunsubscr...@googlegroups.comandroid-develope 
 rs+unsubscr...@googlegroups.com
 For more options, visit this group at

 http://groups.google.com/group/android-developers?hl=enhttp://groups.google.com/group/android-developers?hl=enhttp://groups.google.com/group/android-developers?hl=enhttp://groups.google.com/group/android-developers?hl=en

 --
 jason.vp.engineering.particle

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to
 mailto:android-developers@googlegroups.comandroid-develop...@googlegroup 
 s.com
 To unsubscribe from this group, send email to
 mailto:android-developers%2bunsubscr...@googlegroups.comandroid-develope 
 rs+unsubscr...@googlegroups.com
 For more options, visit this group at
 

[android-developers] Re: How to display unicode text received from a web API

2010-02-01 Thread Bob Kerns
How are you parsing the XML? It's the XML parser's job to understand
this stuff, not yours.

If you're taking the XML as text and trying to understand it -- don't.

For example, DOM gives you getData() on a Text node, SAX informs you
via a characters(...) method call, and XMLPull offers you getText().
Similar options apply if the text appears in an attribute.

However, I'm puzzled that you say the characters are either omitted
or I don't know who'd be omitting them. I'd be concerned that you
have a font problem where it's not displaying that character. I'd be
surprised at this for any of the system-supplied fonts for a European
language, but for other fonts, it'd not be unusual to find one that
only supports ISO 8859-1, for example, which does not include this
character (though it's in ISO-8859-15).

On Jan 30, 7:03 am, Marko Anastasov marko.anasta...@gmail.com wrote:
 Hello,

 I'm fetching some data from my web API that returns XML with content
 which includes escaped unicode characters. So there is content such as
 Izlo#382;ba which I need to display in a TextView as word
 Izložba. How can I do this? Right now these characters are either
 ommitted or displayed as that raw escaped value.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: bug reporting

2010-02-01 Thread Bob Kerns
I think this is an excellent suggestion. There's a product that does
something like this on the Mac. Another model is Windows Error
Reporting.

I think it would do well as an open-source project.

Unfortunately, there's no good way for products to depend on it --
that is, to cause it to be installed with an application. The best
thing I can see is for products to suggest it be installed in their
info screens, startup screens, etc, with one-button access to the
Marketplace to install it. But if communication were via broadcast, it
would be silent if the user opted not to install. And work nicely if
the user installed 3 different competing facilities, so long as there
were a standard for that broadcast message!

On Jan 30, 8:30 pm, laphroaig15 laphroai...@gmail.com wrote:
 I'd finished up my first android application, a simple power
 management app, and was preparing to release it when I realized that I
 didn't have a proper design or infrastructure for bug reporting.  One
 of my pet peeves with the applications on the Android marketplace is
 that there's inadequate visibility into the change logs from version
 to version.  I get a notice to update app X, but I don't know if
 that's fixing a bug that's been annoying me, adding/refreshing
 advertising code, etc.  I dislike adding to chaos.

 So, I started looking at my options.  Obviously, if I hosted my source
 code somewhere then users could use the hoster's built-in bug tracking
 facility to report bugs.  On the off chance that a mobile user took
 the time to look up the project and submit a bug, I'd still be reliant
 on the submitter to supply correct and relevant diagnostic
 information.  I have my doubts that either would occur reliably.

 I came across this thread [http://groups.google.com/group/android-
 developers/browse_thread/thread/bae832439608ad2e/44d2e285da39aa57?
 lnk=gstq=exception+handler#44d2e285da39aa57] detailing a simple
 strategy for collecting information under the covers and posting an
 exception to a remote server.  I see some issues with this strategy as
 well:

 1.  It doesn't engage the user to acknowledge that a problem has
 occurred (mea culpa).
 2.  It doesn't elicit contextual information from the user.
 3.  It doesn't help to provide the user visibility into the state of
 issues for the application (bugs nor enhancements).
 4.  It requires that my application request internet permission.  If I
 wanted to allow the user to opt-in to send some personally
 identifiable information (say to support notification), then I'd need
 to request profile permissions.  I dislike jumbling together a lot of
 disparate concerns and then asking for every permission under the
 sun.  This trend will lead to users totally disregarding the
 permissions altogether.

 So, my thought was to implement a separate Bug Reporting application
 that handles bug tracking.  Other programs could elect to register
 with this app.  The BR app accepts crash information from a calling
 application, prompts the user to provide summary, description, and
 priority information, then posts the issue to the developer's bug
 server (indicated during registration).  The BR application could be
 further enhanced to retain these issue ids and allow the user to
 browse the state of them (by browsing to a well defined link or via
 some well-defined exchange with the bug server).  Similar
 functionality could be implemented to allow viewing change logs,
 release road maps, etc. for the app.  Obviously, the integration b/t
 the BR app and the client apps would be implemented in such a way that
 there would be a transparent no-op if the user decided to uninstall or
 never install the BR app (so as to not perpetuate a bad Vista-like
 user experience).

 It looks like I can license JIRA for $10 and open up anonymous issue
 creation.  So, far I've prototyped a simple BR activity and a JIRA
 plugin to accept BR submissions.  Obviously, the http protocol could
 be openly defined in such as way as to allow integration with any
 extensible bug tracking system.

 I'd like to hear opinions on this strategy.  Has it already been
 done?  Is it too intrusive or techy for users?  Do you agree or
 disagree that visibility is an issue?  Is there simply a better
 solution of which I'm unaware?  Ideally, such a thing would be
 embraced by Android itself (or the market).

 regards,

 -Jess

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to display unicode text received from a web API

2010-02-01 Thread Bob Kerns
That reminds me -- check that your web server is setting the encoding
to UTF-8. And that you are consistently processing it as either
uninterpreted bytes or as UTF-8. Anything else is insane in the modern
world, but you'd be surprised at how often people configure web
servers to use some other encoding.

That's probably not either of your problem -- but if it is, you could
waste a lot of time if you don't check.

On Feb 1, 11:04 am, Kevin Duffey andjar...@gmail.com wrote:
 I have a similar issue.. have not yet looked into it, but we have some
 characters with accents and such that at least in LogCat don't show up
 correctly. I expected as much from LogCat tho. I have, however, seen them
 also not show up in displaying them as text in an overlay on a map. I am
 using xml pull to get the nextText() and it stores as a String object. Like
 I said, I've not yet looked into the matter... but since this topic came up
 I will follow it and post my findings if/when I can get to it. I assumed I
 might have to do something special when sending it. I am however using
 Jersey for my REST call via GlassFish v3, and using JAXB. It also may be
 that the web page I use to allow input of the data.. is not sending it
 correctly to the server..and thus my DB may not store it correctly.

 For the OP.. did you make sure before it leaves your server side.. it's
 correct?



 On Mon, Feb 1, 2010 at 10:54 AM, Tommy Hartz droi...@gmail.com wrote:
  Is the text being ommited when it is being sent from your webservice or are
  you getting the full correct text back to android then android
  is omitting stuff?

  On Mon, Feb 1, 2010 at 1:51 PM, Bob Kerns r...@acm.org wrote:

  How are you parsing the XML? It's the XML parser's job to understand
  this stuff, not yours.

  If you're taking the XML as text and trying to understand it -- don't.

  For example, DOM gives you getData() on a Text node, SAX informs you
  via a characters(...) method call, and XMLPull offers you getText().
  Similar options apply if the text appears in an attribute.

  However, I'm puzzled that you say the characters are either omitted
  or I don't know who'd be omitting them. I'd be concerned that you
  have a font problem where it's not displaying that character. I'd be
  surprised at this for any of the system-supplied fonts for a European
  language, but for other fonts, it'd not be unusual to find one that
  only supports ISO 8859-1, for example, which does not include this
  character (though it's in ISO-8859-15).

  On Jan 30, 7:03 am, Marko Anastasov marko.anasta...@gmail.com wrote:
   Hello,

   I'm fetching some data from my web API that returns XML with content
   which includes escaped unicode characters. So there is content such as
   Izlo#382;ba which I need to display in a TextView as word
   Izložba. How can I do this? Right now these characters are either
   ommitted or displayed as that raw escaped value.

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs
   cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

   --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: System Settings

2010-02-01 Thread Bob Kerns
The ones you're not allowed to change are defined here:
http://developer.android.com/intl/de/reference/android/provider/Settings.Secure.html

The ones you ARE allowed to change (with
android.permission.WRITE_SETTINGS permission) are defined here:
http://developer.android.com/intl/de/reference/android/provider/Settings.System.html

You use the static methods on those two classes, together with your
applications ContentResolver, to access them:
e.g.:
return Settings.System.getInt(getContentResolver(),
NOTIFICATIONS_USE_RING_VOLUME)

Physically, these are stored in a database, but you shouldn't do it
that way.

On Feb 1, 9:52 pm, android beginner android.beginne...@gmail.com
wrote:
 Hi,

 How System Settings (eg, volume, brightness) stored in Android and where?

 Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android Programming Class

2010-01-31 Thread Bob Kerns
You know, the sad thing is that you'd find it surprising that 8th-
graders would know Java well enough to program apps for Android.

So very rare are schools and teachers who actually GET that kids can
learn to program, and properly taught, are empowered and excited by
it.

Seymour Papert was teaching kids Logo back in the 1960s. Program after
program have shown that kids can and will program at an early age,
given suitable tools and opportunity. I myself, back in the mid-1970s,
taught kids as young as this to program Lisp -- remotely, over the
network.

From 1979 to 1982, Brian Harvey (now a lecturer at UC Berkeley) taught
computers at the Lincoln-Sudbury Regional High School in
Massachusetts. He modeled the lab an experience there after the AI
labs at MIT and Stanford, and I used to religiously follow his
postings about his experiences, which were fascinating. I've just
located for your reading pleasure a talk he gave about his experience:
http://www.eecs.berkeley.edu/~bh/freedom.html -- but that scarcely
begins to cover it.

Java is not some monolith that has to be taught all at once, nor is
Android. Kids are motivated by curiosity, and if you give them a path
that's not too steep, they'll not only follow that path, but will
explore side trails and ideas that will astonish you.

Contrast this to what passed as programming classes at our local
high school, where my older daughter attended.Visual Basic -- just
enough Visual Basic to manage to glue screens together in the screen
designer. Not even enough programming involved to establish the
concept of a variable, of an object! (Thus, it didn't work out too
well when she tried a science fair project in Java, against a deadline
-- only to discover belatedly that she really needed to start off as
if she didn't know any programming at all.)

Look at how computers are presented within our schools today. Even
today, may teachers are intimidated by computers. When not, they're
presented as tools -- editing, drawing/paint, spreadsheets, maybe a
bit of movie production.

That's good -- but they're also so much more. They're not just a tool.
They are a platform for tool building.

But so much depends on having teachers, who know how to build tools,
and undertake to teach it.

So, Josh Beck: I salute you. I'd love to hear more about your
experiences, and I'd love to see your initiative replicated, explored,
etc. Android may yet supplant OLPC, not by trying, but simply by being
an affordable, mass-market platform in the right place at the right
timme.

On Jan 30, 7:35 pm, Kevin Duffey andjar...@gmail.com wrote:
 Wow. 8th grade. They already know java well enough by that age to pick up on 
 android?



 joshbeck josh.beck2...@gmail.com wrote:
 Hello everyone:

 I teach an 8th grade programming class in San Antonio Texas. We're
 learning Android and I convinced the school to buy us 3 dev phones for
 the kids.

 Here's an article about what we're doing:

 http://www.neisd.net/ComRel/News/Krueger_Smartphone_10.htm

 I'd like to purchase a netbook to supplement the phones so that when
 the students check them out, they have an out-of-the-box programming
 environment within which the phones work.

 I've put together a donation page. My goal is to raise $350 dollars
 for a netbook to go along with these devices. If you can donate $1,
 $5, or $10 to help my class out, it would be greatly appreciated.

 http://www.linuxclassroom.com/donation/donate.html

 Thanks so much for considering it!

 Josh Beck

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Use of final for locals on Dalvik

2010-01-30 Thread Bob Kerns
They can readily inline them in the same class (so all private methods
qualify). Otherwise, you don't really know what the code will be until
the class is loaded. A sufficiently-clever classloader can do amazing
things, but usually this sort of trick is done later, Just-In-Time
compilers that compile down to bytecode.

I don't know much about DalvikVM, specifically. Supposedly, per
Wikipedia, there's a JIT compiler in the source, not currently
enabled. I think it's reasonably safe to assume that for the moment,
anyway, there's probably no inlining except within a class. It's
unclear what the performance characteristics would be, anyway.

Still, it's advisable to make methods private when they're not needed
by other classes (including subclasses), and final when they are
needed by others but won't be subclassed. ('final' is redundant for
'private). This has the dual benefit of a creating a simpler
interface (you know the code you need to look at is here, not in some
subclass, and you know it's only used here, not in some other class),
and also allowing the compiler the possibility of optimizing.


On Jan 29, 3:49 pm, Kevin Duffey andjar...@gmail.com wrote:
 I am a bit rusty on the use of final methods.. I do know they cant be
 extended.. but I also thought that modern JVMs inline final methods or
 something..to help speed them up?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Use of final for locals on Dalvik

2010-01-29 Thread Bob Kerns
See below.

On Jan 29, 3:47 pm, Streets Of Boston flyingdutc...@gmail.com wrote:
 I'm not sure about DalvikVM, but some compilers take advantage of
 'final'.

 E.g.
 Final variables can be put in registers of the CPU without worrying
 that they may change during execution (constantly moving variable-
 values back and forth from memory to registers could be omitted for
 'final' vars).

 Or the compiler itself may do some better optimization of binary code
 generation if it knows that a variable is 'final' and will never
 change.

 ...

 On Jan 28, 4:53 am, Tim Russell t...@jatra.co.uk wrote:



  I've seen a lot of use of final for local primitives.

  Presumable to indicate to the compiler that the value shouldn't be changed.

  However, what's the implication of this on Dalvik?

  I believe final local variables are usually placed on the heap for extended
  lifetime (for use in inner classes), so is their a runtime overhead rather
  than using simple locals (which use Dalvik registers)?

  Thanks,
   Tim

First, let's make sure we're talking about the same thing.

Variables are declared in methods. They only exist during the
execution of the method -- or during the lifetime of any internal
methods defined anonymous in classes defined that method.
Fields are declared in classes. Their lifetime is exactly that of
the instance. (There is an invisible reference to that instance in any
nested non-static classes, or executions of methods, or potentially,
methods on classes defined within methods).

Scope generally is used to refer to lexical scope -- that is,
which part of the code you can reference a variable.
Lifetime is used to refer to how long an object, or a variable's
value exists.

Generally speaking, variables will be on the stack, while fields will
be within instances, which are always in the heap. Variables which are
declared final, and which are referenced by methods of anonymous inner
classes, MAY be copied to the heap as part of the implementation.
That's hidden, and not important to you, unless you're counting the
byte cost of an inner class instance.

Actually, (assuming you're really talking about variables, and not
fields, see below) compilers could do the optimization you describe,
but I doubt it, because it would be lame. Here's why:

The optimization you describe can be done for any variable which IS
NOT assigned.
A final variable CAN NOT be assigned. This is a subset of the above
category.

All Java compilers, as part of required error checking (including the
check for definite assignment) know specifically whether a variable
is assigned. That is, they know the complete, larger set to which they
can apply the optimization -- without the 'final' to act as a hint.

So I doubt they actually fail to optimize unless you supply 'final'.

It's not impossible though -- some compiler writer could have decided
to use it as a user-hint as to what might be optimal. However, since
users are unaware of it -- it's not part of the language, and users
really don't know the tradeoffs -- they're complex and hard for even
compilers do to well -- this would be more of a misfeature, resulting
in a net slowdown over all the code.

As to 'final' and inner methods -- I am baffled why that's still in
the language. Guy Steele (the author of the Java Spec) very definitely
knows how to remove that restriction. It's not in compilers he wrote
for Lisp and Scheme. Actually, he knows more than one way. So I'm
puzzled why we have to do all these weird workarounds the compiler
could do for us.

As to whether this is a documented feature of Java -- definitely.

The situation with final fields is a bit different. For one thing,
those can be accessed via reflection, so the compiler won't really
know. There, 'final' can and does affect compilation, often including
inlining. I think it only happens within the class in question --
other classes might change between when your code is compiled and when
it runs. That could be handled by a clever classloader, but I'm not
aware of it being done. But it's the sort of thing dex might do.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Use of final for locals on Dalvik

2010-01-29 Thread Bob Kerns
Definitely good advice, if we're confusing 'field' and 'variable'. If
not, then you're stating a tautology, which is even better! :)

On Jan 29, 3:48 pm, Kevin Duffey andjar...@gmail.com wrote:
 you might use method declared variables to help with scope... if you know a
 variable is only used in the method, why declare public.. keep it in the
 method and let the method clean it up at the end.

 On Fri, Jan 29, 2010 at 3:32 PM, Jason Proctor 


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Use of final for locals on Dalvik

2010-01-29 Thread Bob Kerns
Yes, or given the background of the language designers, CPA. And the
compiler has to figure this out in order to give the error message --
and even in the error case, there are several trivial ways to
transform the code to be equivalent. (It's a mite more difficult to
make sure debuggers know what to do, but also a long-solved problem).

So I'm baffled why we are required to write 'final' in this one case.
At first, when Java first came out, I assumed it was a time-to-market
thing.

It's not fatal -- it just means more chances to screw up when we
humans do the compiler's work for it.

On Jan 29, 5:10 pm, fadden fad...@android.com wrote:
 Variables that don't change can be given special treatment.  However,
 any compiler worthy of the name will figure this out automatically --
 it's one of the things that falls out of SSA form (see 
 e.g.http://en.wikipedia.org/wiki/Static_single_assignment_form).
 Explicitly labeling a local variable as final isn't necessary,
 because any compiler sophisticated enough to make use of that fact
 should also be sophisticated enough to figure it out for itself.

 Using final on classes, methods, and fields is more interesting.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Desarrollar para diferentes modelos

2010-01-29 Thread Bob Kerns
Excuse me for responding in English -- I'm betting you'll understand
my English better than my Spanish! Besides, others may be able to
offer suggestions.

(Basically, he's got an app that works on the G1, but on a Nexus One
(which he doesn't have), it fails, when changing views (or changing
orientation -- unclear on the intended meaning), and wants to know a
solution or other options).

A lot depends on why your application is failing. The big reasons I
can think of:
1) Android 2.1
2) Size/aspect ratio changes when you change your orientation (is that
what you mean by  y cuando cambia a otra vista?).
3) Screen size differences (the more general case of #2).

Another possibility is that you (or your customers) have run into a
problem that I've run into -- that the Nexus One launcher is prone to
out-of-memory crashes, especially if you force it to switch to
landscape mode, by having it visible in the background when your app
switches. Not really your bug in that case...

Anway, que otro opción tiene usted? Well, if it's a matter of OS
version or screen size / orientation, you should be able to reproduce
it under the emulator. Otherwise, I'd suggest asking another developer
with a Nexus One to get you a stack trace. But for most purposes, you
should be able to reproduce it in the emulator.

(If that's not clear, and Google Translate doesn't help, let me know
and I can try it en Español.)

On Jan 29, 5:35 pm, Jonathan Alonso jonapin...@gmail.com wrote:
 Hola a todos, le comento lo que me esta sucediendo en este momento,
 hice una aplicacion para los moviles G1, usa un timer ya que muestra
 un reloj, en este telefono me funciona a la perfeccion, se probo esta
 misma aplicacion en un Nexus One, y cuando cambia a otra vista, la
 aplicacion falla, no se cual sera el problema por que no tengo el
 nexus one para probar, me comentaron que ahi una forma de programar
 que funcione para todos los moviles, alguien conoce esta solucion?, o
 que otra opcion tengo

 Gracias

 Jonathan Alonso

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to stop playing music or sound of other application

2010-01-29 Thread Bob Kerns
In addition to the other comments -- if you just need to make the
media quiet -- you can temporarily turn the volume down for the
AudioManager.STREAM_MUSIC audio stream type. See
AudioManager.setVolumeStream().

This won't stop playback, but at least it will be silent playback.

On Jan 28, 8:22 am, Alam irshad...@gmail.com wrote:
 Hi,

 I want to know that can we stop playing sound or music of other
 application which actually plays the music from our application?

 Something like get the handle of MusicPlayer or AudioManager in our
 application and using this handle stop the currently playing sound.

 Please share some information on this.

 Regards
 Alam

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: IP Adress of android device

2010-01-28 Thread Bob Kerns
The IP addresses will be whatever the DHCP server on that subnet says
they should be. Often, the DHCP server role will be handled by your
router to the internet, but in a corporate environment, things may be
more complicated.

When a device connects to an IP network, it usually broadcasts who am
I?, and a DHCP server then tells it basic stuff like it's IP address.
This can be a pre-allocated address assigned to that device, or it can
be allocated dynamically from a pool of addresses.

I would guess you don't want to require pre-assignment, because,
typically, users would not be able to do so.

So how do the devices discover each other's IP addresses?

Well, there are a lot of options there. You can have each user type in
the IP address. You can register the device dynamically under a DNS
server, and have them type in the DNS name. You can use a service
discovery protocol (like Apple's Bonjour service). You can roll your
own using broadcast or multicast messages. You can register each
device on a server -- and then even talk to each other THROUGH the
server. This last has the great advantage that it allows two devices
on incompatible networks to communicate. (I presume the disadvantages
are obvious).

About the only thing I can say for sure is -- you're going to need to
know more about networking than you do today. It's learnable, and
there are resources out there to help. Most of what you need to know
is information that is not specific to the Android platform, so there
will be a wide array of sources of information. Google searches are
you friend.

You can probably accomplish everything you're trying to do entirely
with the classes in the java.net package. So you can develop your
approach in any connected Java environment.

On Jan 28, 1:56 am, Tony jituo...@gmail.com wrote:
 Hello ,all!

 If I connect  two android pwer  real-devices   to  a LAN  through wifi,
 then what  are their  IP adress???

 How can then find each other by IP address???

 are  their IP address 192.168.0.* ??

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android Emulator Stop Working in Eclipse

2010-01-27 Thread Bob Kerns
This looks perfectly normal and correct to me. The application is
already up-to-date on the device, and you already have the activity
running, so it just brings it to the front.

If you kill the task, using some task manager app, or rebooting your
phone, or just wait for Android to get rid of the task, and then try
it, it will then create a completely new activity.

But what I usually do is even simpler -- I insert a space somewhere in
a source file, save it, delete the space, and save again. Now it
doesn't see the version on the phone as up-to-date, and it will
redeploy, and then, necessarily, start a fresh activity.

While sometimes I wish the debugger would automatically restart the
task, that's not what happens when the user invokes your program in
this circumstance, so I don't think it would be a good idea as a
default action for a debugger. But it does occasionally confuse me, if
I'm expecting a breakpoint in an onCreate(Bundle) method to trigger.

On Jan 26, 7:16 pm, apregister08 apregiste...@gmail.com wrote:
 I am not sure what's happening but whenever I try to run the project,
 I get the following in the console:

 [2010-01-26 22:13:37 - TestProject1.0]--
 [2010-01-26 22:13:37 - TestProject1.0]Android Launch!
 [2010-01-26 22:13:37 - TestProject1.0]adb is running normally.
 [2010-01-26 22:13:37 - TestProject1.0]Performing com.testproject.Home
 activity launch
 [2010-01-26 22:13:39 - TestProject1.0]Application already deployed. No
 need to reinstall.
 [2010-01-26 22:13:39 - TestProject1.0]Starting activity
 com.greekrow.Home on device
 [2010-01-26 22:13:40 - TestProject1.0]ActivityManager: Starting:
 Intent { cmp=com.testproject/.Home }
 [2010-01-26 22:13:40 - TestProject1.0]ActivityManager: Warning:
 Activity not started, its current task has been brought to the front

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: density setting for aspect ration long screens

2010-01-26 Thread Bob Kerns
Atif, the various layout classes are *intended* to be a generic
solution, making minor adjustments for minor changes.

Using different resource folders is intended for making major
readjustments to layout. If you design a good layout with the layout
classes, you may not need them at all!

Generally, separate resource folders are useful for when a particular
layout strategy simply breaks down when pushed too far. For example,
rotating to landscape may make the screen simply too short for one
strategy, but if you move a couple of things to the side, you're OK.

If you need to distinguish between 480x800 and 480x854 -- and
especially if it's 480x854 that has the problem -- then I would
strongly suggest that you take a close look at your layout strategies.
LinearLayout with some expandable padding elements, TableLayout, or
the use of a 9-patch instead of a fixed background graphic.

Android offers a lot of facilities for handling of layout differences.
I don't think they're always as easy to use and predictable as they
ought to be, but they're pretty rich and functional, none-the-less.

So if they aren't doing the job, and you're having to rely on
differentiating your layouts at the level of 480x800 vs 480x854, then
to get any help, you're going to need to precisely identify what
problem the layouts aren't handling for you automatically, and why.

My guess, however, would be that you're either:
1) Trying to put too much stuff onto each screen. This makes your
layouts very brittle, and usually makes the result seem very
cluttered for the user, as well. There can be times when this is
appropriate -- for example, when the goal is a single-screen status
monitoring display. But generally, the strategy here should be to move
to less-cluttered, more tightly focused screens.

2) Trying to keep too tight a control on the layouts, rather than
defining a logical layout strategy, and allowing the system to make
the layout choices for you, within defined ranges. That does take both
a lot of understanding, and a lot of testing to identify the usable
limits of each layout strategy. But the result is that you won't have
to specify a new layout to handle some new device that adds another 54
pixels along one edge.

On Jan 26, 5:10 am, Atif Gulzar atif.gul...@gmail.com wrote:
 Thanks Dianne Hackborn,

 But then how one can set its single layout to work on all aspect rations. To
 solve the problem for long screens; I created a new folder layout-long and
 adjusted my lauouts. Wel it solved the problem for 480x800 but not for
 480x854. Any generic solution ??

 --
 Best Regards,
 Atif Gulzar

 I  Unicode, ɹɐzlnƃ ɟıʇɐ

 On Mon, Jan 25, 2010 at 11:06 PM, Dianne Hackborn hack...@android.comwrote:



  Density and aspect ratio are completely unrelated.  Density is the size of
  the pixels, and we currently only support square pixels (which is what all
  current devices have as far as I know).  The aspect ratio is determined by
  the number of pixels in th x and y dimensions, regardless of their density.

  On Mon, Jan 25, 2010 at 7:04 AM, Atif Gulzar atif.gul...@gmail.comwrote:

  We can set the pixel values in custom views by multiplying them with

  this.getResources().getDisplayMetrics().density;

  This is ok when the screen aspect ratio is normal means not long

  But how can we set the pixels along Y-axis when the aspect ration is long.

  --
  Best Regards,
  Atif Gulzar

  I  Unicode, ɹɐzlnƃ ɟıʇɐ

   --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs
   cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com

  Note: please don't send private questions to me, as I don't have time to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see and
  answer them.

   --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


<    4   5   6   7   8   9