[android-developers] Re: AsyncTask and screen rotation

2010-09-12 Thread Eric Mill
Why wouldn't that work if it's a non-static inner class? Dave's
solution is basically what I do, with the AsyncTask being a private
(non-static) inner class of the Activity that uses it.  Store it
across screen flips, and then if it's present in onCreate, feed it the
new context.

-- Eric

On Sep 12, 1:02 pm, Mark Murphy mmur...@commonsware.com wrote:
 That should work, so long as MyAsyncTask is a static inner class or a
 regular standalone public class (not a non-static inner class). See:

 http://github.com/commonsguy/cw-android/tree/master/Rotation/Rotation...



 On Sun, Sep 12, 2010 at 12:47 PM, davemac davemac...@gmail.com wrote:
  So we could use something as simple as the following?

    �...@override
     public Object onRetainNonConfigurationInstance() {
         return myAsyncTask;
     }

  And in onCreate():

         if( (myAsyncTask =
  (MyAsyncTask)getLastNonConfigurationInstance()) != null)
                 myAsyncTask.setContext(this);  // Give my AsyncTask the new
  Activity reference

  I added a setContext() method to MyAsyncTask which resets a local
  member to be used in the on* callbacks to do UI work. I made
  MyAsyncTask a completely separate class from my Activity class, and
  the constructor requires a Context. This seems to work, and it seems
  pretty easy to do. I realize that an AsyncTask has no chance of being
  restarted the way a Service does if it comes to an untimely death. But
  from the comments in this thread, I'm assuming that my Activity will
  get a valid reference to the AsyncTask when it is restarted by a
  Configuration Change. Yes?

  - dave

  On Sep 10, 1:05 pm, Dianne Hackborn hack...@android.com wrote:
  On Fri, Sep 10, 2010 at 9:53 AM, Maps.Huge.Info (Maps API Guru) 

  cor...@gmail.com wrote:
   What if that AsyncTask is downloading a file? Interrupting it,
   regardless of how nicely done, would be a bad thing wouldn't it?

  You don't need to interrupt it.  See Mark's option 2.  Just don't have it
  tied to a specific activity instance.

  If you want to have it associated logically with the activity, you can use
  onRetainNonInstanceState() to transfer it between instances.  (Though this
  is intended as an optimization, and if you rely on this then you likely
  won't get the proper semantics in other cases -- for example if the user
  leaves your app and returns to it later it could easily get killed while in
  the background and thus lose the active download.  In fact you would also
  have this same problem if you use android:configChanges for many of the 
  same
  reasons.)

  --
  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.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

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

 Android Training...At Your Office:http://commonsware.com/training

-- 
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 screen rotation

2010-09-10 Thread Eric Mill
I eventually made my own best practices for AsyncTasks that survive
screen flips and can even maintain progress dialogs if needed, and
it's all very robust and reasonably clean - but it took a lot of
iteration and investigation.

Storing an AsyncTask is not hard if you understand what is
happening, but for people just getting into the Android system,
understanding that screen flips destroy Activity references and create
new ones is not trivial.  It's actually really confusing and setting
it all up right is pretty delicate.

At my workplace, I'm porting an Android app over to the Windows Phone
7 platform. Many things about WP7 development are new, some are
frustrating, but there's one notably easy thing about it, which is
this exact problem. Their WebClient class automatically handles
network calls in a background thread, and you can give it a lambda or
named function as a callback to run on the UI thread once it's done.
Survives screen flips just fine, no worries about it being killed. It
Just Works(tm).

I understand that Android is a very different system than WP/
Silverlight, with different considerations that elevate the complexity
of managing all the different fedeated components of an application -
but don't write off managing AsyncTasks as not hard. It's very hard,
and other systems make it look glaringly so.

-- Eric

On Sep 10, 2:33 pm, Dimitris dnkou...@gmail.com wrote:
 Wow thank you, I've been finally waiting for some clarification
 regarding how safe it is when updating the instance of the Activity in
 a task.

 This should be well documented and perhaps an example should be
 provided.

 On Sep 10, 10:13 am, Mark Murphy mmur...@commonsware.com wrote:



  On Fri, Sep 10, 2010 at 1:08 PM, Dianne Hackborn hack...@android.com 
  wrote:
   Yes it is.  If it isn't documented, I'll make sure it is: we guarantee 
   that
   no messages will be processed between onRetainNonConfigurationInstance() 
   to
   the following onCreate().

  Oh, that is absolutely fantastic to hear.

  I'd think it should be documented either on that method or here:

 http://developer.android.com/guide/topics/resources/runtime-changes.html

  Thankyouthankyouthankyou! :-)

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

  Android Training in London:http://skillsmatter.com/go/os-mobile-server

-- 
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's cancel method - possible bug

2010-07-27 Thread Eric Mill
Hi Romain,

Thanks for the response.  What was the general effect of the race
condition? This might explain why I think that I see this behavior
consistently when debugging (when everything is slow) and
inconsistently otherwise (when things are fast, but I can't verify
what's happening).

Is that post- inclusive or exclusive - do you mean it was fixed
after Froyo's release, and will appear in Gingerbread, or that it was
fixed for Froyo? I am using Froyo to test.

Thanks,
Eric

On Jul 27, 1:14 am, Romain Guy romain...@android.com wrote:
 There was a race in the cancel() code that we fixed post-froyo.

 On Mon, Jul 26, 2010 at 10:13 PM, Frank Weiss fewe...@gmail.com wrote:
  It doesn't make sense to me why you're trying to cancel the AsyncTask
  in the Activity's onDestroy method. That seems too late in the
  lifecycle.

  --
  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


[android-developers] Re: AsyncTask's cancel method - possible bug

2010-07-27 Thread Eric Mill
Just making sure. :)

On Jul 27, 12:22 pm, Romain Guy romain...@android.com wrote:
 Post-froyo  means after froyo, so not in froyo :)





 On Tue, Jul 27, 2010 at 5:53 AM, Eric Mill kproject...@gmail.com wrote:
  Hi Romain,

  Thanks for the response.  What was the general effect of the race
  condition? This might explain why I think that I see this behavior
  consistently when debugging (when everything is slow) and
  inconsistently otherwise (when things are fast, but I can't verify
  what's happening).

  Is that post- inclusive or exclusive - do you mean it was fixed
  after Froyo's release, and will appear in Gingerbread, or that it was
  fixed for Froyo? I am using Froyo to test.

  Thanks,
  Eric

  On Jul 27, 1:14 am, Romain Guy romain...@android.com wrote:
  There was a race in the cancel() code that we fixed post-froyo.

  On Mon, Jul 26, 2010 at 10:13 PM, Frank Weiss fewe...@gmail.com wrote:
   It doesn't make sense to me why you're trying to cancel the AsyncTask
   in the Activity's onDestroy method. That seems too late in the
   lifecycle.

   --
   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

 --
 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] AsyncTask's cancel method - possible bug

2010-07-26 Thread Eric Mill
As far as I can tell, AsyncTask's cancel method doesn't work as
advertised.  I can't tell whether this is a bug, or me not
understanding AsyncTask's cancel() method.  I'm asking here instead of
StackOverflow because I suspect it's a bug.

I understand from past discussions here that cancel() isn't meant to
actually kill a thread (though the description of the
mayInterruptIfRunning flag sure implies it is). But I'm also checking
for isCancelled() (which is returning false), and trying to use the
onCancelled callback (which isn't getting called), to no avail.

My situation is that I have a (short-running, one small network call)
AsyncTask that begins in my Activity's onCreate. If the user backs out
of the screen before it finishes though, I need to either cancel the
AsyncTask entirely, or at least make sure its onPostExecute doesn't do
any meaningful work.

In my activity's onDestroy handler, I call cancel() on the task, and
then inside the task I have an onCancelled handler that sets a
boolean.  In my onPostExecute handler, I check isCancelled(), and I
also check to see whether the boolean has been set from onCancelled,
and neither are.

I'm using the debugger, and the order of operations is:

1) onDestroy(), calls task.cancel()
2) task's onPostExecute runs, isCancelled() returns false, so I have
no conditional to stop the flow

and that's it. onCancelled never runs.

What am I doing wrong here? I can't find any way to tell my task not
to run its work in onPostExecute.

-- 
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: TabHost NullPointerException

2009-11-09 Thread Eric Mill
You might want to check out this thread:
http://groups.google.co.jp/group/android-developers/browse_thread/thread/1cfcbfd3fb754b64

I'm having the same problem right now.  I'll let you know if I find a
solution.

-- Eric

On Oct 28, 5:12 pm, Lee labor...@gmail.com wrote:
 I'm getting a null pointer exception in TabHost.java whenever I start
 my TabActivity by pressing the enter key or pressing the trackball on
 the button that starts the activity.

 So I've got a button called start that in its onClick handler will
 start a TabActivity.  Tapping on the button starts the TabActivity
 fine, however when I press the button using the enter key or the
 trackball I get the following trap.

 I've seen another thread related to this 
 athttp://groups.google.com/group/android-developers/browse_thread/threa...

 My stack trace is below:

 10-28 22:10:18.849: ERROR/AndroidRuntime(1078): Uncaught handler:
 thread main exiting due to uncaught exception
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):
 java.lang.NullPointerException
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 android.widget.TabHost.onTouchModeChanged(TabHost.java:179)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 android.view.ViewTreeObserver.dispatchOnTouchModeChanged
 (ViewTreeObserver.java:591)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 android.view.ViewRoot.ensureTouchModeLocally(ViewRoot.java:1877)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 android.view.ViewRoot.performTraversals(ViewRoot.java:715)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 android.view.ViewRoot.handleMessage(ViewRoot.java:1613)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 android.os.Handler.dispatchMessage(Handler.java:99)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 android.os.Looper.loop(Looper.java:123)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 android.app.ActivityThread.main(ActivityThread.java:4203)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 java.lang.reflect.Method.invokeNative(Native Method)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 java.lang.reflect.Method.invoke(Method.java:521)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
 (ZygoteInit.java:791)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
 10-28 22:10:18.849: ERROR/AndroidRuntime(1078):     at
 dalvik.system.NativeStart.main(Native Method)

 But with no word from the Android team.  Is this a framework issue?

 Thanks
 Lee

-- 
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: Trap in TabHost when AsyncTask delays setContentView at activity startup

2009-11-09 Thread Eric Mill
Would you mind elaborating a bit, and showing some code? I am having
the exact same problem, and am in the exact same situation, but I
can't follow your solutions.

-- Eric

On 11月4日, 午後9:34, Lee Laborczfalvi labor...@gmail.com wrote:
 Thanks for the tip on this.  That fixes my issue.

 What I've done is inflate the layout, call setContentView with that
 view, add my tabs and set the visibility of the entire view to
 View.GONE.

 In my onPostExecute I call setContentView(View.VISIBLE) to display the 
 TabHost.

 Thanks again,
 Lee



 On Wed, Nov 4, 2009 at 8:58 PM, Lee Laborczfalvi labor...@gmail.com wrote:
  I'll give this a go and let you know how it works.

  Thanks for the tip.
  Lee

  On Wed, Nov 4, 2009 at 8:27 PM, Jeff Sharkey jshar...@android.com wrote:
  Instead of delaying the setContentView() call, can you inflate that
  layout and set its visibility to View.GONE temporarily until the
  actual content arrives?

  j

  On Tue, Nov 3, 2009 at 8:52 PM, Lee Laborczfalvi labor...@gmail.com 
  wrote:
  I've got a tab host activity started from a home screen shortcut.
  When my application starts it downloads information from a server
  using an AsyncTask. In the onPostExecute method of the AsyncTask I
  call setContentView to display the TabHost.

  When I start the homescreen shortcut by tapping on the shortcut using
  my finger everything works as expected, I download the information
  from the server and display the TabHost with the information in the
  tabs.

  However starting the application by navigating to the shortcut with
  the mouse wheel and then clicking on the shortcut with the mouse wheel
  leads to a trap in the framework code as soon as my application
  starts.  The stack trace is below:

  11-04 15:45:40.113: ERROR/AndroidRuntime(3360): Uncaught handler:
  thread main exiting due to uncaught exception
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360): 
  java.lang.NullPointerException
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  android.widget.TabHost.onTouchModeChanged(TabHost.java:179)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  android.view.ViewTreeObserver.dispatchOnTouchModeChanged(ViewTreeObserver.j
   ava:591)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  android.view.ViewRoot.ensureTouchModeLocally(ViewRoot.java:1877)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  android.view.ViewRoot.performTraversals(ViewRoot.java:715)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  android.view.ViewRoot.handleMessage(ViewRoot.java:1613)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  android.os.Handler.dispatchMessage(Handler.java:99)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  android.os.Looper.loop(Looper.java:123)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  android.app.ActivityThread.main(ActivityThread.java:4203)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  java.lang.reflect.Method.invokeNative(Native Method)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  java.lang.reflect.Method.invoke(Method.java:521)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:
   791)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
  11-04 15:45:40.213: ERROR/AndroidRuntime(3360):     at
  dalvik.system.NativeStart.main(Native Method)

  Looking at the code for the TabHost class I see the following code at
  the point where the trap occurs

     public void onTouchModeChanged(boolean isInTouchMode) {
         if (!isInTouchMode) {
             // leaving touch mode.. if nothing has focus, let's give it to
             // the indicator of the current tab
  TRAP ON THIS LINE              if (!mCurrentView.hasFocus() ||
  mCurrentView.isFocused()) {

  mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus();
             }
         }
     }

  This looks like a simple fix since mCurrentView is null at the time
  that this method is called - can this issue be addressed? Does anyone
  know of any workarounds?

  Thanks
  Lee

  --
  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

  --
  Jeff Sharkey
  jshar...@android.com

  --
  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 

[android-developers] Re: BaseAdapter.getView()’s c onvertView parameter

2009-10-09 Thread Eric Mill

AH, I GET IT NOW!

I was having awful troubles with an ArrayAdapter recycling random
views to me, in a list which used different kinds of views.  The
errors were maddening until I figured out what was going on, using
that part of your book.  It's absolutely insane...until you understand
why they do it, and then it makes (some) sense. Phew.

-- Eric

On Sep 19, 4:34 am, Mark Murphy mmur...@commonsware.com wrote:
 Carmen Delessio wrote:
  Watch this video:
 http://code.google.com/events/io/sessions/TurboChargeUiAndroidFast.html
  Check Mark Murphy's bookhttp://commonsware.com/Android/index.html

  Read several posts here:
 http://www.androidguys.com/2008/07/14/fancy-listviews-part-one/

  Short answer:
  ConvertView is a previously returned view. You can reuse it without
  having to make a view from scratch.
  So you can avoid costly operations.  So you are correct about optimization.
  See the holder pattern.

 Thanks for the shout-out!

 Since those blog posts are as old as the hills (in Android years), I
 make the chapter in my original book that covers this topic available as
 a free excerpt:

 http://commonsware.com/Android/excerpt.pdf

 For short lists, convertView is not a big deal. For long lists, it's
 rather important to avoid creating ten tons of (memory) garbage.

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

 _Android Programming Tutorials_ Version 1.0 Available!
--~--~-~--~~~---~--~~
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: Best practices for handling passwords/keys in open source projects?

2009-09-16 Thread Eric Mill

I figured out the right answer.  In the Eclipse environment, the res/
values folder (unlike the other folders in res/) can have your own
arbitrary files in it.  I created a file called keys.xml, with
string elements.  The resources in it, though, are available under
R.string, *not* R.keys.

I git ignore'd res/values/keys.xml, created a keys.xml.example file
and put it in the root of my repo (can't put it in res/values, causes
project errors), and added an instruction to the README to copy and
rename keys.xml.example, and to fill in one's own values.

-- Eric

On Sep 10, 12:05 pm, Eric Mill kproject...@gmail.com wrote:
 I'm not using Ant, and I'm not familiar with it at all.  I'm using the
 regular Eclipse + SDK approach, and I'd like to stick with that.  This
 API key also isn't used in a MapView (it's not for the Google Maps
 API), so I need a general sort of solution.

 Isn't there any way, using the Eclipse Android Toolkit, to make some
 sort of keys.xml file and have it available in like, R.keys or the
 like?  It doesn't have to be that, either - as long as I can have all
 of the private strings in their own file, it works for me. I could
 just include a completely flat file and have the app read it in
 manually during operation, but that seems like the wrong way to do it.

 -- Eric

 On Sep 9, 4:09 pm, Mark Murphy mmur...@commonsware.com wrote:

  Eric Mill wrote:
   In my app, I'm taking advantage of a web-based API (the Sunlight Labs
   API) that requires an API Key.  The project is also open source,
   hosted on Github. I want to avoid committing my API key into the
   codebase.

   I'd be fine with creating some other .xml file of special string
   values, and git-ignoring that file (while providing a .xml.example
   file to copy into its place), but I don't know the best way of doing
   that with the Android SDK.

   Any suggestions?

  Total brainstorm, never tried this, your kilometerage may vary, etc. It
  also assumes you're using Ant...

  Step #1: Put the layout file containing the MapView element that needs
  the API key somewhere other than res/layout/ (e.g., make a
  layout-template/ directory and put it there).

  Step #2: Create an Ant target that reads in a property file and uses
  copy and replaceregexp tasks to paste the API key out of the
  property file into a copy of the layout you make in the proper spot
  (e.g., copy from layout-template/ to res/layout/ and then paste in the key).

  Step #3: git-ignore the post-API-key edition of the layout file and your
  property file.

  Step #4: Possibly have your Ant target turn around and call some other
  target (e.g., the debug target).

  Side benefit of this: you can have two targets and two property files,
  one for debug and one for production.

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

  _The Busy Coders' Guide to *Advanced* Android Development_ In Print!


--~--~-~--~~~---~--~~
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: Best practices for handling passwords/keys in open source projects?

2009-09-10 Thread Eric Mill

I'm not using Ant, and I'm not familiar with it at all.  I'm using the
regular Eclipse + SDK approach, and I'd like to stick with that.  This
API key also isn't used in a MapView (it's not for the Google Maps
API), so I need a general sort of solution.

Isn't there any way, using the Eclipse Android Toolkit, to make some
sort of keys.xml file and have it available in like, R.keys or the
like?  It doesn't have to be that, either - as long as I can have all
of the private strings in their own file, it works for me. I could
just include a completely flat file and have the app read it in
manually during operation, but that seems like the wrong way to do it.

-- Eric

On Sep 9, 4:09 pm, Mark Murphy mmur...@commonsware.com wrote:
 Eric Mill wrote:
  In my app, I'm taking advantage of a web-based API (the Sunlight Labs
  API) that requires an API Key.  The project is also open source,
  hosted on Github. I want to avoid committing my API key into the
  codebase.

  I'd be fine with creating some other .xml file of special string
  values, and git-ignoring that file (while providing a .xml.example
  file to copy into its place), but I don't know the best way of doing
  that with the Android SDK.

  Any suggestions?

 Total brainstorm, never tried this, your kilometerage may vary, etc. It
 also assumes you're using Ant...

 Step #1: Put the layout file containing the MapView element that needs
 the API key somewhere other than res/layout/ (e.g., make a
 layout-template/ directory and put it there).

 Step #2: Create an Ant target that reads in a property file and uses
 copy and replaceregexp tasks to paste the API key out of the
 property file into a copy of the layout you make in the proper spot
 (e.g., copy from layout-template/ to res/layout/ and then paste in the key).

 Step #3: git-ignore the post-API-key edition of the layout file and your
 property file.

 Step #4: Possibly have your Ant target turn around and call some other
 target (e.g., the debug target).

 Side benefit of this: you can have two targets and two property files,
 one for debug and one for production.

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

 _The Busy Coders' Guide to *Advanced* Android Development_ In Print!
--~--~-~--~~~---~--~~
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] Best practices for handling passwords/keys in open source projects?

2009-09-09 Thread Eric Mill

In my app, I'm taking advantage of a web-based API (the Sunlight Labs
API) that requires an API Key.  The project is also open source,
hosted on Github. I want to avoid committing my API key into the
codebase.

I'd be fine with creating some other .xml file of special string
values, and git-ignoring that file (while providing a .xml.example
file to copy into its place), but I don't know the best way of doing
that with the Android SDK.

Any suggestions?

-- Eric
--~--~-~--~~~---~--~~
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: Eclipse and Junit

2009-02-24 Thread Eric Mill

I am having similar problems, and have no idea how to resolve it. So,
er, +1.

-- Eric

On Feb 22, 2:17 am, Ilan ilan.ca...@gmail.com wrote:
 Hi,

 I've tried to setup eclipse to run junit after reading the following
 instructionshttp://developer.android.com/guide/appendix/faq/troubleshooting.html#
 My testrunner is setup in a different project then the classes I'm
 testing.

 When I'm executing the test I'm getting NoClassDefFoundError when I'm
 trying to call any Android class. So I tried to run the suite from the
 tested project which didn't help.

 Am I missing something, of is JUnit isn't really working directly from
 Eclipse using the Android plugin?
--~--~-~--~~~---~--~~
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: Market paid-for apps

2008-12-31 Thread Eric Mill

Yeah, I got that too.  It's wonderful news, awesome on Google!

-- Eric

On Wed, Dec 31, 2008 at 11:51 AM, Al Sutton a...@funkyandroid.com wrote:

 Did anyone else get the email saying that initially only developers
 operating in the US and UK will be allowed to sell apps in Market?

 The email says this will be followed by German, Austria, and the
 Netherlands, then by France, Italy and Spain, and the plans for other
 countries will be announced at the end of Q1 2009.

 So from this I think it's safe to deduce that if you're not in those 8
 countries you won't be able to sell apps via Market until after Q1 2009.

 Al.
 http://andappstore.com/

 --
 ==
 Funky Android Limited is registered in England  Wales with the
 company number  6741909. The registered head office is Kemp House,
 152-160 City Road, London,  EC1V 2NX, UK.

 The views expressed in this email are those of the author and not
 necessarily those of Funky Android Limited, it's associates, or it's
 subsidiaries.


 


--~--~-~--~~~---~--~~
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: HTTP compression lost when using 3G connection

2008-12-02 Thread Eric Mill

There's an issue where downloading small files (such as small 20Kish
apps) get corrupted over 3G, but not wifi, that this is certainly
related to.  If you've ever downloaded an app, and it says that it
wants to replace Android System, that's the bug, and I now blame T-
Mobile (as opposed to Google) for it.

-- Eric

On Nov 25, 1:58 pm, Jean-Baptiste Queru [EMAIL PROTECTED] wrote:
 It's actually not uncommon in the cell world to turn off compression
 on the public Internet, so that the proxy can have an easier time
 looking at the data and processing it to send it over the air (where
 it is compressed), i.e. trading Internet bandwidth for some CPU time
 on the proxy.

 JBQ

 On Tue, Nov 25, 2008 at 10:53 AM, melody [EMAIL PROTECTED] wrote:

  Thanks. I ran the test in the emulator, and the http compression was
  kept.  So this does indeed seem to be a problem being caused by a
  proxy at T-Mobile.

  Not to be overly dramatic, but isn't this a pretty serious issue?  I
  would think that under 3G, T-Mobile would very much want us all to be
  using HTTP compression so that we don't flood their network.  Even on
  my home broadband connection, when I turn off http compression in my
  browser to do testing work, most websites load much more slowly,
  especially with the massive css/js files being transmitted these
  days.

  Something else that may or may not be related:
  I noticed that the T-Mobile proxy is also converting my http request
  to a HTTP 1.0 request, whereas I am actually trying to send a HTTP
  1.1 request.

  David Turner wrote:
  The best way to test this is try to run your test from the emulator, since
  the browser
  wouldn't then use an intermediate T-Mobile proxy.

  On Tue, Nov 25, 2008 at 12:27 AM, melody [EMAIL PROTECTED] wrote:

   I've been working on improving the speed of my application and noticed
   that when I turn off wifi and use the 3G connection, http requests no
   longer use http compression.

   Specifically, when using the 3G connection, the Accept-Encoding
   header (which I have set to gzip, deflate) are stripped off before
   the request arrives at my server.  I tested this with the HttpClient
   class, and with my own custom http client through java.net.Socket.

   I then also verified this using the native android web browser.  With
   wifi turned on, my server recieves a header Accept-Encoding: gzip.
   With wifi turned off, and using the 3G connection, my server does not
   receive that header.

   I initially thought this might be an intentional behavior as part of
   3G connections, but then I tested it with a 3G iphone (on ATT), and
   there was no such problem there.  So I'm guessing it's a problem
   specific to T-Mobile.  i wonder if there is some proxy that is
   intentionally stripping out this header.

   I'd appreciate any advice about this.  For an XML-based web service
   like mine where the response data has a high compression ratio, this
   behavior causes a significant speed hit.
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: G1 Linux

2008-12-02 Thread Eric Mill

This has been an awesome thread.

On Dec 1, 5:33 pm, Xavier Mathews [EMAIL PROTECTED] wrote:
 So that means the G1 Does!

 Xavier A. Mathews
 Student/Browser Specialist/Developer/Web-Master
 Google Group Client Based Tech Support Specialist
 Hazel Crest Illinois
 [EMAIL PROTECTED]@[EMAIL PROTECTED]
 Fear of a name, only increases fear of the thing itself.

 On Mon, Dec 1, 2008 at 4:31 PM, Jean-Baptiste Queru [EMAIL PROTECTED] wrote:

  Android is and has always been built on top of Linux.

  JBQ

  On Mon, Dec 1, 2008 at 2:30 PM, Xavier Live Tech.S
  [EMAIL PROTECTED] wrote:

   Will G1 be running Linux like Iphone anytime soon?
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to add menu item dynamically

2008-12-01 Thread Eric Mill

You could just have a piece of code that reads in the text file,
parses it into an array of items, and then loops through that array to
add the items to the menu.  It's not conceptually different than doing
it statically.  The XML inflate method isn't going to work for dynamic
data, so it'll have to happen in your code.

-- Eric

On Dec 1, 1:01 am, souvik [EMAIL PROTECTED] wrote:
 Hi,

 I want to add menu item dynamically.

 Instead of adding items like this mentioned below, how can I add item
 dynamically?
 items.add( item1 );
 items.add( item2 );

 I have a file a1.txt and the content of the file is like:
 a1.txt
 =
 1.Question1
 2.Question2
 3.Question3

 Now i want to read this a1.txt and add 1.Question1 ,2.Question2
 as menu item.

 Please provide some sample code.
 Thanks,
 Souvik
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Is there a hook to run code on device shutdown (power off)?

2008-11-21 Thread Eric Mill

Dianne, do you think this will be added to the API in the future?
Saving state on phone shutdown could be important for some apps.

-- Eric

On Nov 20, 9:12 pm, Jon Colverson [EMAIL PROTECTED] wrote:
 Eek. That makes things a bit more difficult. Thank you for the quick
 response, though!

 On Nov 20, 9:55 pm, Dianne Hackborn [EMAIL PROTECTED] wrote:



  Sorry, there is nothing available to find out when the device is being
  turned off.

  On Thu, Nov 20, 2008 at 5:37 AM, Jon Colverson [EMAIL PROTECTED] wrote:

   Hello.

   Part of the app I'm writing is a Service that does some work. If it
   hasn't finished when the user switches the device off I'd like to be
   able to save my state to a file and then restart the Service when the
   device starts up again.

   I can see how to start it up again (receive the ACTION_BOOT_COMPLETED
   Intent), but I can't figure out a way to run the saving code on
   shutdown. I was expecting my Service's onDestroy() to be called, but
   this doesn't seem to be the case.

   Thanks.

   --
   Jon

  --
  Dianne Hackborn
  Android framework engineer
  [EMAIL PROTECTED]

  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.

 --
 Jon
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Land Navigation Application development

2008-11-09 Thread Eric Mill

If you think many in the army would find it useful, I bet you could
find someone or some office who could hire someone to do it.

-- Eric

On Nov 8, 1:15 pm, Sam M [EMAIL PROTECTED] wrote:
 I'm a US Army Officer Cadet, not a developer.  However, I've seen
 things like the Radar application and know that you can do amazing
 things with GPS functionality.

 Part of our training in the Army requires us to do land navigation,
 where we use 8 digit grid coordinates (e.g. EG12345678) to navigate
 between two points using a distance (e.g. 1650 meters) and direction
 in degrees (e.g. 273*).

 It would be incredibly useful is someone could develop an application
 in which I could enter a distance and direction (e.g 1650 meters at
 273*) that would give me the range remaining and notify me when I'm
 drifting off azimuth (ideally establishing a tolerance that notifies
 me when my azimuth variation would result in my being more than 15
 meters from my target destination).  Perhaps the application could
 even generate and store the map location that's specified by the
 distance and direction and automatically recalculate a new distance
 and direction in the event that I become lost or disoriented or need
 to navigate to a new waypoint.

 Please let me know if you could develop such an application!  I know
 that thousands of cadets and soldiers would find this application
 incredibly useful!
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Capture Call Audio

2008-11-08 Thread Eric Mill

So, is there a way to get the audio after the call?  Surely there must
be some way to use the G1 to record one's phone calls.

-- Eric

On Nov 7, 2:34 pm, Dave [EMAIL PROTECTED] wrote:
 Downlink audio is not routed to the application processor on the G1,
 so there is no way to capture in-call audio.

 On Nov 6, 7:31 pm, Sreeji [EMAIL PROTECTED] wrote:

  Hi,

  Any one tried capturing Audio after accepting the call, is there a way
  to use the PhoneApp class to do this?

  -Sreeji
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Reviews in android market

2008-11-04 Thread Eric Mill

It would be neat to make an unofficial website that uses that API to
make an identical looking and functioning frontend.  Now I just need
to know the API...maybe I can Wireshark my G1's packets...

-- Eric

On Nov 3, 2:25 am, Al Sutton [EMAIL PROTECTED] wrote:
 My guess would be that the market app is displaying the data from an API
 call to a server, so unless you know how to get call the API and
 interpret the data you're not going to have any joy.

 Al.



 Shane Isbell wrote:

  On Sun, Nov 2, 2008 at 4:14 PM, Eric Mill [EMAIL PROTECTED]
  mailto:[EMAIL PROTECTED] wrote:

      I share Nate's interest -- I have a G1, but I'd like to just browse
      the Market in Firefox for a while sometimes.  Where's the endpoint,
      and what user agent string do I have to spoof? :)

  For all we know, the Android Market could only be accessible through a
  private IP inside of T-Mobile's network. That's what I would do if I
  were them.

  Shane

 --
 Al Sutton

 W:www.alsutton.com
 B: alsutton.wordpress.com
 T: twitter.com/alsutton
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Reviews in android market

2008-11-02 Thread Eric Mill

I share Nate's interest -- I have a G1, but I'd like to just browse
the Market in Firefox for a while sometimes.  Where's the endpoint,
and what user agent string do I have to spoof? :)

-- Eric

On Oct 27, 6:03 pm, Nate Sanden [EMAIL PROTECTED] wrote:
 It says my app has 17 reviews but I can't read them from the website. Please
 add that functionality soon. I don't have a G1 and don't plan on getting one
 for the time being.
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: sending data from one program to another

2008-10-21 Thread Eric Mill

This is a good question.  Is there a standard way for programs to send
messages to each other?  Can they touch each others' SQLite databases,
at least?

-- Eric

On Oct 19, 5:00 am, roshan [EMAIL PROTECTED] wrote:
 I wanna know a possible way of sending data from one android
 application to another. but not as sms s. UDP is quite i achieved. i
 preffer TCP. But couldn't go ahead. please help me with this.

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---