[android-developers] Re: Eclair install choked with errors about locks and died horribly leaving corrupted install

2009-10-28 Thread Streets Of Boston

I had the same problem.
I decided to just unzip the contents of the SDK package - tools
directory only; you'll find the others are empty - into the the tools
directory of the Android SDKs used by Eclipse.

This did the trick for Eclipse. Although, i still see that weird
message when opening android.bat (see my earlier posts).

On Oct 28, 12:23 pm, Armond Avanes armond...@yahoo.com wrote:
 Xavier,

 I've downloaded the SDK package (v3) and have run both SDK Setup.exe and
 android.bat (I'm on WinXP). But still the same problem... There are not
 any open command-lines (but the one running the SDK tool itself) or
 explorers!

 Can't it be a bug?

 Regards,
 Armond



  -Original Message-
  From: android-developers@googlegroups.com [mailto:android-
  develop...@googlegroups.com] On Behalf Of Xavier Ducrohet
  Sent: Wednesday, October 28, 2009 4:19 AM
  To: android-developers@googlegroups.com
  Subject: [android-developers] Re: Eclair install choked with errors about
  locks and died horribly leaving corrupted install

  That's correct.

  Windows users who are not using eclipse, we recommend that you
  download the SDK package at
 http://developer.android.com/sdk/index.html

  This is basically only the tools folder, but it also includes a SDK
  Setup.exe at the top SDK folder which calls android.bat in update
  mode. This should fix the lock problem.

  Xav

  On Tue, Oct 27, 2009 at 5:44 PM, Streets Of Boston
  flyingdutc...@gmail.com wrote:

   I have the same issue.

   I started android.bat from the command prompt.
   Since android.bat is in the directory that is reported to be locked,
   my command prompt is holding a lock to it when starting
   android.bat not very handy...

   On Oct 27, 7:36 pm, Xavier Ducrohet x...@android.com wrote:
   Hi,

   the issue is with Windows putting locks on files/folders. For instance
   if you have a file explorer opened on the folder being updated (e.g.
   the docs folder), it'll prevent other programs from modifying the
   files/folders.

   If you have problem using it from eclipse you can always use
   SDK/tools/android.bat which provide you with the same UI.

   Which version of Eclipse are you using? I'll double-check that Eclipse
   doesn't open/lock some files in the documentation.

   Xav

   On Tue, Oct 27, 2009 at 2:31 PM, Jim Showalter

   jamesleeshowal...@gmail.com wrote:
Followed the instructions in
   http://developer.android.com/sdk/adding-components.htmlforadding 2.0
  as
components to an existing 1.6 SDK, from within Eclipse.

It didn't work. Not by a long shot. Instead, it got partway through
  and then
said that C:\android-sdk-windows-1.6_r1\
temp\DocPackage.new01 couldn't be copied because of a lock, and
  similarly
for PlatformPackage.new01.

It said to shut down running programs, but the only program running
  was
Eclipse, which was needed to do the upgrade.

The cancel button was disabled, and the close box didn't work.
  Shutting down
Eclipse killed it, but left C:\android-sdk-windows-1.6_r1 in a
  corrupted
state. Restarting Eclipse showed the Android projects with errors, no
  SDK,
and a disabled Android SDK and AVD Manager (which means no ability to
  rerun
the install).

Shutting down Eclipse, renaming the corrupted SDK directory,
  unzipping 1.6
again into C:, and restarting Eclipse made it as if nothing had ever
happened, which is good. But it is not possible to complete the
  install from
Eclipse, which is bad.

The dialog says:

Failed to rename directory
C:\android-sdk-windows-1.6_r1\temp\DocPackage.new01 to
C:\android-sdk-windows-1.6_r1\docs
-= Warning ! =-
A folder failed to be renamed or moved. On Windows this typically
  means that
a program is using that folder (for example Windows Explorer.) Please
  close
all running programs that may belockingthe directory
'C:\android-sdk-windows-1.6_r1\temp\DocPackage.new01' and try again.

Failed to rename directory
C:\android-sdk-windows-1.6_r1\temp\DocPackage.new01 to
C:\android-sdk-windows-1.6_r1\docs
-= Warning ! =-
A folder failed to be renamed or moved. On Windows this typically
  means that
a program is using that folder (for example Windows Explorer.) Please
  close
all running programs that may belockingthe directory
'C:\android-sdk-windows-1.6_r1\temp\DocPackage.new01' and try again.
Installed: SDK Platform Android 2.0, API 5 (tools rev: 3)

   --
   Xavier Ducrohet
   Android SDK Tech Lead
   Google Inc.- Hide quoted text -

   - Show quoted text -

  --
  Xavier Ducrohet
  Android SDK Tech Lead
  Google Inc.

  Please do not send me questions directly. Thanks!- 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

[android-developers] Re: Android SDK loads every time i open Eclipse

2009-10-29 Thread Streets Of Boston

Eclipse loads from a work-space (e.g. try to start eclipse up twice in
a row and the second time it'll complain that the works-space is
already in use).

Create a different workspace that does not have Android SDK. Then
start Eclipse from there.

On Oct 29, 11:04 am, Teo teomina...@gmail.com wrote:
 Can i stop that? Sometimes i don't use Eclipse for Android development
 but it still bugs me to see it load every time =D

 Thanks in advance!
--~--~-~--~~~---~--~~
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: Example Needed: a view containing a reference to its activity

2009-10-29 Thread Streets Of Boston

Or you could use the getTag and setTag methods on your view:

myView.setTag(myActivity)
...
myActivity = (MyActivity)someView.getTag();
...

On Oct 28, 5:08 pm, ClarkBattle clarkbat...@gmail.com wrote:
 Very tricky.  I like it!  Thanks.

 On Oct 28, 1:12 pm, RichardC richard.crit...@googlemail.com wrote:



  In your activity onCreate method
  1. find your custom view by id.
  2. call a method on your custom view and pass it this (of your
  activity class) and save it in the custom view.

  In the custom view used the saved reference to your activity class to
  call back into your activity class when you need to.

  --
  RichardC

  On Oct 28, 7:40 pm, ClarkBattle clarkbat...@gmail.com wrote:

   I have a custom view that needs a reference to the activity that
   created it.

   Dianne Hackborn said in another thread:

   Give your view a reference to the activity (or a Java interface it 
   implements) and call back through that.
   Much much MUCH more efficient than sending a broadcast.
   See all of the standard view and view subclass callbacks for examples.

   Sadly, I dont understand her reply and cant find any decent examples
   that show how to do this.

   Can anyone point me to an example or post one here?

   Thanks.- 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: bitmap size exceeds VM budget

2009-10-30 Thread Streets Of Boston
How large is the bitmap (in pixels)?

Don't make the bitmaps/pics in your resources too large. Don't make
the larger than you absolutely need to (e.g. not much larger than your
screen or larger than the view in which you tend to put them).


On Oct 30, 6:17 am, Richard rtaylor...@googlemail.com wrote:
 I'm getting some reports from the remote stack trace plug-in, with
 this error (see below)

 What I'm doing, is
 findViewById(R.id.instructionsBack).setBackgroundResource
 (R.drawable.instructions1);

 And then when I need to change the image,
 findViewById(R.id.instructionsBack).setBackgroundResource
 (R.drawable.instructions2);

 From the error, I'm guessing that the old image is staying in the
 memory and preventing the new one from loading?

 What's the correct way to do this kind of thing?

 Thanks,
 Richard

 java.lang.OutOfMemoryError: bitmap size exceeds VM budget
         at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
         at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:
 363)
         at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:
 212)
         at android.graphics.drawable.Drawable.createFromResourceStream
 (Drawable.java:663)
         at android.content.res.Resources.loadDrawable(Resources.java:1637)
         at android.content.res.Resources.getDrawable(Resources.java:535)
         at android.view.View.setBackgroundResource(View.java:6489)
         at com.stickycoding.FlyingAces.Instructions.updateScreen
 (Instructions.java:33)
         at com.stickycoding.FlyingAces.Instructions.onClick(Instructions.java:
 52)
         at android.view.View.performClick(View.java:2179)
         at android.view.View.onTouchEvent(View.java:3828)
         at android.view.View.dispatchTouchEvent(View.java:3368)
         at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
         at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
         at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
         at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
         at com.android.internal.policy.impl.PhoneWindow
 $DecorView.superDispatchTouchEvent(PhoneWindow.java:1752)
         at
 com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent
 (PhoneWindow.java:1206)
         at android.app.Activity.dispatchTouchEvent(Activity.java:1998)
         at com.android.internal.policy.impl.PhoneWindow
 $DecorView.dispatchTouchEvent(PhoneWindow.java:1736)
         at android.view.ViewRoot.handleMessage(ViewRoot.java:1547)
         at android.os.Handler.dispatchMessage(Handler.java:99)
         at android.os.Looper.loop(Looper.java:123)
         at android.app.ActivityThread.main(ActivityThread.java:3948)
         at java.lang.reflect.Method.invokeNative(Native Method)
         at java.lang.reflect.Method.invoke(Method.java:521)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
 (ZygoteInit.java:782)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
         at dalvik.system.NativeStart.main(Native Method)

-- 
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: Processing Pictures

2009-11-02 Thread Streets Of Boston
Few hints :)
Search for ColorMatrix and ColorMatrixFilter on developer.android.com
and search for ColorMatrix on Google for various ways of transforming
color-images into BW.

On Nov 2, 12:18 pm, polyclefsoftware dja...@gmail.com wrote:
 What I'd like to be able to do is take a picture with the camera and
 convert the resulting image into a monochrome bitmap (and do some
 other processing on the image).

 Googling for answers hasn't yielded good results. Can anyone point me
 to a good resource for how to handle this? Should I handle the
 processing on the byte array from taking the picture, or convert it
 into a Bitmap or some other image format and process that?

-- 
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: Anyone know what happened to Cyrket?

2009-11-02 Thread Streets Of Boston
www.androlib.com is still up.

On Nov 2, 5:50 pm, dadical keyes...@gmail.com wrote:
 I love, love, love that application, and have been missing it terribly
 since it went offline about a week ago.  Google's lack of any kind of
 real console for devs was made less painful by cyrket.  Anyone have
 any clues as to where it went and if it will be back?

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

2009-11-07 Thread Streets Of Boston
Lance is absolutely right. I ran into this problem a few months ago.

Possible solution:
Hold a static handle to your currently active instance of your
activity (works only if you have at most one active instance of your
activity at any given time in your process).

public class MyActivity extends Activity {
public static final MyActivity ACTIVE_INSTANCE;
private final static int DIALOG_TASKING = 1;


ProgressDialog mLoadingDialog;


@Override
public void onCreate(Bundle savedInstanceState) {

ACTIVE_INSTANCE = this;

super.onCreate(savedInstanceState);
setContentView(R.layout.main);


new Task().execute();
}

@Override
public void onDestroy() {
super.onDestroy();

   ACTIVE_INSTANCE = null;
}

@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_TASKING:
mLoadingDialog = new ProgressDialog(this);
mLoadingDialog.setMessage(Loading stuff..);
mLoadingDialog.setCancelable(true);
return mLoadingDialog;
}
return super.onCreateDialog(id);
}


private static class Task extends AsyncTaskVoid, Void, Void {


protected void onPreExecute() {
ACTIVE_INSTANCE.showDialog(DIALOG_TASKING);
}


protected Void doInBackground(Void... unused) {
for (int i = 0; i  400; i++) { }; // just
to take some time up
return null;
}


protected void onPostExecute(Void unused) {
ACTIVE_INSTANCE.dismissDialog
(DIALOG_TASKING);
Toast.makeText(ACTIVE_INSTANCE, Finished..,
Toast.LENGTH_LONG).show();
}
}
}

You may need to put null checks in your code before using
ACTIVE_INSTANCE.
But, you get the idea :)


On Nov 7, 11:45 am, Lee Jarvis ljjar...@googlemail.com wrote:
 Ah ok, that makes sense. Thanks for your reply. I understand what
 you're saying, but in all honesty after trying another 3 examples I'm
 still unable to resolve this, could you possibly provide some kind of
 example for what would work?

 Seems if I use a reference to a ProgressDialog in my activity it'll
 leak, and if I use the showDialog() methods it'll continue forever.

 Thanks

 On Nov 7, 4:39 pm, Lance Nanek lna...@gmail.com wrote:



  private final class Task extends AsyncTaskVoid, Void, Void {
  ...
  dismissDialog(DIALOG_TASKING);

  A non-static inner class like this has a reference to the instance of
  the class that created it. So that dismissDialog call probably goes to
  the previous instance of your activity in this case. Not the current
  one if there has been an orientation change and the activity has been
  recreated.

  public void onDestroy() {
  dismissDialog(DIALOG_TASKING);

  This is called too late to matter. Dialogs created by showDialog are
  managed by the Activity class. It records which dialogs have to be
  reshown when the activity is recreated due to an orientation change.
  It does so right after the call to onSaveInstanceState. That happens
  before onDestroy.

  On Nov 7, 9:53 am, Lee Jarvis ljjar...@googlemail.com wrote:

   I apologise if I'm missing something or just being stupid.. But i've
   tried the following..

       @Override
       public void onDestroy() {
           dismissDialog(DIALOG_TASKING);
           super.onDestroy();
       }

   The dialog is only dismissed if I DONT change orientation, otherwise
   the finished toast will show, but the ProgressDialog will never
   actually disappear.

   On Nov 7, 2:41 pm, Mark Murphy mmur...@commonsware.com wrote:

Lee Jarvis wrote:
 This code (kinda) works, the only problem is dismissing the dialog if
 the activity is recreated. I've tried dismissing it if mTaskComplete
 is true but I guess by that time it's lost reference to the
 ProgressDialog.

You may need to dismiss the dialog in onDestroy() and reopen it in
onCreate(), if the flag is true.

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

Android App Developer Books:http://commonsware.com/books- 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: AsyncTask and ProgressDialog

2009-11-07 Thread Streets Of Boston
Show us your code that deals with showing/hiding the progress bar and
show exactly what doesn't work.
Maybe we can figure it out  :)

On Nov 7, 5:32 pm, Lee Jarvis ljjar...@googlemail.com wrote:
 Any other suggestions? I keep trying different things out but nothing
 seems to work, I keep seeing common applications with the same
 functionality which is making it more frustrating because I know it
 should work fine

 On 7 Nov, 17:29, Lee Jarvis ljjar...@googlemail.com wrote:



  Thanks for your reply, it's made me understand things a little better.

  Unfortunately that still doesn't seem to work..

  The Toast popup appears twice, then the ProgressDialog just continues
  to run regardless

  On Nov 7, 5:14 pm, Streets Of Boston flyingdutc...@gmail.com wrote:

   Lance is absolutely right. I ran into this problem a few months ago.

   Possible solution:
   Hold a static handle to your currently active instance of your
   activity (works only if you have at most one active instance of your
   activity at any given time in your process).

   public class MyActivity extends Activity {
       public static final MyActivity ACTIVE_INSTANCE;
       private final static int DIALOG_TASKING = 1;

       ProgressDialog mLoadingDialog;

       @Override
       public void onCreate(Bundle savedInstanceState) {

               ACTIVE_INSTANCE = this;

           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);

           new Task().execute();
       }

       @Override
       public void onDestroy() {
           super.onDestroy();

              ACTIVE_INSTANCE = null;
       }

       @Override
       protected Dialog onCreateDialog(int id) {
           switch (id) {
           case DIALOG_TASKING:
                   mLoadingDialog = new ProgressDialog(this);
                   mLoadingDialog.setMessage(Loading stuff..);
                   mLoadingDialog.setCancelable(true);
                   return mLoadingDialog;
           }
           return super.onCreateDialog(id);
       }

       private static class Task extends AsyncTaskVoid, Void, Void {

           protected void onPreExecute() {
                   ACTIVE_INSTANCE.showDialog(DIALOG_TASKING);
           }

                   protected Void doInBackground(Void... unused) {
                           for (int i = 0; i  400; i++) { }; // just
   to take some time up
                           return null;
                   }

                   protected void onPostExecute(Void unused) {
                           ACTIVE_INSTANCE.dismissDialog
   (DIALOG_TASKING);
                           Toast.makeText(ACTIVE_INSTANCE, Finished..,
   Toast.LENGTH_LONG).show();
                   }
       }

   }

   You may need to put null checks in your code before using
   ACTIVE_INSTANCE.
   But, you get the idea :)

   On Nov 7, 11:45 am, Lee Jarvis ljjar...@googlemail.com wrote:

Ah ok, that makes sense. Thanks for your reply. I understand what
you're saying, but in all honesty after trying another 3 examples I'm
still unable to resolve this, could you possibly provide some kind of
example for what would work?

Seems if I use a reference to a ProgressDialog in my activity it'll
leak, and if I use the showDialog() methods it'll continue forever.

Thanks

On Nov 7, 4:39 pm, Lance Nanek lna...@gmail.com wrote:

 private final class Task extends AsyncTaskVoid, Void, Void {
 ...
 dismissDialog(DIALOG_TASKING);

 A non-static inner class like this has a reference to the instance of
 the class that created it. So that dismissDialog call probably goes to
 the previous instance of your activity in this case. Not the current
 one if there has been an orientation change and the activity has been
 recreated.

 public void onDestroy() {
 dismissDialog(DIALOG_TASKING);

 This is called too late to matter. Dialogs created by showDialog are
 managed by the Activity class. It records which dialogs have to be
 reshown when the activity is recreated due to an orientation change.
 It does so right after the call to onSaveInstanceState. That happens
 before onDestroy.

 On Nov 7, 9:53 am, Lee Jarvis ljjar...@googlemail.com wrote:

  I apologise if I'm missing something or just being stupid.. But i've
  tried the following..

      @Override
      public void onDestroy() {
          dismissDialog(DIALOG_TASKING);
          super.onDestroy();
      }

  The dialog is only dismissed if I DONT change orientation, otherwise
  the finished toast will show, but the ProgressDialog will never
  actually disappear.

  On Nov 7, 2:41 pm, Mark Murphy mmur...@commonsware.com wrote:

   Lee Jarvis wrote:
This code (kinda) works, the only problem is dismissing the 
dialog if
the activity is recreated. I've tried dismissing it if 
mTaskComplete
is true but I guess by that time it's lost

[android-developers] Re: AsyncTask and ProgressDialog

2009-11-08 Thread Streets Of Boston
If you do showDialog(dialogId) and dismissDialog(dailogId), Android
actively manages the showing and hiding of the dialog on configuration
changes.

E.g. if you called showDialog(id) and your rotate your screen, Android
will make sure that the dialog is shown again when the activity is
recreated for the new configuration. To dismiss it, you have to
explicitly call dismissDialog(id).

However, you must call 'dismissDialog' on the currently active
activity. That's where the trick with 'ACTIVE_INSTANCE' comes in:
ACTIVE_INSTANCE.showDialog(ACTIVE_TASKING) and
ACTIVE_INSTANCE.dismissDialog(DIALOG_TASKING).

On Nov 8, 4:28 am, Lee Jarvis ljjar...@googlemail.com wrote:
 Well, that's the thing. It's not a progress 'bar' that I can just show/
 hide which would seem a lot easier. I'm just using a ProgressDialog
 that I dismiss in onPostExecute, The code you see above inside of my
 AsyncTask is what I'm using to show/hide the dialog. I use showDialog
 () in onPreExecute and dismissDialog() in onPostExecute, I realize one
 a new activity is created and the old one is killed it'll lose
 reference to that dialog so I'm guessing that's why dismissDialog()
 doesn't work (on in fact the code in onPostExecute() doesn't get
 executed because the phone has change orientation and it's trying to
 dismiss a dialog which doesn't exist.

 On 8 Nov, 03:52, Streets Of Boston flyingdutc...@gmail.com wrote:



  Show us your code that deals with showing/hiding the progress bar and
  show exactly what doesn't work.
  Maybe we can figure it out  :)

  On Nov 7, 5:32 pm, Lee Jarvis ljjar...@googlemail.com wrote:

   Any other suggestions? I keep trying different things out but nothing
   seems to work, I keep seeing common applications with the same
   functionality which is making it more frustrating because I know it
   should work fine

   On 7 Nov, 17:29, Lee Jarvis ljjar...@googlemail.com wrote:

Thanks for your reply, it's made me understand things a little better.

Unfortunately that still doesn't seem to work..

The Toast popup appears twice, then the ProgressDialog just continues
to run regardless

On Nov 7, 5:14 pm, Streets Of Boston flyingdutc...@gmail.com wrote:

 Lance is absolutely right. I ran into this problem a few months ago.

 Possible solution:
 Hold a static handle to your currently active instance of your
 activity (works only if you have at most one active instance of your
 activity at any given time in your process).

 public class MyActivity extends Activity {
     public static final MyActivity ACTIVE_INSTANCE;
     private final static int DIALOG_TASKING = 1;

     ProgressDialog mLoadingDialog;

     @Override
     public void onCreate(Bundle savedInstanceState) {

             ACTIVE_INSTANCE = this;

         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);

         new Task().execute();
     }

     @Override
     public void onDestroy() {
         super.onDestroy();

            ACTIVE_INSTANCE = null;
     }

     @Override
     protected Dialog onCreateDialog(int id) {
         switch (id) {
         case DIALOG_TASKING:
                 mLoadingDialog = new ProgressDialog(this);
                 mLoadingDialog.setMessage(Loading stuff..);
                 mLoadingDialog.setCancelable(true);
                 return mLoadingDialog;
         }
         return super.onCreateDialog(id);
     }

     private static class Task extends AsyncTaskVoid, Void, Void {

         protected void onPreExecute() {
                 ACTIVE_INSTANCE.showDialog(DIALOG_TASKING);
         }

                 protected Void doInBackground(Void... unused) {
                         for (int i = 0; i  400; i++) { }; // just
 to take some time up
                         return null;
                 }

                 protected void onPostExecute(Void unused) {
                         ACTIVE_INSTANCE.dismissDialog
 (DIALOG_TASKING);
                         Toast.makeText(ACTIVE_INSTANCE, Finished..,
 Toast.LENGTH_LONG).show();
                 }
     }

 }

 You may need to put null checks in your code before using
 ACTIVE_INSTANCE.
 But, you get the idea :)

 On Nov 7, 11:45 am, Lee Jarvis ljjar...@googlemail.com wrote:

  Ah ok, that makes sense. Thanks for your reply. I understand what
  you're saying, but in all honesty after trying another 3 examples 
  I'm
  still unable to resolve this, could you possibly provide some kind 
  of
  example for what would work?

  Seems if I use a reference to a ProgressDialog in my activity it'll
  leak, and if I use the showDialog() methods it'll continue forever.

  Thanks

  On Nov 7, 4:39 pm, Lance Nanek lna...@gmail.com wrote:

   private final class Task extends AsyncTaskVoid

[android-developers] Re: AsyncTask and ProgressDialog

2009-11-10 Thread Streets Of Boston
();
                         }
                 }

         }

 }

 On Nov 10, 5:41 pm, Lee Jarvis ljjar...@googlemail.com wrote:



  I've tried that, too. But again to no avail, nothing I do seems to
  work. I've tried using the callback features whilst also implementing
  weak references which also doesn't work. Once I change orientation,
  the progressDialog never disappears, it's bugging me to hell

  On 8 Nov, 17:41, Streets Of Boston flyingdutc...@gmail.com wrote:

   If you do showDialog(dialogId) and dismissDialog(dailogId), Android
   actively manages the showing and hiding of the dialog on configuration
   changes.

   E.g. if you called showDialog(id) and your rotate your screen, Android
   will make sure that the dialog is shown again when the activity is
   recreated for the new configuration. To dismiss it, you have to
   explicitly call dismissDialog(id).

   However, you must call 'dismissDialog' on the currently active
   activity. That's where the trick with 'ACTIVE_INSTANCE' comes in:
   ACTIVE_INSTANCE.showDialog(ACTIVE_TASKING) and
   ACTIVE_INSTANCE.dismissDialog(DIALOG_TASKING).

   On Nov 8, 4:28 am,LeeJarvisljjar...@googlemail.com wrote:

Well, that's the thing. It's not a progress 'bar' that I can just show/
hide which would seem a lot easier. I'm just using a ProgressDialog
that I dismiss in onPostExecute, The code you see above inside of my
AsyncTask is what I'm using to show/hide the dialog. I use showDialog
() in onPreExecute and dismissDialog() in onPostExecute, I realize one
a new activity is created and the old one is killed it'll lose
reference to that dialog so I'm guessing that's why dismissDialog()
doesn't work (on in fact the code in onPostExecute() doesn't get
executed because the phone has change orientation and it's trying to
dismiss a dialog which doesn't exist.

On 8 Nov, 03:52, Streets Of Boston flyingdutc...@gmail.com wrote:

 Show us your code that deals with showing/hiding the progress bar and
 show exactly what doesn't work.
 Maybe we can figure it out  :)

 On Nov 7, 5:32 pm,LeeJarvisljjar...@googlemail.com wrote:

  Any other suggestions? I keep trying different things out but 
  nothing
  seems to work, I keep seeing common applications with the same
  functionality which is making it more frustrating because I know it
  should work fine

  On 7 Nov, 17:29,LeeJarvisljjar...@googlemail.com wrote:

   Thanks for your reply, it's made me understand things a little 
   better.

   Unfortunately that still doesn't seem to work..

   The Toast popup appears twice, then the ProgressDialog just 
   continues
   to run regardless

   On Nov 7, 5:14 pm, Streets Of Boston flyingdutc...@gmail.com 
   wrote:

Lance is absolutely right. I ran into this problem a few months 
ago.

Possible solution:
Hold a static handle to your currently active instance of your
activity (works only if you have at most one active instance of 
your
activity at any given time in your process).

public class MyActivity extends Activity {
    public static final MyActivity ACTIVE_INSTANCE;
    private final static int DIALOG_TASKING = 1;

    ProgressDialog mLoadingDialog;

    @Override
    public void onCreate(Bundle savedInstanceState) {

            ACTIVE_INSTANCE = this;

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        new Task().execute();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();

           ACTIVE_INSTANCE = null;
    }

    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case DIALOG_TASKING:
                mLoadingDialog = new ProgressDialog(this);
                mLoadingDialog.setMessage(Loading stuff..);
                mLoadingDialog.setCancelable(true);
                return mLoadingDialog;
        }
        return super.onCreateDialog(id);
    }

    private static class Task extends AsyncTaskVoid, Void, 
Void {

        protected void onPreExecute() {
                ACTIVE_INSTANCE.showDialog(DIALOG_TASKING);
        }

                protected Void doInBackground(Void... unused) {
                        for (int i = 0; i  400; i++) { }; 
// just
to take some time up
                        return null;
                }

                protected void onPostExecute(Void unused) {
                        ACTIVE_INSTANCE.dismissDialog
(DIALOG_TASKING);
                        Toast.makeText(ACTIVE_INSTANCE, 
Finished..,
Toast.LENGTH_LONG).show

[android-developers] Re: New Developer Distribution Agreement

2009-11-11 Thread Streets Of Boston
Chill out! :=)

To me it looks like a more tight-knit version of their earlier
agreement.

About the 48hour:
That was already happening, kind-of. I had some refunds that were
about 36 hours after the sale. Am i happy with this long period, no...
but it's nothing new, i think.

The main changes seem to come regarding (involuntary) takedowns of
your application (e.g. copyright infringement, legal issues with your
app, etc). See Al' post in 'Discussion' about that.

On Nov 11, 3:09 pm, Rich miser...@gmail.com wrote:
 Is nobody from Google going to chime in on any of these threads?

 This is a total fucking farce if you ask me, just another example of
 Google not giving any respect to the development community. They're
 already taxing us, and now they're changing the rules, upping the
 refund period and holding us responsible for refunds? Without even
 being decent enough to tell us in plain english? What a joke.

 R

 On Nov 11, 3:16 am, Al Sutton a...@funkyandroid.com wrote:



  This is being discussed on -discuss and I believe that the changes
  can't be enforced until they've complied with section 14.1 (in both
  new and old agreements) of the agreement which states;

  14.1 Google may make changes to this Agreement at any time by sending
  the Developer notice by email describing the modifications made

  Al.

  The -discuss thread is 
  athttp://groups.google.co.uk/group/android-discuss/browse_thread/thread...

  On 11 Nov, 06:49, dan raaka danra...@gmail.com wrote:

   It will be good to see the diff between the old and the new one.

   -Dan

   On Tue, Nov 10, 2009 at 4:47 PM, Rich miser...@gmail.com wrote:
 I don't speak legalese, I speak code!.. What is the TL;DR of this?
What am I agreeing to here?

Thanks,
Rich

--
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- 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 native Gallery is reading bigger images!

2009-11-11 Thread Streets Of Boston
I think the Gallery just uses BitmapFactory to read the images.

But, the biggest images i've had on my phone are 2048x1539pixels
(6MByte uncompressed, when using RGB_565). I've not tried to load a
truly huge image.

On Nov 11, 12:54 pm, gaetan.eleo...@gmail.com
gaetan.eleo...@gmail.com wrote:
 Hi, i'm wondering too how is it possible to read/write really big
 image in android...

 Thank you
 Regards,
 Gaetan Eleouet

-- 
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 camera.setParameters(p) - Picture size must be 213x350?

2009-11-16 Thread Streets Of Boston
That's just in the emulator. The emulated camera only 'takes' 213x350
pixel pictures.
And you need to deal with it anyway in your code, just in case you set
some picture width/height that is not supported by some real Android
phone.

On Oct 29, 10:03 am, chrispix chris...@gmail.com wrote:
 I am having an issue w/ 2.0 in the emulator when I am trying to set a
 couple of parameters.  Including the size.

 It appears these messages appear.. I guess my question is, why is the
 picture size stuck at 213x350? If I set my picture size to 640x480 it
 fails.

 Chris.

 10-29 14:55:24.261: DEBUG/CameraService(31): getParameters(picture-
 format=jpeg;picture-size=213x350;preview-format=yuv422sp;preview-frame-
 rate=15;preview-size=176x144)
 10-29 14:55:24.261: DEBUG/CameraService(31): setParameters(preview-
 size=176x144;preview-format=yuv422sp;picture-size=640x480;picture-
 format=jpeg;preview-frame-rate=15)
 10-29 14:55:24.261: ERROR/CameraHardwareStub(31): Still picture size
 must be size of canned JPEG (213x350)
 10-29 14:55:24.271: DEBUG/CameraService(31): setParameters(focus-
 mode=auto;preview-size=176x144;preview-format=yuv422sp;picture-
 size=640x480;rotation=90;picture-format=jpeg;preview-frame-rate=15)
 10-29 14:55:24.271: ERROR/CameraHardwareStub(31): Still picture size
 must be size of canned JPEG (213x350)

-- 
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: Securing a paid app

2009-11-17 Thread Streets Of Boston
What would happen if someone gets a new android phone? The app's
authentication will fail.

You should hash/key on the user's google-account, the same key that is
used by Android Market (you can download paid apps as often as you
want - once you paid for them - based on your google-account)

On Nov 15, 2:32 am, android kracker markamorris2...@gmail.com wrote:
 Using the unique ID (hash) of the phone, register it with your web
 service on install.
 Then employ PKI to authenticate your app on each launch.
 On your web service sign a string containing the hash, timestamp, and
 a short expiration timestamp.
 Then have your app use your public key (in the app) to authenticate
 the string, verify the timestamps, and complete
 the launch if valid, otherwise abort the launch or offer the user to
 come clean and install.
 To prevent code modification--bypassing the check--don't include all
 of the code in the app.
 Keep some of it on the server and only send it to the app if the check
 takes place and passes the check.
 This way the app will not function correctly unless the check is
 performed and passes.
 Create a set of one-off methods (dummys that just pass through) that
 you can dynamically use with each app instance; since you
 are in control of the download (unlike Market publishers), you can
 dynamically build and package a unique app for each instance
 downloaded.
 This way no two apps use the same method and a hacker is up a creek as
 far a patching the code
 and replicating it to the community. When one instance is cracked, and
 it will be, then your server can cancel that hacked instance
 without effecting all of the other valid users. This will create a
 string disincentive, because no two app are the same, codewise ;-)

 Maybe we should start a service and offer Android publishers a secure
 distribution service, unlike the Market.
 There is no way to register (stamp an app with a phone id) downloads
 from the Market prior to installation.
 As it stands now publishers have no way to verify if their app was
 downloaded from the Market or copied and installed by other means.

 If there is I would like to know. I've asked but I never get replies
 regarding this advanced topic. Most publishers are still learning to
 just create apps, let alone seek out secure distribution and customer
 behavior--only Google enjoys this privilege, currently.

 Here's a method snippet for getting the unique ID and hashing it:

 String getPhoneID(){
         MessageDigest digest;
         try {
             digest = MessageDigest.getInstance(SHA-1);
         } catch (NoSuchAlgorithmException e) {
             throw new RuntimeException(this should never happen);
         }

         String srvcName = Context.TELEPHONY_SERVICE;
         TelephonyManager telephonyManager =
           (TelephonyManager)getSystemService(srvcName);

         /* requires READ_PHONE_STATE permission */
         String deviceId = telephonyManager.getDeviceId();
         if (TextUtils.isEmpty(deviceId)) {
             return ;
         }

         byte[] hashedDeviceId = digest.digest(deviceId.getBytes());
         String id = new String(Base64.encodeBase64(hashedDeviceId), 0,
 12);
         id = id.replaceAll(/, _);
         return id;

 }

 On Nov 14, 7:12 am, jax jackma...@gmail.com wrote:



  I am wondering how I might go about securing a paid app on Android.

  I am thinking of selling the application from my own website via
  PayPal, however, how will I stop people from sharing it with their
  friends etc.  Does Android have any type of native support for this?- 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: fwd: get the file path from a URI instance

2009-11-17 Thread Streets Of Boston
When using openInputStream on the content-resolver, the returned input-
stream is not as 'flexible' as a FileInputStream. For example,
FileInputStreams can be retried if something goes wrong. The one
returned by openInputStream can not.

To get the fully qualified path-name to the image-file (jpg/png),
query the Uri of the image and obtain the value of the DATA (_data)
column. This value is a String, the fully-qualified path to the image
file. Then you can create a FileInputStream from this file.


On Nov 17, 4:08 am, MrChaz mrchazmob...@googlemail.com wrote:
 If I remember rightly, the gallery returns you a content uri
 so you'll want to do something like: getContentResolver
 ().openInputStream(uri)

 On Nov 17, 5:53 am, Abhi abhishek.r.sha...@gmail.com wrote:



  Hi Dianne,

  I am trying to do the following.

  I have an Image viewer where in the user picks an Image from within
  the gallery. The uri to that selected Image is available to me. Now, I
  want to use this URI information and send it as a file over a socket
  using FileInputStream. Is this a valid syntax to perform the above
  action?

        FileInputStream fis = new FileInputStream(uri.getPath()); //
  Here uri is the URI of the selected Image
        byte[] buffer = new byte[fis.available()];
        fis.read(buffer);

        ObjectOutputStream oos = new ObjectOutputStream
  (socket.getOutputStream());
        oos.writeObject(buffer);

  Please help me to move forward.

  Thanks,

  Abhi- 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: Is there any way to display 8000 * 8000 jpeg file without OutOfMemoryException

2009-11-21 Thread Streets Of Boston
Like some others suggested pre-process the large file, break it up in
smaller chunks, each chunk being a proper JPEG
Then put all the chunks in a RandomAccessFile or a database. Be sure
to be able to find the chunks by a row and column index.

Then put this RandomAccessFile or database on your phone and write
code to fetch each sub-jpg based on a row and colum index.


On Nov 20, 3:38 pm, PJ pjbar...@gmail.com wrote:
 We might be able to come up with more creative solutions if you give
 us more information about where the 8000x8000 jpeg file is coming
 from, and whether you just want to display it in a WxH view or to do
 something else with it.

 Also, since you expressed interest in Google's server-side solution
 for Google Maps, are you considering developing a server-side
 component to your app as well?  If so, you could host this capability
 (convert 8000x8000 image to smaller image) on a server somewhere.

 If you try to do all processing on the device itself, it's probably
 going to be very slow.

 What does your app do?  Now you've got me all curious.  :D

 -- PJ

 On Nov 19, 7:06 pm, James Wang jameswangc...@gmail.com wrote:



Step #2: Generate 10,000 tiles that are 80*80 instead (100 * 100 tiles).

Step #3: Render tiles on-screen by drawing them on the Canvas, and
support swipe gestures to move through the image by replacing tiles,
much like Google Maps works.

  Hi Mark, AFAIK, the decoder of jpeg on android must support to read
  random part of jpeg file if I want do step#2 as you said.
  I checked out SDK reference and found out the default decoder of jpeg
  seems not support it. Am I right?
  Do I have to make another jpeg decoder?

  BTW, I think google map does the same thing on server side, not on
  mobile phone, does not it?- 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: OpenGL gluUnProject

2009-11-23 Thread Streets Of Boston
http://groups.google.com/group/android-developers/browse_frm/thread/9d2bf53e3a798cb6/07cfa3ee11507fc1?lnk=gstq=gluUnproject#07cfa3ee11507fc1


On Nov 22, 3:35 am, Anfernee anfernee2...@gmail.com wrote:
 i want to get the 3D coordinate from the android screen x,y
 coordinate
 i choose to use the gluUnProject
 but the gluUnProject function always returns NaN
 why 
 please help me

-- 
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: Picture location on HTC sense phones

2009-11-23 Thread Streets Of Boston
If you do a ContentResolver.insert, instead of a
MediaStore.Images.Media.insertImage, you have to provide the fully
qualified path to the image-file in the ContentValues as well:

   // fullyQualifiedPathName is the absolute/canonical path-name to
the JPEG file.
   values.put(MediaStore.Images.Media.DATA, fullyQualifiedPathName);

And you should call bitmap.compress on the FileOutputStream of this
JPEG file to save the actual image/jpeg data.

If you don't do this, the MediaScanner will pick it up, but only after
you unmounted your sd-card or restarted your  phone.


On Nov 22, 6:04 pm, Derek dlawl...@gmail.com wrote:
 Agree we are seeing the same thing.  Haven't found any solution yet.
 In Sense UI seems like HTC wrote their own camera app that is
 listening to the same intent as the default Android camera but not
 conforming to the same interface contract as the Android code.

 Anyone else find a fix to this?

 On Nov 5, 6:27 am, SCMSoft scms...@gmail.com wrote:



  (The message was accidentally sent, here is the full one:)

  Hi,
  We have multiple apps that save pictures to the phone. We use the
  following code for that:

          ContentValues values = new ContentValues();
          values.put(MediaStore.Images.Media.DISPLAY_NAME, Photo);
          values.put(MediaStore.Images.Media.DESCRIPTION, Camera
  Pro);
          values.put(MediaStore.Images.Media.MIME_TYPE, image/jpeg);
          values.put(MediaStore.Images.Media.DATE_TAKEN,
  System.currentTimeMillis());
          Uri uri = getContentResolver().insert
  (MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

          ... save Image to getContentResolver().openOutputStream
  (uri) ...

  This works fine on the G1 and a Samsung Galaxy, but on HTC phones with
  thesenseUI, the photos seem to be stored in a different location.
  The HTC Albums app doesn't pick these photos up and to the user it
  seems like the photos are not there at all. Also the default gallery
  app is not present.
  Is there a way to save images in the right place always? Can any
  phone manufacturer just choose to shuffle things around like this? It
  seems to make it unnecesarily hard on app developers if there are no
  standards.

  Best regards,

  Swiss Codemonkey team.- 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: Activity [sometimes] throws Wrong state class exception when being resumed after kill

2009-11-24 Thread Streets Of Boston
i've seen this too.
I got around it by overriding the problematic View's
onRestoreInstanceState method:

public void onRestoreInstanceState(Bundle savedState) {
 ...
 ...
 super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE);
}

I took a look at the android.view.View's implementation of this
onRestoreInstanceState method and it only expects the
BaseSavedState.EMPTY_STATE as valid input. It checks for if
(savedState != BaseSavedState.EMPTY_STATE)  then throw exception ...

For me it went wrong because 'savedState' is no longer the actual
BaseSavedState.EMPTY_STATE instance but a de-serialized copy of it
(after the killed process has been restored/restarted) and this means
that the '!=' operator returns true and an exception is thrown.

On Nov 24, 10:08 am, Mark Wyszomierski mar...@gmail.com wrote:
 Hi,

 I'm testing how my app behaves when killed by the OS due to low memory
 conditions. I always have three activities on the stack, like:

    A  B  C  (then C launches maps or some other heavy process)

 when my app is killed, and I return to it, C starts itself up again
 ok. When I hit the back button to go to B, I [sometimes] get an
 exception thrown which I can't trace. Output is below. I don't know
 where to go from here. I've only seen one other post mentioning this
 exception, but it was related to a reproducable error when rotating
 the device. This only happens sometimes. Thanks for any help:

 11-24 07:52:12.469: ERROR/AndroidRuntime(5877): Uncaught handler:
 thread main exiting due to uncaught exception
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):
 java.lang.RuntimeException: Unable to start activity ComponentInfo
 {com.test.android/com.test.android.ui.ActivityHello}:
 java.lang.IllegalArgumentException: Wrong state class -- expecting
 View State
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
 2268)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
 2284)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.app.ActivityThread.access$1800(ActivityThread.java:112)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.os.Handler.dispatchMessage(Handler.java:99)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.os.Looper.loop(Looper.java:123)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.app.ActivityThread.main(ActivityThread.java:3948)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 java.lang.reflect.Method.invokeNative(Native Method)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 java.lang.reflect.Method.invoke(Method.java:521)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
 (ZygoteInit.java:782)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 dalvik.system.NativeStart.main(Native Method)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877): Caused by:
 java.lang.IllegalArgumentException: Wrong state class -- expecting
 View State
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.view.View.onRestoreInstanceState(View.java:5359)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.view.View.dispatchRestoreInstanceState(View.java:5335)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
 1093)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
 1097)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
 1097)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
 1097)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
 1097)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.view.View.restoreHierarchyState(View.java:5314)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState
 (PhoneWindow.java:1501)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.app.Activity.onRestoreInstanceState(Activity.java:834)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.app.Activity.performRestoreInstanceState(Activity.java:800)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 android.app.Instrumentation.callActivityOnRestoreInstanceState
 (Instrumentation.java:1172)
 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
 

[android-developers] Re: jpg images noisy on sdcard but fine in gallery, only on Android 1.6 (1.5 is fine)

2009-11-24 Thread Streets Of Boston
In your  'public void onPictureTaken(byte[] data, Camera camera)'
method
You have to create a BMP out of the 'data'. The 'data' is not JPEG. It
is RGB data (if i'm not mistaken).

  Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);

Then you compress the bitmap into jpeg.

  bmp.compress(...) to create a PNG or JPEG file.

A side note: If you want to avoid the MediaScanner to have to run
before your gallery can actually see the proper picture, supply the
DATA column in your insert statement (add it to the ContentValues).
The value of the DATA column is a string, it is the fully-qualified
path-name to your JPEG or PNG file.

On Nov 24, 10:27 am, Joel joelefisc...@googlemail.com wrote:
 In my application users take photos with an Activity that implements
 SurfaceHolder.Callback. The uri.toString() is then passed as an extra
 to a subsequent Activity that displays the image. All fine, except for
 in Android 1.6 the jpgs on the sdcard have a strange noise when
 looking at them through mac finder or win explorer after mounting the
 sdcard. The images have purple and yellow stripes on their upper half.
 Fine on camera gallery.

 Here's some (hopefully) relevant code.

 The fact that it works on 1.5 and not 1.6 points to some underlying
 problems..? Is this a known issue?

 code
 private OnClickListener shutterListener = new OnClickListener() {
         public void onClick(View v) {
                 ImageCaptureCallback iccb = null;
                 filename = System.currentTimeMillis()+;
                         ContentValues values = new ContentValues();
                         values.put(Media.TITLE, filename);
                         values.put(Media.DESCRIPTION, my_photos);
                 uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI,
 values);
                 try {
                         iccb = new ImageCaptureCallback( getContentResolver
 ().openOutputStream(uri));
                 } catch (FileNotFoundException ce) {Log.e(getClass
 ().getSimpleName(),ce.toString());}
                 //take the pic
                 camera.takePicture(mShutterCallback, mPictureCallbackRaw,
 iccb);

 }

 .

 public class ImageCaptureCallback implements PictureCallback  {

                 private OutputStream filoutputStream;
                 public ImageCaptureCallback(OutputStream filoutputStream) {
                         this.filoutputStream = filoutputStream;
                 }

                 public void onPictureTaken(byte[] data, Camera camera) {

                         try {
                                 filoutputStream.write(data);
                                 filoutputStream.flush();
                                 filoutputStream.close();

                         } catch(Exception ex) {
                                 ex.printStackTrace();
                         }
                         startNextActivity();
                 }
         }

 protected void startNextActivity() {
                 Log.d(CameraActivity,starting next activity...);
                 startActivity( new Intent(CameraActivity.this,
 ImageAccepter.class).putExtra(pic, uri.toString()));
         }

 /code

-- 
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: Activity [sometimes] throws Wrong state class exception when being resumed after kill

2009-11-24 Thread Streets Of Boston
I'm going to check that out.

What if it occurs on a View without an ID?

Thanks!

On Nov 24, 11:27 am, Romain Guy romain...@google.com wrote:
 This would happen if you have several views of different type with the
 same id inside a single view hierarchy. This could cause other
 problems so I really advise you to not hack around the default
 implementation of onRestoreInstanceState()  but make sure that your UI
 is setup correctly.

 On Tue, Nov 24, 2009 at 7:28 AM, Streets Of Boston





 flyingdutc...@gmail.com wrote:
  i've seen this too.
  I got around it by overriding the problematic View's
  onRestoreInstanceState method:

  public void onRestoreInstanceState(Bundle savedState) {
   ...
   ...
   super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE);
  }

  I took a look at the android.view.View's implementation of this
  onRestoreInstanceState method and it only expects the
  BaseSavedState.EMPTY_STATE as valid input. It checks for if
  (savedState != BaseSavedState.EMPTY_STATE)  then throw exception ...

  For me it went wrong because 'savedState' is no longer the actual
  BaseSavedState.EMPTY_STATE instance but a de-serialized copy of it
  (after the killed process has been restored/restarted) and this means
  that the '!=' operator returns true and an exception is thrown.

  On Nov 24, 10:08 am, Mark Wyszomierski mar...@gmail.com wrote:
  Hi,

  I'm testing how my app behaves when killed by the OS due to low memory
  conditions. I always have three activities on the stack, like:

     A  B  C  (then C launches maps or some other heavy process)

  when my app is killed, and I return to it, C starts itself up again
  ok. When I hit the back button to go to B, I [sometimes] get an
  exception thrown which I can't trace. Output is below. I don't know
  where to go from here. I've only seen one other post mentioning this
  exception, but it was related to a reproducable error when rotating
  the device. This only happens sometimes. Thanks for any help:

  11-24 07:52:12.469: ERROR/AndroidRuntime(5877): Uncaught handler:
  thread main exiting due to uncaught exception
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):
  java.lang.RuntimeException: Unable to start activity ComponentInfo
  {com.test.android/com.test.android.ui.ActivityHello}:
  java.lang.IllegalArgumentException: Wrong state class -- expecting
  View State
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
  2268)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
  2284)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.app.ActivityThread.access$1800(ActivityThread.java:112)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.os.Handler.dispatchMessage(Handler.java:99)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.os.Looper.loop(Looper.java:123)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.app.ActivityThread.main(ActivityThread.java:3948)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  java.lang.reflect.Method.invokeNative(Native Method)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  java.lang.reflect.Method.invoke(Method.java:521)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
  (ZygoteInit.java:782)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  dalvik.system.NativeStart.main(Native Method)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877): Caused by:
  java.lang.IllegalArgumentException: Wrong state class -- expecting
  View State
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.view.View.onRestoreInstanceState(View.java:5359)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.view.View.dispatchRestoreInstanceState(View.java:5335)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
  1093)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
  1097)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
  1097)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
  1097)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
  1097)
  11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
  android.view.View.restoreHierarchyState(View.java:5314)
  11-24 07:52:12.539

[android-developers] Re: Activity [sometimes] throws Wrong state class exception when being resumed after kill

2009-11-24 Thread Streets Of Boston
Thanks Romain,

Did not work... still the exception...

It occurs on a View with an ID set to 'container'.
And i went into my View hierarchy to check. All looks fine.:
There is only one view with the id set to 'container'.
Every other view in the hierarchy has a unique name or no id at all.

And still i get the exception after my process is killed, restarted
and my view is about to be restored
Doing super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE); gets
rid of that exception.


Here's my code-snippet.
@Override
protected void onRestoreInstanceState(Parcelable parcelable) {
if (parcelable instanceof ViewBundle) {
final ViewBundle  viewBundle = (ViewBundle)parcelable;
mSaveState = viewBundle.getBundle();

// Note that mRestoredBitmapOffFullSizedImage can be null!
// It won't be null on a configuration change, but it may be
// after this view's process/activity is restarted.
mRestoredBitmapOffFullSizedImage = 
(Bitmap)viewBundle.getTransient
(bitmapholder);
super.onRestoreInstanceState(viewBundle.getSuperState());
}
else {
// TODO
// This exception can be thrown when:
// Do edit image (Effects)
// Open Dialer app, make sure process 
smugdroid.process.pictures
is killed.
// Then return to SnapFX --
// java.lang.IllegalArgumentException: Wrong state class --
expecting View Sate.
// Fixed it by always using BaseSavedState.EMPTY_STATE instead 
of
'parcelable'
super.onRestoreInstanceState(parcelable); // -- Exception 
happens
here when using 'parcelable'.
}
}


On Nov 24, 5:57 pm, Romain Guy romain...@google.com wrote:
 That would be worrisome because we do not save/restore the state of
 views without ids.

 On Tue, Nov 24, 2009 at 2:39 PM, Streets Of Boston





 flyingdutc...@gmail.com wrote:
  I'm going to check that out.

  What if it occurs on a View without an ID?

  Thanks!

  On Nov 24, 11:27 am, Romain Guy romain...@google.com wrote:
  This would happen if you have several views of different type with the
  same id inside a single view hierarchy. This could cause other
  problems so I really advise you to not hack around the default
  implementation of onRestoreInstanceState()  but make sure that your UI
  is setup correctly.

  On Tue, Nov 24, 2009 at 7:28 AM, Streets Of Boston

  flyingdutc...@gmail.com wrote:
   i've seen this too.
   I got around it by overriding the problematic View's
   onRestoreInstanceState method:

   public void onRestoreInstanceState(Bundle savedState) {
    ...
    ...
    super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE);
   }

   I took a look at the android.view.View's implementation of this
   onRestoreInstanceState method and it only expects the
   BaseSavedState.EMPTY_STATE as valid input. It checks for if
   (savedState != BaseSavedState.EMPTY_STATE)  then throw exception ...

   For me it went wrong because 'savedState' is no longer the actual
   BaseSavedState.EMPTY_STATE instance but a de-serialized copy of it
   (after the killed process has been restored/restarted) and this means
   that the '!=' operator returns true and an exception is thrown.

   On Nov 24, 10:08 am, Mark Wyszomierski mar...@gmail.com wrote:
   Hi,

   I'm testing how my app behaves when killed by the OS due to low memory
   conditions. I always have three activities on the stack, like:

      A  B  C  (then C launches maps or some other heavy process)

   when my app is killed, and I return to it, C starts itself up again
   ok. When I hit the back button to go to B, I [sometimes] get an
   exception thrown which I can't trace. Output is below. I don't know
   where to go from here. I've only seen one other post mentioning this
   exception, but it was related to a reproducable error when rotating
   the device. This only happens sometimes. Thanks for any help:

   11-24 07:52:12.469: ERROR/AndroidRuntime(5877): Uncaught handler:
   thread main exiting due to uncaught exception
   11-24 07:52:12.539: ERROR/AndroidRuntime(5877):
   java.lang.RuntimeException: Unable to start activity ComponentInfo
   {com.test.android/com.test.android.ui.ActivityHello}:
   java.lang.IllegalArgumentException: Wrong state class -- expecting
   View State
   11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
   2268)
   11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
   2284)
   11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
   android.app.ActivityThread.access$1800(ActivityThread.java:112)
   11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
   android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
   11-24 07:52:12.539: ERROR

[android-developers] Re: Activity [sometimes] throws Wrong state class exception when being resumed after kill

2009-11-24 Thread Streets Of Boston
Thank you, Dianne.

This is in my log:
11-24 21:29:16.706: VERBOSE/smugdroid(12341): Bundle Instance is
android.view.view$basesavedst...@4325ac40
11-24 21:29:16.706: VERBOSE/smugdroid(12341):
BaseSavedState.EMPTY_STATE instance is android.view.AbsSavedState
$...@400681f0

Where 'bundle instance' is the value of 'parcelable'.
And the second one is the value of BaseSavedState.EMPTY_STATE.

As you can see, they are not the same object -- If i would just pass
'parcelable' to the super-class' method, an exception would be throw:

Snippet from android/view/View.java:
protected void onRestoreInstanceState(Parcelable state) {
mPrivateFlags |= SAVE_STATE_CALLED;
if (state != BaseSavedState.EMPTY_STATE  state != null) {
throw new IllegalArgumentException(Wrong state class --
expecting View State);
}
}




On Nov 24, 9:04 pm, Dianne Hackborn hack...@android.com wrote:
 What type of view is it?  There are only a handful of view classes that
 actually save and restore state (TextView and a few others).  What type of
 object is it returning?  (You could print the state bundle in
 onSaveInstanceState().)...

 read more »

 On Tue, Nov 24, 2009 at 4:41 PM, Streets Of Boston
 flyingdutc...@gmail.comwrote:



  Thanks Romain,

  Did not work... still the exception...

  It occurs on a View with an ID set to 'container'.
  And i went into my View hierarchy to check. All looks fine.:
  There is only one view with the id set to 'container'.
  Every other view in the hierarchy has a unique name or no id at all.

  And still i get the exception after my process is killed, restarted
  and my view is about to be restored
  Doing super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE); gets
  rid of that exception.

  Here's my code-snippet.
  @Override
  protected void onRestoreInstanceState(Parcelable parcelable) {
         if (parcelable instanceof ViewBundle) {
                 final ViewBundle  viewBundle = (ViewBundle)parcelable;
                 mSaveState = viewBundle.getBundle();

                 // Note that mRestoredBitmapOffFullSizedImage can be null!
                 // It won't be null on a configuration change, but it may be
                 // after this view's process/activity is restarted.
                 mRestoredBitmapOffFullSizedImage =
  (Bitmap)viewBundle.getTransient
  (bitmapholder);
                 super.onRestoreInstanceState(viewBundle.getSuperState());
         }
         else {
                 // TODO
                 // This exception can be thrown when:
                 //     Do edit image (Effects)
                 //     Open Dialer app, make sure process
  smugdroid.process.pictures
  is killed.
                 //     Then return to SnapFX --
                 // java.lang.IllegalArgumentException: Wrong state class --
  expecting View Sate.
                 // Fixed it by always using BaseSavedState.EMPTY_STATE
  instead of
  'parcelable'
                 super.onRestoreInstanceState(parcelable); // -- Exception
  happens
  here when using 'parcelable'.
          }
  }

  On Nov 24, 5:57 pm, Romain Guy romain...@google.com wrote:
   That would be worrisome because we do not save/restore the state of
   views without ids.

   On Tue, Nov 24, 2009 at 2:39 PM, Streets Of Boston

   flyingdutc...@gmail.com wrote:
I'm going to check that out.

What if it occurs on a View without an ID?

Thanks!

On Nov 24, 11:27 am, Romain Guy romain...@google.com wrote:
This would happen if you have several views of different type with the
same id inside a single view hierarchy. This could cause other
problems so I really advise you to not hack around the default
implementation of onRestoreInstanceState()  but make sure that your UI
is setup correctly.

On Tue, Nov 24, 2009 at 7:28 AM, Streets Of Boston

flyingdutc...@gmail.com wrote:
 i've seen this too.
 I got around it by overriding the problematic View's
 onRestoreInstanceState method:

 public void onRestoreInstanceState(Bundle savedState) {
  ...
  ...
  super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE);
 }

 I took a look at the android.view.View's implementation of this
 onRestoreInstanceState method and it only expects the
 BaseSavedState.EMPTY_STATE as valid input. It checks for if
 (savedState != BaseSavedState.EMPTY_STATE)  then throw exception ...

 For me it went wrong because 'savedState' is no longer the actual
 BaseSavedState.EMPTY_STATE instance but a de-serialized copy of it
 (after the killed process has been restored/restarted) and this
  means
 that the '!=' operator returns true and an exception is thrown.

 On Nov 24, 10:08 am, Mark Wyszomierski mar...@gmail.com wrote:
 Hi,

 I'm testing how my app behaves when killed by the OS due to low
  memory
 conditions. I always have three activities on the stack, like:

    A  B  C  (then C launches maps or some

[android-developers] Re: Activity [sometimes] throws Wrong state class exception when being resumed after kill

2009-11-24 Thread Streets Of Boston
Thank you, Dianne.
This is in my log:


From onSaveInstanceState, this one is being saved:
11-24 21:38:52.786: VERBOSE/smugdroid(12475):
  Saved Bundle Instance is
com.streetsofboston.smugdroid.snapfx.images.SnapFXImageViewContainer
$viewbun...@432e6760


From onRestoreInstanceState, this is printend:
11-24 21:29:16.706: VERBOSE/smugdroid(12341):
  Bundle Instance is android.view.view$basesavedst...@4325ac40
11-24 21:29:16.706: VERBOSE/smugdroid(12341):
  BaseSavedState.EMPTY_STATE instance is android.view.AbsSavedState
$...@400681f0

Where 'bundle instance' is the value of 'parcelable'.
And the second one is the value of BaseSavedState.EMPTY_STATE.



As you can see, they are not the same object -- If i would just pass
'parcelable' to the super-class' method, an exception would be throw:

Snippet from android/view/View.java:
protected void onRestoreInstanceState(Parcelable state) {
  mPrivateFlags |= SAVE_STATE_CALLED;
  if (state != BaseSavedState.EMPTY_STATE  state != null) {
throw new IllegalArgumentException(Wrong state class -- expecting
View State);
  }
}


Also strange is that my original ViewBunlde instance is not sent to
onRestoreInstanceState.. why is that?

On Nov 24, 9:04 pm, Dianne Hackborn hack...@android.com wrote:
 What type of view is it?  There are only a handful of view classes that
 actually save and restore state (TextView and a few others).  What type of
 object is it returning?  (You could print the state bundle in
 onSaveInstanceState().)...

 read more »

 On Tue, Nov 24, 2009 at 4:41 PM, Streets Of Boston
 flyingdutc...@gmail.comwrote:



  Thanks Romain,

  Did not work... still the exception...

  It occurs on a View with an ID set to 'container'.
  And i went into my View hierarchy to check. All looks fine.:
  There is only one view with the id set to 'container'.
  Every other view in the hierarchy has a unique name or no id at all.

  And still i get the exception after my process is killed, restarted
  and my view is about to be restored
  Doing super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE); gets
  rid of that exception.

  Here's my code-snippet.
  @Override
  protected void onRestoreInstanceState(Parcelable parcelable) {
         if (parcelable instanceof ViewBundle) {
                 final ViewBundle  viewBundle = (ViewBundle)parcelable;
                 mSaveState = viewBundle.getBundle();

                 // Note that mRestoredBitmapOffFullSizedImage can be null!
                 // It won't be null on a configuration change, but it may be
                 // after this view's process/activity is restarted.
                 mRestoredBitmapOffFullSizedImage =
  (Bitmap)viewBundle.getTransient
  (bitmapholder);
                 super.onRestoreInstanceState(viewBundle.getSuperState());
         }
         else {
                 // TODO
                 // This exception can be thrown when:
                 //     Do edit image (Effects)
                 //     Open Dialer app, make sure process
  smugdroid.process.pictures
  is killed.
                 //     Then return to SnapFX --
                 // java.lang.IllegalArgumentException: Wrong state class --
  expecting View Sate.
                 // Fixed it by always using BaseSavedState.EMPTY_STATE
  instead of
  'parcelable'
                 super.onRestoreInstanceState(parcelable); // -- Exception
  happens
  here when using 'parcelable'.
          }
  }

  On Nov 24, 5:57 pm, Romain Guy romain...@google.com wrote:
   That would be worrisome because we do not save/restore the state of
   views without ids.

   On Tue, Nov 24, 2009 at 2:39 PM, Streets Of Boston

   flyingdutc...@gmail.com wrote:
I'm going to check that out.

What if it occurs on a View without an ID?

Thanks!

On Nov 24, 11:27 am, Romain Guy romain...@google.com wrote:
This would happen if you have several views of different type with the
same id inside a single view hierarchy. This could cause other
problems so I really advise you to not hack around the default
implementation of onRestoreInstanceState()  but make sure that your UI
is setup correctly.

On Tue, Nov 24, 2009 at 7:28 AM, Streets Of Boston

flyingdutc...@gmail.com wrote:
 i've seen this too.
 I got around it by overriding the problematic View's
 onRestoreInstanceState method:

 public void onRestoreInstanceState(Bundle savedState) {
  ...
  ...
  super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE);
 }

 I took a look at the android.view.View's implementation of this
 onRestoreInstanceState method and it only expects the
 BaseSavedState.EMPTY_STATE as valid input. It checks for if
 (savedState != BaseSavedState.EMPTY_STATE)  then throw exception ...

 For me it went wrong because 'savedState' is no longer the actual
 BaseSavedState.EMPTY_STATE instance but a de-serialized copy of it
 (after the killed process has been restored/restarted

[android-developers] Re: Activity [sometimes] throws Wrong state class exception when being resumed after kill

2009-11-24 Thread Streets Of Boston
I fixed my particular situation.

I forgot to implement the static CREATOR in my own ViewBundle class
(which extends BaseSavedState).
This prevented the construction of new ViewBundle classes. I just
added the static CREATOR variable and all goes well.

However, should the above exception still happen, despite me coding
the ViewBundle incorrectly?


On Nov 24, 9:43 pm, Streets Of Boston flyingdutc...@gmail.com wrote:
 Thank you, Dianne.
 This is in my log:

 From onSaveInstanceState, this one is being saved:
 11-24 21:38:52.786: VERBOSE/smugdroid(12475):
   Saved Bundle Instance is
 com.streetsofboston.smugdroid.snapfx.images.SnapFXImageViewContainer
 $viewbun...@432e6760

 From onRestoreInstanceState, this is printend:
 11-24 21:29:16.706: VERBOSE/smugdroid(12341):
   Bundle Instance is android.view.view$basesavedst...@4325ac40
 11-24 21:29:16.706: VERBOSE/smugdroid(12341):
   BaseSavedState.EMPTY_STATE instance is android.view.AbsSavedState
 $...@400681f0

 Where 'bundle instance' is the value of 'parcelable'.
 And the second one is the value of BaseSavedState.EMPTY_STATE.

 As you can see, they are not the same object -- If i would just pass
 'parcelable' to the super-class' method, an exception would be throw:

 Snippet from android/view/View.java:
 protected void onRestoreInstanceState(Parcelable state) {
   mPrivateFlags |= SAVE_STATE_CALLED;
   if (state != BaseSavedState.EMPTY_STATE  state != null) {
     throw new IllegalArgumentException(Wrong state class -- expecting
 View State);
   }

 }

 Also strange is that my original ViewBunlde instance is not sent to
 onRestoreInstanceState.. why is that?

 On Nov 24, 9:04 pm, Dianne Hackborn hack...@android.com wrote:



  What type of view is it?  There are only a handful of view classes that
  actually save and restore state (TextView and a few others).  What type of
  object is it returning?  (You could print the state bundle in
  onSaveInstanceState().)...

  read more »

  On Tue, Nov 24, 2009 at 4:41 PM, Streets Of Boston
  flyingdutc...@gmail.comwrote:

   Thanks Romain,

   Did not work... still the exception...

   It occurs on a View with an ID set to 'container'.
   And i went into my View hierarchy to check. All looks fine.:
   There is only one view with the id set to 'container'.
   Every other view in the hierarchy has a unique name or no id at all.

   And still i get the exception after my process is killed, restarted
   and my view is about to be restored
   Doing super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE); gets
   rid of that exception.

   Here's my code-snippet.
   @Override
   protected void onRestoreInstanceState(Parcelable parcelable) {
          if (parcelable instanceof ViewBundle) {
                  final ViewBundle  viewBundle = (ViewBundle)parcelable;
                  mSaveState = viewBundle.getBundle();

                  // Note that mRestoredBitmapOffFullSizedImage can be null!
                  // It won't be null on a configuration change, but it may 
   be
                  // after this view's process/activity is restarted.
                  mRestoredBitmapOffFullSizedImage =
   (Bitmap)viewBundle.getTransient
   (bitmapholder);
                  super.onRestoreInstanceState(viewBundle.getSuperState());
          }
          else {
                  // TODO
                  // This exception can be thrown when:
                  //     Do edit image (Effects)
                  //     Open Dialer app, make sure process
   smugdroid.process.pictures
   is killed.
                  //     Then return to SnapFX --
                  // java.lang.IllegalArgumentException: Wrong state class --
   expecting View Sate.
                  // Fixed it by always using BaseSavedState.EMPTY_STATE
   instead of
   'parcelable'
                  super.onRestoreInstanceState(parcelable); // -- Exception
   happens
   here when using 'parcelable'.
           }
   }

   On Nov 24, 5:57 pm, Romain Guy romain...@google.com wrote:
That would be worrisome because we do not save/restore the state of
views without ids.

On Tue, Nov 24, 2009 at 2:39 PM, Streets Of Boston

flyingdutc...@gmail.com wrote:
 I'm going to check that out.

 What if it occurs on a View without an ID?

 Thanks!

 On Nov 24, 11:27 am, Romain Guy romain...@google.com wrote:
 This would happen if you have several views of different type with 
 the
 same id inside a single view hierarchy. This could cause other
 problems so I really advise you to not hack around the default
 implementation of onRestoreInstanceState()  but make sure that your 
 UI
 is setup correctly.

 On Tue, Nov 24, 2009 at 7:28 AM, Streets Of Boston

 flyingdutc...@gmail.com wrote:
  i've seen this too.
  I got around it by overriding the problematic View's
  onRestoreInstanceState method:

  public void onRestoreInstanceState(Bundle savedState

[android-developers] Re: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

2009-11-25 Thread Streets Of Boston
As in the comment in your bug-report by Romain, you're using too much
memory.
Note that you only have 16MByte total available RAM for your process,
including your bitmaps.

- Only load the bitmaps that are absolutely necessary (especially when
they become quite large).
- Load the bitmaps scaled to the size of your screen, if possible. Use
BitmapFactory.decode and set the 'inSampleSize' of your bitmap-options
to scale down the size of the bitmap to be loaded and rendered on the
screen.



On Nov 25, 12:46 pm, Matt Kanninen mathias...@gmail.com wrote:
 a href=http://code.google.com/p/android/issues/detail?id=5045;Issue
 5045/a

 http://code.google.com/p/android/issues/detail?id=5045

 On Nov 25, 9:37 am, Matt Kanninen mathias...@gmail.com wrote:



  This:
          private static final int[] glowDrawableIds={
                  R.drawable.graphic_microphoneglow_01,
                  R.drawable.graphic_microphoneglow_02,
                  R.drawable.graphic_microphoneglow_03,
                  R.drawable.graphic_microphoneglow_04,
                  R.drawable.graphic_microphoneglow_05,
                  R.drawable.graphic_microphoneglow_06,
                  R.drawable.graphic_microphoneglow_07,
                  R.drawable.graphic_microphoneglow_08,
                  R.drawable.graphic_microphoneglow_09,
                  R.drawable.graphic_microphoneglow_10
          };
  ...
  View glow = findViewById(R.id.glow);
  ..

  glow.setBackgroundResource(glowDrawableIds[scale]);

  is causing

  11-25 09:21:02.046: WARN/UsageStats(1018): Failed to persist new stats
  11-25 09:21:02.694: DEBUG/dalvikvm(2386): GC freed 298 objects / 15656
  bytes in 61ms
  11-25 09:21:02.952: ERROR/dalvikvm-heap(2386): 680-byte external
  allocation too large for this process.
  11-25 09:21:02.952: ERROR/(2386): VM won't let us allocate 680
  bytes
  11-25 09:21:02.952: DEBUG/AndroidRuntime(2386): Shutting down VM
  11-25 09:21:02.952: WARN/dalvikvm(2386): threadid=3: thread exiting
  with uncaught exception (group=0x4001b180)
  11-25 09:21:02.952: ERROR/AndroidRuntime(2386): Uncaught handler:
  thread main exiting due to uncaught exception
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):
  java.lang.OutOfMemoryError: bitmap size exceeds VM budget
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.graphics.Bitmap.nativeCreate(Native Method)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.graphics.Bitmap.createBitmap(Bitmap.java:468)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.graphics.Bitmap.createBitmap(Bitmap.java:435)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:
  323)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.graphics.drawable.Drawable.createFromResourceStream
  (Drawable.java:697)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.content.res.Resources.loadDrawable(Resources.java:1705)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.content.res.Resources.getDrawable(Resources.java:580)
  11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
  android.view.View.setBackgroundResource(View.java:7187)- 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: High performance access on static data: What is your approach?

2009-11-25 Thread Streets Of Boston
I use a RandomAccessFile for a thumbnail database. Works pretty fast
(i haven't done any exact benchmarking).


On Nov 24, 3:09 am, Marc Reichelt mcreich...@googlemail.com wrote:
 Hi!

 I am writing a program where I have to access some static data, and
 now I am looking for the best method of how to include them into the
 project.

 This is what I found out by now:

 1. Reading in the data by parsing an XML is *slow* (even using the SAX
 parser).
 2. Reading the data by parsing a CSV file is faster than loading an
 XML, but again is too slow.
 3. Putting the data into a Java file directly (e.g. by defining an
 array) fails because Dalvik says it is too large.
 4. Reading in the data using serialization is slow. The funny thing
 here is: It takes a bit longer than loading the XML file.
 5. Reading in the data from a SQLite database is the fastest method
 until now. But a bad workaround is needed: A SQLite DB can not yet be
 read directly from the resources, but instead has to be copied to the
 cache or to the SD card - even for read-only access.

 Right now I am using method 5, but I would really like to use a more
 simplified and faster solution.

 What I found out: Unserialization in Java is *fast* (reading a HashMap
 with 5000 integers and strings in 79ms on my PC), while the same
 action on my G1 takes over 13500ms. I know that I can not compare a PC
 to a mobile device. But still, there seems to be a big difference
 here. I think that the JRE directly copies the serialized data to RAM,
 while Dalvik seems to read every object step by step. Is this going to
 change in the future?

 And, most interestingly: what do you do to access lots of static
 information?

 Thanks in advance  happy hacking

 Marc Reichelt   ||  http://www.marcreichelt.de/

-- 
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: fwd: get the file path from a URI instance

2009-11-25 Thread Streets Of Boston
Thanks! I never thought about going through the file-descriptor.
But why is using the DATA column discouraged? It works fine and it's a
public column (not part of a private API or such).

On Nov 17, 12:42 pm, Dianne Hackborn hack...@android.com wrote:
 On Tue, Nov 17, 2009 at 7:06 AM, Streets Of Boston
 flyingdutc...@gmail.comwrote:

  To get the fully qualified path-name to the image-file (jpg/png),
  query the Uri of the image and obtain the value of the DATA (_data)
  column. This value is a String, the fully-qualified path to the image
  file. Then you can create a FileInputStream from this file.

 No, don't do this.  Use ContentResolver.openFile() and create a
 FileInputStream or whatever from the FileDescriptor:

 http://developer.android.com/reference/android/content/ContentProvide...,
 java.lang.String)

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


[android-developers] Re: Is there any way to display 8000 * 8000 jpeg file without OutOfMemoryException

2009-11-25 Thread Streets Of Boston
My suggestion of a RandomAccessFile would involve only *one* file.
This file is the RandomAccessFile, much like an uncompressed zip file,
containing records, each record being a sub-jpeg.

On Nov 25, 8:15 pm, James Wang jameswangc...@gmail.com wrote:
 @PJ
 Thanks for your interesting. We just want to display such picture, no
 further edition on it.
 In fact, we know sharp brought us with a phone-fax product-in-phone
 (http://www.sharp.co.jp/in-phone/index.html) with 8000*8000 photo
 displaying supports.
 Although, in-phone is not an Android Box, but it is an embedded device
 and they can do such thing. We just got curious about its implement.

 @Robert, ko5tik, Streets Of Boston
 Pre-processor is a good suggestion. But the side effect of it is too
 many chunk files on SD Card or in flash. Maybe sharp has a smarter way
 to achieve it and we just do not know.

 @Mitch
 Thanks for your message. I am reading it.

 Thanks everyone. I did not suppose so many people got interesting in
 this topic.

-- 
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: fwd: get the file path from a URI instance

2009-11-25 Thread Streets Of Boston
But if you know when you're dealing with images from the media-
provider that are stored on the SD-card, then using the
MediaStore.Images.ImageColumns.DATA column should be fine?

On Nov 25, 3:34 pm, Dianne Hackborn hack...@android.com wrote:
 That only works if the provider's data exists somewhere that is
 world-readable, which is basically only the media provider.  It really
 shouldn't be specified as a generic column, but something very specific to
 the media provider.  I would strongly recommend not using it.

 On Wed, Nov 25, 2009 at 11:29 AM, Streets Of Boston flyingdutc...@gmail.com





  wrote:
  Thanks! I never thought about going through the file-descriptor.
  But why is using the DATA column discouraged? It works fine and it's a
  public column (not part of a private API or such).

  On Nov 17, 12:42 pm, Dianne Hackborn hack...@android.com wrote:
   On Tue, Nov 17, 2009 at 7:06 AM, Streets Of Boston
   flyingdutc...@gmail.comwrote:

To get the fully qualified path-name to the image-file (jpg/png),
query the Uri of the image and obtain the value of the DATA (_data)
column. This value is a String, the fully-qualified path to the image
file. Then you can create a FileInputStream from this file.

   No, don't do this.  Use ContentResolver.openFile() and create a
   FileInputStream or whatever from the FileDescriptor:

  http://developer.android.com/reference/android/content/ContentProvide..
  .,
   java.lang.String)

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

 --
 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.- 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: Garbage collector is not recycling Activity

2009-12-01 Thread Streets Of Boston
Could be anything...
Do you hold any static references?
If so, are these static references to your Activity(s) or to objects
that may contain themselves references to your activity?


On Dec 1, 5:32 am, Jyothi Prasad ajp...@gmail.com wrote:
 Hi,

 I have an activity in my app.
 When I clicked back key the activities onDestroy is getting called.
 But, When i run Memory analyser, The activity is lying with 4.5KB size.

 Why garbage collector is not cleaning this object?

 If I open, that activity for 10 times, 9 instances of 4.5KB and one instance
 of 20.5KB is present.

 Thanks for help.

 -- Jyothi

-- 
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: Pick photo from Gallery

2009-12-01 Thread Streets Of Boston
Take a look the the Intent framework.
Start an activity given an intent (PICK_IMAGE) and this should start
any app that responds to it (Gallery or some other 3rd party program).

For examples, just take a look at the Contacts application in
Android's framework's source-code.

On Dec 1, 4:28 am, Tom thomas.coz...@gmail.com wrote:
 Nobody?

 Tom

-- 
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: animation between two activities

2009-12-02 Thread Streets Of Boston
You can attach listeners to your animation:

Attach an animation-listener to your rotate-animation. In the 'on-
animation-ended' callback of the listener, do the startActivity(...).

When the animation ends, this callback is automatically called and
will then start the activity.



On Dec 2, 3:19 am, tstanly tsai.sta...@gmail.com wrote:
 hi all,

 I design a rotate animation when activity 1 ends, and then start
 activity 2.
 so my code is:
 ===when activity 1 ends function===

 rotate_animation();  //first call up the animation

 Intent i=new Intent();
 i.setClass(activity1.this,activity2.class);
 startActivity(i);

 ===
 but this code will not saw the animation totally,
 that's means, the animation will pop up a second then soon activity2
 start!
 but I need the animation play over, then the activity 2 start.

 so how I do for that requestion?
 I almost use the threadhandler to do, but it wasn't work.

 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: Gridview loads in reverse on onConfigurationChanged

2010-01-17 Thread Streets Of Boston
I've seen this too in my app.

If you add a layout-animation, that animates the grid-view children
(i.e. the grid-items), you can clearly see this reverse order.

On Jan 17, 4:03 am, Mike M mike.mos...@gmail.com wrote:
 Hey everyone,

 I have a gridview of images that I load from the internet.  When the
 phone rotates (or some other config change), onConfigurationChanged()
 is called.  When that happens, the items in the gridview are reversed
 (meaning, the 1st image is the last; they are in reverse order).

 Does anyone know why this is or how to change it?   I'm hoping someone
 has run into this before...

 Sorry if I don't share any code.  I don't think It'd help; it's more
 of a conceptual question.

 Thanks,

 Mike
-- 
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: ATTENTION ANDROID TEAM: Take back control of Android.

2010-01-17 Thread Streets Of Boston
That's how it works.

You can have only *one* version of an app. Your app's ID is determined
by its package-name. The code in your app should be able to run on a
phone with an OS equal to minSdkVersion or higher.

You can specify that your app only supports (i.e. runs on) a certain
number of SDKs:

minSdkVersion: Any user with a phone with an OS lower than this
version, won't see the app in the Market and the OS won't allow it to
be installed.

targetSdkVersion: Tells the software that an OS equal to this version
running the app, needs no 'compatibility' code to be able to run this
app.

maxSdkVersion: Any user with a phone with an OS higher than this
version, won't see the app in the Market and the OS won't allow it to
be installed.


On Jan 17, 5:14 pm, Kevin Duffey andjar...@gmail.com wrote:
 Man..now that sucks. That is a bug if you ask me.. the market should NOT
 show a 1.5 users a 1.6 SDK app update. That's just pure stupidity. That
 makes no sense at all and I am shocked and disturbed that this is how it
 works. They basically want you to submit a brand new 1.6 app so that 1.5
 users don't get the update.. how hard is it to actually put a little code in
 the market app that checks the min SDK and even IF the user has the app, if
 their OS is not 1.6, don't show it. Very bad design of the market app
 developers/designers.

 On Sun, Jan 17, 2010 at 2:03 PM, Christine christine.kar...@gmail.comwrote:



  On Jan 17, 9:26 pm, Kevin Duffey andjar...@gmail.com wrote:
   First.. let me ask for those of you that have apps in the market.. if I
  have
   a 1.5 version out there.. it shows up on any device that is 1.5 or later,
   right? Now..if I update it to run on 2.0.. will the update be made
  available
   or even notify 1.5/1.6 users? Or does it only show up for 2.0 and later
   users in their market?

  By specifiying minSdkVersion and maxSdkVersion, you can provide
  different versions for different sdks. Every user would only see one
  version in the market, if I'm not mistaken. But you don't really want
  to do that unless you really need those different versions.

  --
  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- 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: Gridview loads in reverse on onConfigurationChanged

2010-01-18 Thread Streets Of Boston
Hi Roman,

It does happen. :-)

I can reproduce it almost every time like this:
- Just create an activity with a Grid View with quite a few images (or
grid-items) and attach a grid-layout-animator to the grid-view.
Configure the grid-view-animator in such a way that you see how the
grid-view-items are laid-out. E.g. columns first, rows later.
- Create an (empty) sub-activity that can be launched from the one
having the grid-view.


- Start your grid-view's activiy in portrait orientation.
- Start your sub-activity.
- Rotate your phone into landscape orientation.
- Press back to finish the sub-activity.
  The grid-view's activity is shown again and...

... 9 out of 10 times, i see the grid-view being built up in reverse
mode (i'm running on 2.1, Nexus One).

In my app, the 'getView()' method does not rely on the order in which
the 'getView()' is called at all.

On Jan 18, 2:15 am, Romain Guy romain...@android.com wrote:
 I have never noticed such an issue. The only way I can think of that
 would cause this to happen would be if your adapter relies on the
 order of the getView() calls. Note there is absolutely no guarantee
 about the order in which getView() will be called (the position
 argument will not necessarily be sequential, incrementing or
 decrementing.)





 On Sun, Jan 17, 2010 at 8:57 PM, Mike M mike.mos...@gmail.com wrote:
  Streets of Boston,

  Thanks for the reply.  I do have an animation on my GridView, but I
  took it off and still notice the problem.

  Any ideas?

  Thanks

  On Jan 17, 1:23 pm, Streets Of Boston flyingdutc...@gmail.com wrote:
  I've seen this too in my app.

  If you add a layout-animation, that animates the grid-view children
  (i.e. the grid-items), you can clearly see this reverse order.

  On Jan 17, 4:03 am, Mike M mike.mos...@gmail.com wrote:

   Hey everyone,

   I have a gridview of images that I load from the internet.  When the
   phone rotates (or some other config change), onConfigurationChanged()
   is called.  When that happens, the items in the gridview are reversed
   (meaning, the 1st image is the last; they are in reverse order).

   Does anyone know why this is or how to change it?   I'm hoping someone
   has run into this before...

   Sorry if I don't share any code.  I don't think It'd help; it's more
   of a conceptual question.

   Thanks,

   Mike

  --
  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- 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: Hprof dump support in SDK 2.1

2010-01-19 Thread Streets Of Boston
It works quite well on 2.1 (and on 2.0, but i'm not sure, i just tried
it on 2.1 with my nexus).

When you do a hprof-dump and have the proper plugins installed in
Eclipse, you get nice charts and graphs of your app's memory usage.

I'm not sure how it works, but i think the device dumps a proprietary
hprof format for Dalvik, which then gets automatically converted into
the 'standard' hprof format and then displayed as charts and graphs.


On Jan 19, 9:13 am, kohlerm markus.koh...@gmail.com wrote:
 Hi all,
 It seems ddms now has a dump hprof button (since 2.0?). Though it
 doesn't seem to work
 with an Android 1.5 device (HTC Hero) it's greyed out and says that
 hprof dumps are not supported on this VM.

 I know who to still get the heap dump anyway, but I'm asking myself
 Why is that?- Are newer devices really able to dump directly in
 hprof format?

 Regards,
 Markus
-- 
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: Gridview loads in reverse on onConfigurationChanged

2010-01-19 Thread Streets Of Boston
The animation is not necessary to make it happen. It just makes it
really easy to actually see the issue :-)

On Jan 19, 6:06 pm, Mike M mike.mos...@gmail.com wrote:
 yeah,
 I get the same on Droid 2.0, Although I get it without having
 animation applied to the gridview...

 I wish there was a uniform / sequential way that getView() was
 called...

 On Jan 18, 5:29 pm, Streets Of Boston flyingdutc...@gmail.com wrote:



  Hi Roman,

  It does happen. :-)

  I can reproduce it almost every time like this:
  - Just create an activity with a Grid View with quite a few images (or
  grid-items) and attach a grid-layout-animator to the grid-view.
  Configure the grid-view-animator in such a way that you see how the
  grid-view-items are laid-out. E.g. columns first, rows later.
  - Create an (empty) sub-activity that can be launched from the one
  having the grid-view.

  - Start your grid-view's activiy in portrait orientation.
  - Start your sub-activity.
  - Rotate your phone into landscape orientation.
  - Press back to finish the sub-activity.
    The grid-view's activity is shown again and...

  ... 9 out of 10 times, i see the grid-view being built up in reverse
  mode (i'm running on 2.1, Nexus One).

  In my app, the 'getView()' method does not rely on the order in which
  the 'getView()' is called at all.

  On Jan 18, 2:15 am, Romain Guy romain...@android.com wrote:

   I have never noticed such an issue. The only way I can think of that
   would cause this to happen would be if your adapter relies on the
   order of the getView() calls. Note there is absolutely no guarantee
   about the order in which getView() will be called (the position
   argument will not necessarily be sequential, incrementing or
   decrementing.)

   On Sun, Jan 17, 2010 at 8:57 PM, Mike M mike.mos...@gmail.com wrote:
Streets of Boston,

Thanks for the reply.  I do have an animation on my GridView, but I
took it off and still notice the problem.

Any ideas?

Thanks

On Jan 17, 1:23 pm, Streets Of Boston flyingdutc...@gmail.com wrote:
I've seen this too in my app.

If you add a layout-animation, that animates the grid-view children
(i.e. the grid-items), you can clearly see this reverse order.

On Jan 17, 4:03 am, Mike M mike.mos...@gmail.com wrote:

 Hey everyone,

 I have a gridview of images that I load from the internet.  When the
 phone rotates (or some other config change), onConfigurationChanged()
 is called.  When that happens, the items in the gridview are reversed
 (meaning, the 1st image is the last; they are in reverse order).

 Does anyone know why this is or how to change it?   I'm hoping 
 someone
 has run into this before...

 Sorry if I don't share any code.  I don't think It'd help; it's more
 of a conceptual question.

 Thanks,

 Mike

--
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- Hide quoted 
   text -

   - Show quoted text -- 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: Understanding how the Final keyword in Android Works

2010-01-20 Thread Streets Of Boston
The 'final' keyword is not android specific.

It is a java keyword that declares that the variable-reference can
never be changed after it has been defined.

e.g.

final int x;
x = 10; // OK
x = 20; // Compiler error, since x is declared final and cannot be
changed.

final String age;
if (x = 0)
  age = nothing; // OK
else
  age = Integer.toString(x); //OK

if (somethingElse)
  age = someOtherValue; // Compiler error, since age is final and  may
already have been defined.

Why use final:
- Some compilers may be able to optimize better if a variable is
declared to be 'final'.
- Ensure that a variable doesn't get assigned another value
accidentally.

I'm not sure if this is true for the DalvikVM, but i tend to use
'final' a lot more for embedded device development. Maybe DalvikVM
will tend to use registers more for 'final' variables...?

For regular Java developent (J2EE), it is less important to use
'final'. It actually adds to the syntactic sugar.

On Jan 20, 12:35 pm, tim hansen timhansen.lon...@googlemail.com
wrote:
 Hi all,
 Can anyone explain why, when I use the Final keyword the following code
 works fine, but without it, it doesn't?

 I just find it irritating that I don't understand why it works! ;)

 Thanks in advance!

 Tim.

 public class PowerLangMaxMain extends Activity {

      private Button btnSave;

     �...@override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);

           final Builder builder = new AlertDialog.Builder(this);

          builder.setTitle(Confirm);
          builder.setMessage(Save to Database);
          builder.setPositiveButton(ok, null);
          builder.setNegativeButton(cancel, null);

          DBAdapter db = new DBAdapter(this);

          btnSave = (Button)findViewById(R.id.save_button);

          btnSave.setOnClickListener(new OnClickListener() {
           @Override
           public void onClick(View v) {
            builder.show();
           }
          });
      }



 }- 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: Confusion about using Camera to take pictures from my application

2010-01-20 Thread Streets Of Boston
I'm going to upload a camera app in the market soon that does provide
the Uri to full-sized images. If your intent requires an in-memory
bitmap, it is still a small-sized image (100KBytes in size), but the
Uri should point to the size of the image as it was taken by the
camera.

I'm still writing up the help text and testing it out on various
devices.

On Jan 19, 2:18 pm, Neil ntr...@gmail.com wrote:
 I'm trying to do this too, except I want a full-sized picture.  I have
 it working.  I'm using your code, but without all the extras (maybe
 those extras are causing your error?)  My code:

 File tmpFile = new File(Environment.getExternalStorageDirectory(),
                         tmp_ + String.valueOf(System.currentTimeMillis()) + 
 .jpg);
 Intent imgCapture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
 imgCapture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile));

 // in the activity result:
 if (resultCode == Activity.RESULT_CANCELED) {
         return;}

 try {
         imageView.setImageBitmap(BitmapFactory.decodeStream(new
 FileInputStream(tmpFile)));} catch (Exception e) {

         Log.e(Constants.LOG_TAG, Unable to load image content, e);}

 tmpFile.delete();

 One problem with this is that my app doesn't have permission to delete
 the temp file.  I can't point the camera to my app's files/ directory
 because the Camera activity doesn't have access to my files.  Do you
 know how to provide a content provider URI that both activities would
 have read/write access to?  I haven't had the chance to read much
 about content providers yet...

 The other problem is, this will only return a 512x384 image.  Without
 the EXTRA_OUTPUT the image returned is even smaller (192x256).  For
 you, this might be okay.  You can probably scale the image down to
 64x64 using some Bitmap or Matrix methods (not sure how to do that).

 For me, this is unacceptable, and from what I can tell the only way to
 get a full size image is to use the Camera API and ditch the Camera
 activity altogether :-(.  See the comments 
 here:http://code.google.com/p/android/issues/detail?id=1480

 Btw, if you are using the external storage to store the picture, you
 may want to check that it exists first:

 String storageState = Environment.getExternalStorageState();
 if (!Environment.MEDIA_MOUNTED.equals(storageState)) {
         // If there's no storage media, our intents won't work.
         return;

 }

 Let me know if you find anything more!  I'm going to keep looking...

 To everyone else reading this:
 Is there a way to get a full sized picture from the Camera activity?
 Or do I have to roll my own?  That would be SUPER lame.  If I do have
 to make my own activity, can someone point me to some example code?
 Thanks in advance!

 -- Neil

 On Jan 7, 7:10 am, rben ray.benja...@gmail.com wrote:



  I've been trying to write an application that uses the Camera App to
  take a picture. So far, the only thing I've been able to get back
  successfully is a tiny bitmap picture. I've found several other posts
  related to this topic that have code that is reported to work, but it
  does not work for me. I'm hoping someone can steer me in the right
  direction.

  Below is the code I am using currently, but it causes the application
  to blow up.

          private void takePicture(final int x, final int y, String
  description) {
                  // create a file on the SD card
                  File file = new 
  File(Environment.getExternalStorageDirectory(),
                                  tmp_ + 
  String.valueOf(System.currentTimeMillis()) +
                                  .jpg);
                  // Create the URI that tells the camera where to put the 
  picture.
                  mOutputFileUri = Uri.fromFile(file);
                  statusLine.setText(URI =  + mOutputFileUri);
                  mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                          .putExtra(MediaStore.EXTRA_OUTPUT, mOutputFileUri)
                          .putExtra(PIC_X, x)  // x coordinate of square
                          .putExtra(PIC_Y, y)  // y coordinate of square
                          .putExtra(PIC_DESCRIP,description)
                          .putExtra(return-data, true)
                          ;
                  startActivityForResult(mIntent, PIC_FROM_CAMERA);
          }

  Ultimately, I want to be able to get the picture back and do two
  things with it: create a 64x64 icon that is displayed by the Android
  application, and upload the picture to a web application.

  Thank you for any help or advice you can give.
  Oh, btw, I'm running this on the emulator using Android 2.0

  Thanks,
    Ray- 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

[android-developers] Re: Creating dialogs from a thread

2010-01-21 Thread Streets Of Boston
Dirk,

You cannot create UI elements in threads that don't have a message-
looper themselves.

I usually do this.
Call the 'post' (or 'postDelayed') method.

In your example, I assume that the method getEpisodes() is part of a
Thread instances that is defined as a non-static inner (anonymous)
class of your activity. This means that you can call 'post' inside
your getEpisodes() method:


private void getEpisodes() {
try {
episodes = myEpisodesService.retrieveEpisodes
(user);
} catch (InternetConnectivityException e) {
String message = Could not connect to host;
Log.e(LOG_TAG, message, e);
exceptionMessageResId =
R.string.internetConnectionFailureReload;

post(new Runnable() {
   public void run() {
  showDialog(EXCEPTION_DIALOG);
   }
});

}
runOnUiThread(returnEpisodes);
}

If your Thread is not an inner class of your Activity and you
therefore can't call 'post', give your thread a reference to your
activity:

private void getEpisodes() {
try {
episodes = myEpisodesService.retrieveEpisodes
(user);
} catch (InternetConnectivityException e) {
String message = Could not connect to host;
Log.e(LOG_TAG, message, e);
exceptionMessageResId =
R.string.internetConnectionFailureReload;

mMyActivity.post(new Runnable() {
   public void run() {
  showDialog(EXCEPTION_DIALOG);
   }
});

}
runOnUiThread(returnEpisodes);
}


On Jan 21, 4:30 pm, Dirk Vranckaert dirkvrancka...@gmail.com wrote:
 It seems your solution does not work either. As long as I'm doing it
 in a thread it doesn't work.

 Altough what I tried next was setting the error message for the user
 in my catch clause. And right after the thread finished I handled the
 showing of the errors based on wheater some error message was set or
 not!

 Thx for your help! (If you get me some advanced explanation on why
 dialogs cannot be created from within a thread plz let me know!)

 On 21 jan, 20:47, Dirk Vranckaert dirkvrancka...@gmail.com wrote:



  I certainly will try it out later this evening (studying for my
  certification right now) but is there any more detailed/advanced
  explanation about why I can't run a bunch of code in a thread and at
  the end of the thread start a dialog? Why I have to start a nested
  thread with just the dialog creation? :s Still don't really get the
  reason why...

  Anyway thx in advance for giving me a possible working solution, and
  I'll certainly keep you informed if it did the job for me (later this
  evening).

  On 21 jan, 19:47, TreKing treking...@gmail.com wrote:

   On Thu, Jan 21, 2010 at 12:28 PM, Dirk Vranckaert
   dirkvrancka...@gmail.comwrote:

So if I understand you correct I should run two nested threads to show
the dialog?

   Yup. So instead of showDialog(int) in the thread, do
   runOnUiThread(someThread); where someThread just calls showDialog(int) in
   it's run method.

   Yes, it's annoying and messy, but you can't do UI related operations in
   separate threads, so there you go.

   ---­--
   TreKing - Chicago transit tracking app for Android-powered 
   deviceshttp://sites.google.com/site/rezmobileapps/treking- 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: Activity.finish() x System.exit

2010-01-21 Thread Streets Of Boston
System.exit() kills your entire process.
activity.finish() just hides, stops and destroys your activity. Your
process is still running.

You should not call System.exit(). It could mess up Android's handling
of the lifecycles of your activities and result in an awkward user-
experience (e.g. when killing the process, the previous activity from
which you laucnhed your activity may be gone as well. Android may try
to restart the process again and re-create that accidentally killed
parent-activity... but still).

On Jan 21, 3:46 pm, guiha...@gmail.com guiha...@gmail.com wrote:
 Hi,

 I've been using System.exit to quit the application. Is
 Activity.finish a better approach? What would be the differences?

 thx

    guich
-- 
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: Serious android app problem in Canada

2010-01-21 Thread Streets Of Boston
Some (very) small consolation.
Try, for now, to offer your app through other markets, such as
SlideMe, Handango, MobiHand, etc.

On Jan 21, 12:57 pm, Alex ixsan...@gmail.com wrote:
 No, you cannot either upload or download paid apps from android market
 in Canada.
 We are in the same boat and I've been waiting for this for the last
 one year.

 ~ Sad Android Developer from Canada

 On Jan 19, 8:11 am, ian stilbit...@gmail.com wrote:



  Hey Candroid developers:

  Now I hope I'm wrong but it appears as an Android developer in Canada
  I cannot sell my apps through the |Market, nor can a Canadian customer
  purchase my paid apps.

  Are these dire concerns valid?

  Maybe somebody from the Google mothership could clarify this important
  matter as soon as possible.

  The Android Market accepted my developer fee of $25 no problem.  And I
  don't recall any restrictions mentioned for Canadian developers or for
  paid apps in Canada.

  I worry that  hundreds of hours of my work may have been wasted.

  Like most Canadian Android developers who share these concerns, I am
  considering putting my Android development on hold immediately and
  perhaps permanently, and porting my apps to iPhone and/or Pre.

  Any other Canucks feel the same way?- 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: Creating dialogs from a thread

2010-01-21 Thread Streets Of Boston
Note that 'post' and 'runOnUiThread' takes a Runnable and it should
*not* be a Thread (although that implements Runnable as well)! (Mis)
using a Thread for this is not good. Just use a Runnable.

Create a new instance of a Runnable and implement its 'public void run
()' method (see my example code in my previous post).

On Jan 21, 4:50 pm, TreKing treking...@gmail.com wrote:
 On Thu, Jan 21, 2010 at 3:30 PM, Dirk Vranckaert
 dirkvrancka...@gmail.comwrote:

  It seems your solution does not work either.

 Um ... it should, I've used this technique repeatedly. Can you post the code
 you're using?

  As long as I'm doing it in a thread it doesn't work.

 Well, it depends on how you're running the thread. If you're posting it to
 the runOnUiThread() function, it should work. If you're starting it with
 Thread.start(), then yeah, that won't work. Again, some code would clarify.

  Altough what I tried next was setting the error message for the user
  in my catch clause. And right after the thread finished I handled the
  showing of the errors based on wheater some error message was set or
  not!

 I'm not sure I follow here.

  Thx for your help! (If you get me some advanced explanation on why
  dialogs cannot be created from within a thread plz let me know!)

 Probably because of the complexities of ensuring thread safety. If you could
 update the UI from any thread, you could run into various threading issues
 (deadlocks, race conditions, etc). If they core framework were designed to
 support this it would introduce more complexity and overhead to the system.
 Just a guess, but again, this is pretty standard behavior in GUI systems, so
 it's really something that's just accepted.

 ---­--
 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: How to close an application?

2010-01-21 Thread Streets Of Boston
If you want to make sure that your app shuts down completely:
- Implement onPause to pause any threads running in the background (if
you have any)
- Implement onDestroy to clean up any other resources (stop threads,
if any, for example)

Short of the user pulling the battery, the onPause is guaranteed to be
called.
If the onDestroy is not called, your process has been killed
forcefully by Android -- resources are cleanup anyway.

It is absolutely not necessary to do a System.exit() and can result in
the behavior described by Pink444 (restarting of the process and
activity). Even the Anrdroid apps that do implement a 'Quit' or 'Exit'
button, most (i hope all) of them just do a call to 'finish()' and
clean up stuff in the onDestroy. They should not ever call System.exit
().

For apps that behave badly and leave threads actively running when
their activities are in the background: They indeed will drain the
battery. The user can figure this out, though (Battery info) and kill
or even uninstall the app. For your app, just make sure your app
behaves gracefully :-) ... it's in your control.

It's just another model of programming model (although very close to
regular event-driven programming) and that's actually the best part
about it. I'm learning something new!

In general, you can write activities that can be called by other
activities. Your activity can be called within the process of another
activity that is not yours. Doing a System.exit() may adversely affect
the calling (parent) activity.

On Jan 21, 5:27 pm, Kevin Duffey andjar...@gmail.com wrote:
 I don't know if I like this model. :D I'll give you one reason that I don't
 know if it comes up or exists often, but I think it's one of the most
 confusing issues for non-techie (and even techie peeps that don't know about
 programming and threads and such) users for android devices. The problem to
 me is.. I am a developer that will without a doubt make mistakes. As such,
 if I am writing an app that otherwise seems to run fine on devices, but I've
 forgotten to stop threads when my app is paused (either by user hitting
 home/back, phone call, etc).. to the users, my app may be finished. The
 notion of not closing down an app and users getting used to that idea means
 that they need to trust every app they ever get that it wont leave some
 battery draining possibility running behind. Now, Mark I know will correct
 me if I am wrong here, I've read his first book mostly and other books on
 Android. It is up to us in every Activity to handle the pause/resume,
 create(bundle) to resume properly if the app was actually shut down and
 bundle info saved, etc. But I still can't help to think that there are thos
 eapps that have bugs in them that have either a thread left behind
 (assuming android doesn't completely shut it down) that may end up draining
 the battery. I don't know for sure, but a few times now, I've come back to
 my phone a couple hours later to find it dead, from a completely charged
 state prior. And I don't know why. My only guess is that I left something
 running, like google maps with wifi that I thought was stopped/shut down
 cause I hit the home/back button. Being a developer I know it's probably in
 a paused state, but this battery drain thing has happened a few times.

 Thus, my thought is.. to avoid my app possibly draining the battery, I'd
 rather have a quit option to exit the app completely.. it's done, unloaded,
 no threads, etc. Now on iPhone, it's well known that presently pressing the
 one button kills the apps. The apps have the option to save state info
 before shutting down, and some apps make good use of this to make it look
 like it never shut down.. restoring the user to where they were previously
 at. Most iPhone apps dont do this tho. So the thing is, this not shutting
 apps down completely is a different mind set that I honestly am surprised we
 would want to program to as developers concerned about battery drainage. I
 would think since one of the most important things when writting android
 apps is to consider battery life, would be to do everything we can to shut
 our app down if the user hits the exit button. Sure, if they hit back/home,
 or a call comes in or they go to status bar and select something, the
 pause/resume notion kicks in. But I am having a hard time understand why you
 would not want to put in an exit/quit option and cleanly shut down
 everything if they choose this? I do see some games on Android doing this.

 So Mark et all, I understand the basics of what you are saying and for some
 apps this makes perfect sense. But some, like games or those that may spawn
 threads or do other cpu intensive things that could drain battery especially
 if done in threads, it seems to me to be safe and keep our ratings of our
 apps form going down to 1 star, we'd want to program defensively and make
 sure our app shuts down completely.

 Just my .02 on the matter.

 On Thu, Jan 21, 2010 at 8:52 AM, Vladimir 

[android-developers] Re: AsyncTask discrepancy

2010-01-21 Thread Streets Of Boston
A Service, like an Activity, has a main thread with a message-loop.
You can create an AsyncTask in the onX() callbacks of Services,
just like in an Activity. The onPostExecute can do your handling of
the results, as you described.

However, AsyncTask is more geared towards the one-time executing of a
background process. E.g. retrieve some data from the internet now, or
create/process a bitmap. It is not really meant to stay in the
background forever in a loop polling for some data to come in. When
you have something like 'while (true)' or 'while (!mStopped)' or
something like it, you should not use a AsyncTask. Use a regular
Thread instead that calls 'post' on the owning Activity that will
consume the results generated by the thread.

On Jan 21, 6:22 pm, Flapjack millerhugg...@gmail.com wrote:
 According to my research, which includes reputable sources (Mark
 Murphy et al), the most preferred way of polling a remote source and
 presenting said data to the user is by creating a service and using
 AsyncTask within that service to do the polling. I have done that.

 But, when I read the docs (http://developer.android.com/reference/
 android/os/AsyncTask.html), there seem to be several Threading Rules
 that conflict with this way of doing things: The task instance must
 be created on the UI thread. and execute(Params...) must be invoked
 on the UI thread. As stated, I have created the task instance on the
 Service thread (not the UI thread). Am I missing something?

 Also, when the AsyncTask finished, I sent out a Broadcast on
 onPostExecute, which is then picked up by the Activity, telling it to
 retrieve the final value again from the service (since I couldn't
 obviously update the UI from the service). I couldn't figure out any
 other way to return the result of the AsyncTask. Is this the correct
 practice?

 Java is not my native language so please bear with my ignorance.
 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: Threading in activity and AsyncTask problem

2010-01-22 Thread Streets Of Boston
1. If your code is on onPostExecute(), your code is already running in
the UI thread. Just call a method on your activity to execute that
chunk of code (instead of holding a reference to 'context', hold a
reference to your activity instead).

2. Just call this again:
  StudentTask st = new StudentTask(getThis());
  st.execute(new Object[] {StudentTask.Task.AUTH, null, userName,
password });

Tasks are like executable messages that will be executed on a
background thread. Creating multiple tasks does not necessarily create
multiple threads. Tasks are scheduled on the available background
threads. Whenever you create a new AsyncTask and call 'execute', the
task will be scheduled on the next available thread. The next
available thread is obtained from a pool of threads (I don't know how
large the pool is that AsyncTask uses).

On Jan 22, 5:21 am, yasirmturk yasirmt...@gmail.com wrote:
 i have a class derived from AsyncTask and i initialize it in my
 activity. Now i m facing two problems...

 1. I want to send result back to my activity and execute a chunk of
 code in my activty on onPostExecute(Object result) event. (i tried
 handler but its not working)
 2. I want to execute asynctask multiple times.

 Please suggest me some better solution or a fix to this...
 thanx in advance

 ACTIVITY CODE:

                          StudentTask st = new StudentTask(getThis());
                          st.execute(new Object[] {StudentTask.Task.AUTH, 
 null, userName,
 password);

 CLASS CODE:

 public class StudentTask extends AsyncTask {

         private Context context;
         private ProgressDialog pd;

 public static enum Task {
                 SYNCRONIZE, AUTH, ACTIVATE
         }

 public StudentTask(Context context) {
                 super();
                 this.context = context;
         }

         @Override
         protected void onPreExecute() {
                 pd = ProgressDialog.show(context, Please wait, Starting);
         }

         @Override
         protected Object doInBackground(Object... params) {

                 Object result = null;
                 Task t = (Task) params[0];
                 switch (t) {
                 case AUTH:
                         if (this.authenticateStudent(params[1].toString(),
                                         params[2].toString()).IsSuccessFul()) 
 {
                                 result = true;
                         } else {
                                 result = false;
                         }
                         break;
                 case SYNCRONIZE:
 result =                        this.synchronize(null, null);
                         break;
                 default:
                         break;
                 }
                 return result;
         }

         @Override
         protected void onProgressUpdate(Object... values) {
                 pd.setMessage(values[0].toString());
                 super.onProgressUpdate(values);
         }

         @Override
         protected void onPostExecute(Object result) {
                 pd.dismiss();
                 // Send this result back to activity and execute some code 
 there
 e.g. launch next activity or display error
                 super.onPostExecute(result);
         }

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

2010-01-22 Thread Streets Of Boston
If the AsyncTask finishes executing, the thread on which the asynctask
was run just waits (Object.wait()).
The AsyncTask is based upon the ExecutorService and FutureTask classes
from the java.util.concurrent packages.

Creating a new AsyncTask does not create a new thread. An AsyncTask is
executed on one thread selected from a pool of threads (internally it
uses ExecutorService from java.util.concurrent)

If you want to have ONE thread that continuously runs in the
background (e.g. wait 5 mins, see if there's data, if so notify the
main app, start over again), use a Thread, not an AsyncTask. When you
have a 'while(true)' or some similar loop in your background-task
code, it may be a sign that you need a Thread instead.

Then in that Thread you can have a reference to your activity (e.g.
mActivity) and call runOnUiThread() on your activity. Here is a code-
example snippet from that Thread:

public void run() {
  while (!mStopped) {

sleep(fiveMinutes);

final Result result = getSomeDataFromSomehwere();

if (result.isNotEmpty()) {
  mActivity.runOnUiThread(new Runnable() {
public void run() {
mActivity.hereIsResult(result);
}
  });
}

  }
}

(above is pseudo-code... it won't compile :-))
(and i assume that mActivity is still around and kicking when
hereIsResult is called... if not, you have to use a static reference
to your currently running activity instead)





On Jan 22, 6:38 pm, Flapjack millerhugg...@gmail.com wrote:
 Streets of Boston, please forgive my ignorance. If I use AsyncTask
 within a service to retrieve data once, can I destroy the AsyncTask
 after? Or would I have to destroy the entire Service?

 Additionally, if I want to poll, say, every 5 minutes, wouldn't having
 AsyncTask in the service be a good idea, instead of tying up the
 Service, which might be needed for other operations?

 Finally, what do you mean when you said to use a regular Thread that
 calls 'post' on the owning Activity?

 On Jan 21, 10:37 pm, Streets Of Boston flyingdutc...@gmail.com
 wrote:



  A Service, like an Activity, has a main thread with a message-loop.
  You can create an AsyncTask in the onX() callbacks of Services,
  just like in an Activity. The onPostExecute can do your handling of
  the results, as you described.

  However, AsyncTask is more geared towards the one-time executing of a
  background process. E.g. retrieve some data from the internet now, or
  create/process a bitmap. It is not really meant to stay in the
  background forever in a loop polling for some data to come in. When
  you have something like 'while (true)' or 'while (!mStopped)' or
  something like it, you should not use a AsyncTask. Use a regular
  Thread instead that calls 'post' on the owning Activity that will
  consume the results generated by the thread.

  On Jan 21, 6:22 pm, Flapjack millerhugg...@gmail.com wrote:

   According to my research, which includes reputable sources (Mark
   Murphy et al), the most preferred way of polling a remote source and
   presenting said data to the user is by creating a service and using
   AsyncTask within that service to do the polling. I have done that.

   But, when I read the docs (http://developer.android.com/reference/
   android/os/AsyncTask.html), there seem to be several Threading Rules
   that conflict with this way of doing things: The task instance must
   be created on the UI thread. and execute(Params...) must be invoked
   on the UI thread. As stated, I have created the task instance on the
   Service thread (not the UI thread). Am I missing something?

   Also, when the AsyncTask finished, I sent out a Broadcast on
   onPostExecute, which is then picked up by the Activity, telling it to
   retrieve the final value again from the service (since I couldn't
   obviously update the UI from the service). I couldn't figure out any
   other way to return the result of the AsyncTask. Is this the correct
   practice?

   Java is not my native language so please bear with my ignorance.
   Thanks!- 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: AsyncTask discrepancy

2010-01-22 Thread Streets Of Boston
If your Service is running in the same process as your Activity, use a
static reference to your Activity.

E.g. MyActivity.ACTIVE_INSTANCE

Be sure to update the ACTIVE_INSTANCE in onCreate (set it to 'this')
and onDestroy (set it to 'null'). This will work when you can have
only one instance of you activity at the same time. If you can
multiple instances active, then this trick won't work.

If your Service may be running in a different process, you have to use
IDL and interprocess communication between the two.


On Jan 22, 6:31 pm, Flapjack millerhugg...@gmail.com wrote:
 Frank, if my AsyncTask is located in my Service, how can I use it to
 update the UI in my Activity? I'm a bit confused by this- I thought
 the AsyncTask would have to be located inside the Activity class in
 order to update the UI within the Activity.

 On Jan 21, 8:20 pm, Frank Weiss fewe...@gmail.com wrote:



  Please reread the doc carefully. You can run stuff on the UI thread in three
  of the methods. There's really no need to send a message if you make the
  subclass of AsyncTask an inner class. In that case those three methods can
  do anything on the enclosing Activity's behalf, like setting the contents of
  a view or showing a dialog.

  On Thu, Jan 21, 2010 at 3:22 PM, Flapjack millerhugg...@gmail.com wrote:
   According to my research, which includes reputable sources (Mark
   Murphy et al), the most preferred way of polling a remote source and
   presenting said data to the user is by creating a service and using
   AsyncTask within that service to do the polling. I have done that.

   But, when I read the docs (http://developer.android.com/reference/
   android/os/AsyncTask.html), there seem to be several Threading Rules
   that conflict with this way of doing things: The task instance must
   be created on the UI thread. and execute(Params...) must be invoked
   on the UI thread. As stated, I have created the task instance on the
   Service thread (not the UI thread). Am I missing something?

   Also, when the AsyncTask finished, I sent out a Broadcast on
   onPostExecute, which is then picked up by the Activity, telling it to
   retrieve the final value again from the service (since I couldn't
   obviously update the UI from the service). I couldn't figure out any
   other way to return the result of the AsyncTask. Is this the correct
   practice?

   Java is not my native language so please bear with my ignorance.
   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.comandroid-developers%2bunsubs­cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

  Please- 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 to repeat Login dialog and progress dialog, coordinating with http thread

2010-01-25 Thread Streets Of Boston
I haven't read your code-snippet, but here is how i would do it:

When the user wants to login, do a showDialog(idDialogLogin),
containing the username/password fields Login/Cancel buttons.

When Login is pressed, dismiss the dialog and start a progress-dialog
and the actual logging in. Handle this through an AsyncTask:
onPreExecute shows the progress dialog. The background task does the
actual logging in (through http). onPostExecute either hides it
(successful login) or just does a showDialog(idDialogLogin) again of
the login-dialog on an unsuccessful login.

When cancel is pressed, just dismiss the dialog.

On Jan 25, 9:47 am, qmwestview qmwestv...@googlemail.com wrote:
 Hi there,

 I am having a problem about repeating Login dialog (an AlertDialog)
 and progress dialog, coordinating with http thread. I suppose
 repetitive Login dialog (if fail, continue) handling should be common
 and straightforward. I guess my approach must be wrong somewhere. I
 already spent 2 days on this and am desperate. So please help.

 The usecase is like this:

 I have a main activity.

 User starts the app, the main activity starts.
 Show a login dialog (generated by the main thread, i.e. from onCreate
 ()). The main thread then starts a wait_thread, which will wait for
 http to return data and check the data and decide what to do.

 After user input username/password and press login, a progress dialog
 starts.

 The progress dialog starts an http_thread to talk to the server and
 get replies. Once done, it will notify the waiting thread.

 If the user type in the right username password first time, the code
 works fine.

 But it always fail for 2nd time Login, i.e. When first login fail
 (wrong username/password), the wait_thread will generate 2nd Login
 dialog to let user repeat the login process. But after user hit the
 login on this 2nd Login dialog, the system always crashes.

 The exception here is:

 ERROR/AndroidRuntime(21880): Uncaught handler: thread main exiting due
 to uncaught exception
 ERROR/AndroidRuntime(21880): android.view.ViewRoot
 $CalledFromWrongThreadException: Only the original thread that created
 a view hierarchy can touch its views.

 The followings are part of the code.
         ...
 public class Test extends Activity implements Constants,Runnable{
     ...

     @Override
     public void onCreate(Bundle savedInstanceState) {
         ...
         showDialog(DIALOG_LOGIN); //
                 startHttpWaitThread();
     }

     private void startHttpWaitThread(){
         try {
                 Thread dialogThread  = new Thread(this);
                 dialogThread.start();
                 } catch(Exception e){
                 //showDialog(DIALOG_LOGIN);
             }
     }
 /*     �...@override
         public void onStart() {
                 super.onStart();
         } */

     public void run(){
         Looper.prepare();

                 try {
                 synchronized(httpReplyData){ // httpReplyData holds all needed
 data returned from server
                         httpReplyData.wait();
                 }
                 } catch(Exception e) {
                         e.printStackTrace();
                 }
                 if 
 (httpReplyData.getHttpResult()!=HTTP_REPLY_STATUS_CODE_OK_200)
 showDialog(DIALOG_LOGIN);
         Looper.loop();
     }

     @Override
     protected Dialog onCreateDialog(int id) {
         switch (id) {
         case DIALOG_LOGIN:
                 return getLoginDialog(this);//,
         case DIALOG_LOGIN_PROGRESS:
                 return new LoginProgressDialog
 (ctxForLoginProgressDialog);//        }
         return null;
     }

     private Dialog getLoginDialog(Context ctx) {//, String name,
 String pwd){
         ...
                 dialogBuilder.setPositiveButton(R.string.login, new
 DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int
 whichButton) {
                         networkService.startHttpThread
 (HTTP_REQUEST_LOGIN_INDEX, getUsername(), getPassword()); //
 networkService is the HTTP manager
                         showDialog(DIALOG_LOGIN_PROGRESS); //
                         startHttpWaitThread();
                 }
             });
         return dialogBuilder.create();
     }

     private class LoginProgressDialog extends ProgressDialog
 implements Constants{
         //private ProgressThread progressThread;
                 public LoginProgressDialog(Context ctx){
                         super(ctx);
                         ...
                 }
     }

 }

 ~~~
 I also tried second approach, which moves the wait_thread into
 progress dialog class/object, following Google’s “Creating a
 ProgressDialog” (http://developer.android.com/guide/topics/ui/
 dialogs.html#ProgressDialog). The 2nd login dialog is started by the
 progress dialog. Its wait() method gets called ONLY once (that is
 before 3nd showDialog(DIALOG_LOGIN) gets called). Seems to me the
 

[android-developers] US Taxes: Does Google send a 1099 tax form?

2010-01-25 Thread Streets Of Boston
Hi,

I'm not sure where to ask this. So, here it goes :)

Does google send a 1099 to holder of a Google CheckOut account for the
Android Market.

If not, how can we know what Google has reported to the IRS?

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: Using Nexus One as a development phone: Problem with USB driver under windows 7 64 bit

2010-01-26 Thread Streets Of Boston
First unzip the zip file somewhere. You'll find an *.inf file in the
unzipped directory.

When you attach your Nexus One to your PC, you will see it in your
Devices (My Computer -- Properties -- -- Hardware/Devices or
something... i don't remember exactly how it looks on XP).

In the list of hardware devices, look for the Nexus One USB
connection.

Update the driver from this dialog. Look for the driver on a disk, on
the computer. Browse to the unzipped directory that contains the *.inf
file.


On Jan 11, 8:42 pm, 48-New courag...@gmail.com wrote:
 I'm working on Windows XP using Eclipse.  Can't attached the Nexus One
 either.  Saw the xda post below as well but not sure I know how to
 proceed onces I download and unzip the file.  Would appreciate
 somebody post a more details step by step on getting the driver
 installed and hence the adb can detect the connected Nexus One.  Many
 thnx.

 On Jan 7, 3:53 am, SoftwareForMe.com SoftwareForMe.com



 softwareforme@gmail.com wrote:
  Interesting.

  I downloaded rev 3 of the driver pack, but could not find the proper driver.

  I eventually downloaded it from a forum, 
  here:http://forum.xda-developers.com/showthread.php?t=613054

  SoftwareForMe.com
  Makers of PhoneMyPC
   Imagine Multi-touch- 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: US Taxes: Does Google send a 1099 tax form?

2010-01-26 Thread Streets Of Boston
Thanks Mark.

no different than any other business income
true, but better be safe than sorry :-)

E.g. I sell my pictures on smugmug.com and they do send a 1099 and
report earnings to the IRS. When i wrote my question, I wondered
whether Google Checkout had a similar setup.


On Jan 25, 1:21 pm, Mark Murphy mmur...@commonsware.com wrote:
 Kevin Duffey wrote:
  I asked that same thing a while ago in response to a different post, I
  don't recall getting a clear answer to this. I would think that google
  reports 1099 to IRS to keep track of all income you make... otherwise
  it's tax free which seems odd to me if you make a few grand.

 Payment processors, as a rule, do not have to file 1099's, AFAIK. I
 don't remember getting them from Amazon, PayPal, and Google Checkout
 last year. Your income comes from consumers, not Google.

 You simply have to report that income as part of your taxes, no
 different than any other business income.

 --
 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: Crop a Picture after Using Camera to Take It

2010-01-27 Thread Streets Of Boston
... The name of the action looks good...

In my app, the image-Uri in the setData is different. You use a
'file:' uri. In my app, I use a 'content:' uri. Maybe the CROP action
cannot handle 'file:' uris and can only handle images that are
inserted into the Images content-provider.

On Jan 27, 9:57 am, GDroid baron...@gmail.com wrote:
 That's what I did in the second try.
 As I mentioned I commented out the the setClassName method and got
 the second exception:

 01-27 14:15:46.483: ERROR/AndroidRuntime(1813): Caused by:
 android.content.ActivityNotFoundException: No Activity found to handle
 Intent { act=com.android.camera.action.CROP dat=file:///sdcard/
 tmp_contact_1264594532122.jpg (has extras) }

 BTW - Thanks for the quick response.

 On Jan 27, 4:03 pm, zero zeroo...@googlemail.com wrote:



  the activity is not present on all systems under that explicit package
  name. try calling it with just the action, leaving out package and
  classname in the intent

  On Jan 27, 1:31 pm, GDroid baron...@gmail.com wrote:

   Hi,

   I'm testing this code on Motorola Milestone (2.0).
   And I get an exception when trying to launch the Cropper:

   01-27 14:29:24.210: ERROR/AndroidRuntime(1895): Caused by:
   android.content.ActivityNotFoundException: Unable to find explicit
   activity class {com.android.camera/com.android.camera.CropImage}; have
   you declared this activity in your AndroidManifest.xml?

   When trying the same intent without the setClassName call I get this
   error:

   01-27 14:15:46.483: ERROR/AndroidRuntime(1813): Caused by:
   android.content.ActivityNotFoundException: No Activity found to handle
   Intent { act=com.android.camera.action.CROP dat=file:///sdcard/
   tmp_contact_1264594532122.jpg (has extras) }

   Anyone?

   Also, there is no Constant for the Crop image intent. Can anyone from
   the Google/Android Framework team explain?
   It seems like it is there to be used but someone forgot to create the
   constant.

   Thanks

   On Dec 29 2009, 8:30 pm, Wysie sohyuanc...@gmail.com wrote:

Hi all,

After doing some reading, I realized it can't be done so simply. My
modded Contacts source is athttp://github.com/Wysie, you can take a
look if you're interested. Also, here's what I did to get it working:

    private void doTakePhotoAction() {
        //http://2009.hfoss.org/Tutorial:Camera_and_Gallery_Demo
        
//http://stackoverflow.com/questions/1050297/how-to-get-the-url-of-the-...
        //http://www.damonkohler.com/2009/02/android-recipes.html
        //http://www.firstclown.us/tag/android/
        // The one I used to get everything 
working:http://groups.google.com/group/android-developers/msg/2ab62c12ee99ba30

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

        //Wysie_Soh: Create path for temp file
        mImageCaptureUri = Uri.fromFile(new File
(Environment.getExternalStorageDirectory(),
                            tmp_contact_ + String.valueOf
(System.currentTimeMillis()) + .jpg));

        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
mImageCaptureUri);

        try {
            intent.putExtra(return-data, true);
            startActivityForResult(intent, PICK_FROM_CAMERA);
        } catch (ActivityNotFoundException e) {
            //Do nothing for now
        }
    }

    protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
        if (resultCode != RESULT_OK) {
            return;
        }

        switch (requestCode) {

        case CROP_FROM_CAMERA: {
            //Wysie_Soh: After a picture is taken, it will go to
PICK_FROM_CAMERA, which will then come here
            //after the image is cropped.

            final Bundle extras = data.getExtras();

            if (extras != null) {
                Bitmap photo = extras.getParcelable(data);

                mPhoto = photo;
                mPhotoChanged = true;
                mPhotoImageView.setImageBitmap(photo);
                setPhotoPresent(true);
            }

            //Wysie_Soh: Delete the temporary
file
            File f = new File(mImageCaptureUri.getPath());
            if (f.exists()) {
                f.delete();
            }

            InputMethodManager mgr = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.showSoftInput(mPhotoImageView,
InputMethodManager.SHOW_IMPLICIT);

            break;
        }

        case PICK_FROM_CAMERA: {
            //Wysie_Soh: After an image is taken and saved to the
location of mImageCaptureUri, come here
            //and load thecropeditor, with the necessary parameters
(96x96, 1:1 ratio)

            Intent intent = new Intent
(com.android.camera.action.CROP);
            

[android-developers] Re: US Taxes: Does Google send a 1099 tax form?

2010-01-27 Thread Streets Of Boston
About reporting a loss at tax time: You can't if you only make a few
hundred bucks or so. It's considered a hobby and you cannot deduct
more than your income on that hobby. E.g. i have a photography hobby
as well. It would be nice to deduct all the costs of my camera and
lenses if i just would sell one picture :-). But the IRS don't swing
that way :)


If it's your principal income than the story becomes much different.


On Jan 27, 12:37 am, Nathan nathan.d.mel...@gmail.com wrote:
 On Jan 26, 3:46 pm, Kevin Duffey andjar...@gmail.com wrote:

  I don't want to sound
  like I am going to cheat the system and not pay taxes..

 Well, that is what you sound like.

  The point is, and I know this is at
  the discretion of each developer, but if I only make a few hundred bucks
  over the course of a year, it hardly seems like it's worth while for the IRS
  to even follow up on..

 It probably is worth it to you to track your expenses that went into
 making those few hundred bucks. You'll probably come out ahead and
 report a loss at tax time.

 if I ever get around
  to an app that makes money tho, is it any different than if I were making
  tips as a bartender?

 Yes. Consult your tax advisor, they are not on the same line.

 might just ignore the tax thing altogether if there is no way for them to be 
 caught.

 The IRS can find everything if they do an audit, which you can be
 chosen for randomly.

 Nathan

-- 
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: US Taxes: Does Google send a 1099 tax form?

2010-01-27 Thread Streets Of Boston
You can report a negative income, but not on a hobby (see my example
above about selling one photograph to deduct expensive lenses and
camera).


On Jan 27, 6:48 pm, Kevin Duffey andjar...@gmail.com wrote:
 Funny.. if you make enough.. they take your money.. if you dont, they dont
 help you in reverse. Sad.

 On Wed, Jan 27, 2010 at 7:27 AM, Streets Of Boston
 flyingdutc...@gmail.comwrote:



  About reporting a loss at tax time: You can't if you only make a few
  hundred bucks or so. It's considered a hobby and you cannot deduct
  more than your income on that hobby. E.g. i have a photography hobby
  as well. It would be nice to deduct all the costs of my camera and
  lenses if i just would sell one picture :-). But the IRS don't swing
  that way :)

  If it's your principal income than the story becomes much different.

  On Jan 27, 12:37 am, Nathan nathan.d.mel...@gmail.com wrote:
   On Jan 26, 3:46 pm, Kevin Duffey andjar...@gmail.com wrote:

I don't want to sound
like I am going to cheat the system and not pay taxes..

   Well, that is what you sound like.

The point is, and I know this is at
the discretion of each developer, but if I only make a few hundred
  bucks
over the course of a year, it hardly seems like it's worth while for
  the IRS
to even follow up on..

   It probably is worth it to you to track your expenses that went into
   making those few hundred bucks. You'll probably come out ahead and
   report a loss at tax time.

   if I ever get around
to an app that makes money tho, is it any different than if I were
  making
tips as a bartender?

   Yes. Consult your tax advisor, they are not on the same line.

   might just ignore the tax thing altogether if there is no way for them
  to be caught.

   The IRS can find everything if they do an audit, which you can be
   chosen for randomly.

   Nathan

  --
  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- 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: AsyncTask and simultaneous network downloads

2010-01-28 Thread Streets Of Boston
AsyncTask is based upon the java.util.concurrent package's
ExecutorService and FutureTask classes.

When you create and execute an AsyncTask a thread is obtained from a
pool of threads (i don't know what the size of this pool is for
AsyncTasks) and your background process is executed on this thread.

If the pool-size is 1, then there will be always one background
thread. If another new AsyncTask is created and executed and an old
one is still busy doing its thing, the new one is queued and executed
only when the old one finishes.

If the pool-size is larger than 1, some algorithm kicks in
distributing the AsyncTasks over the threads in the pool.


On Jan 28, 12:32 pm, Biosopher biosop...@gmail.com wrote:
 I am performing several https posts and http downloads from two
 different servers using AsyncTasks.  The connections are fairly quick
 but I'm surprised to see that they are running synchronously instead
 of in parallel.

 To be more explicit, here is pseudo-code for what's happening when I
 initiate a call to AsyncTask1():

 AsyncTask1 {
         for (i=1 to 3) {
                 result = getDataFromServer1();
                 moreDataUrl = parseResult(result);

                 secondNetConnect = new AsyncTask2();
                 secondNetConnect.doInBackground(moreDataUrl);
         }

 }

 AsyncTask2 {
         connects to 2nd server

 }

 What ends up running is this every time:
 AsyncTask1a, AsyncTask1b, AsyncTask1c, AsyncTask2a, AsyncTask2b,
 AsyncTask2c

 I would have expected at least some interleaving of the AsyncTask1 and
 AsyncTask2.  Is there a known issue with non-simultaneous network
 calls in Android using AsyncTask?

 Thanks,
 Anthony

-- 
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 Streets Of Boston
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

-- 
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: device shaked? accelerometer once more

2010-01-31 Thread Streets Of Boston
I'm not that familiar with how the sensor works, but judging from the
values you report, i looks like the device is not entire horizontal or
vertical.

Your computeRealForce hovers around 0.4 (horizontally) or -1
(vertically).

I guess you have to find a proper 'baseline' against which you can
measure any deviation. In the horizontal case that would be around
0.4, in  the vertical case that would be around -1.

However, it could be that your device was not precisely horizontal or
precisely vertical. How would you know the 'baseline'? I don't know...
Maybe 0 or -1 is precisely horizontal or vertical and you can't assume
that your device will be ever exactly horizontal or vertical...

I guess you have to measure over a period of time and see what the
deviation is. If it's small enough, your phone is in rest.

On Jan 31, 4:19 pm, kretes kretesena...@gmail.com wrote:
 There has been a few discussions about it, but there is still not a
 good solution.
 Simple problem - recognize when the device is laying somewhere not
 moving (in relation to earth) and when is moving.
 Accelerometer seems to be a good sensor to use.

 First suprise came to me, when I logged data from the sensor events.
 When the device (htc hero) is laying on the table - the values are
 changing!
 sth. like
 -0.7, -0.7, 10.1
 -0.6, -0.8, 10.0
 and so on - fluctuating

 I haven't expected that, but let's go on - I thought I woudl compute
 the real force, and went with

 private double computeRealForce(SensorEvent event) {
                 return Math.sqrt(Math.pow(event.values[0], 2)
                                 + Math.pow(event.values[1], 2)
                                 + Math.pow(event.values[2], 2))
                                 - SensorManager.GRAVITY_EARTH;

         }

 very similiar approach as seen 
 inhttp://github.com/commonsguy/cw-advandroid/blob/master/Sensor/Shaker/...
 and similiar 
 inhttp://www.anddev.org/example_detecting_-und-quotshake-und-quot_with_...

 and the computed value also fluctuates,
 0,35
 0,39
 0,4
 but I can apply force treshold like 0,5 as a kind of filter and
 everything is ok.

 But when I put my phone to stand vertically - suddenly my computed
 force turned out to be
 -1,01
 -1,05

 I give up - I don't know what is the good enough solution -
 the one that would give around zero value when the device isn't moving
 in relation to earth - is there any?

-- 
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: Multi-threaded http requests cause exception

2010-01-31 Thread Streets Of Boston
Petroleam is right about AsyncTask using a thread-pool of only one
thread on 1.5. Higher versions of Android use a pool of more than one
thread.

You can do something similar with ExecutorService and FutureTask
classes (java.util.concurrent; i believe that AsyncTask is based upon
these classes) and tell the ExecutorService to use Thread-pools of any
size.


On Jan 28, 11:36 am, Biosopher biosop...@gmail.com wrote:
 Hi Frank,

 Thanks for pointing me back to AsyncTask.  I had seen AsyncTask but
 hadn't updated my code to it.  Instead I had relied on Threads and
 Handlers as they had worked without a problem before.  I'm still
 unsure why the Thread and Handler setup wasn't working, but now that
 I've updated to AsyncTask everything is working great.

 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: BitmapFactory.decodeByteArray gives pixelated bitmap

2010-02-01 Thread Streets Of Boston
You are resaving a JPEG. You'll be compressing twice.

Why don't you try to directly save the data obtained from the URL to a
file on the SDCard. Don't do any compressing. Just a direct save of
the JPG file from Flickr.

After you've done that, you have a file (on the SDCard) that contains
an exact copy of the image on Flickr. Get hold of the fully qualified
file-name of this file.

Then you insert a new image into the images' content provider:

   values.put(MediaStore.MediaColumns.DATA, fullyQualifiedFileName);
   ...
   ...
   Uri uri = mCtx.getContentResolver().insert
(Images.Media.EXTERNAL_CONTENT_URI, values);


On Feb 1, 4:22 pm, michael michael.d.peder...@googlemail.com wrote:
 Bump; the post got held up for 2 days due to moderation.

 On Jan 30, 4:53 pm, michael michael.d.peder...@googlemail.com wrote:



  Hi,

  I am working on an app that displays photos which are downloaded from
  Flickr. I obtain a Bitmap object from a byte array, which in turn is
  read from the relevant Flickr URL, as follows:

  Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);

  The problem is that the resulting bitmap is pixelated and I can't
  figure out why. To demonstrate, here is an example of a picture
  created via BitmapFactory.decodeByteArray versus the original picture
  obtained directly from the relevant Flickr URL:

 http://homepages.inf.ed.ac.uk/s0677975/bad.jpghttp://homepages.inf.ed...

  Look e.g. at the clouds in the top-left corner to see the difference.

  Can anybody give me a hint as to why this is happening?

  Below are some additional details. The byte array is obtained as
  follows; this is based on code from the Photostream app by Romain Guy:

  InputStream in = new BufferedInputStream(url.openStream(),
  IO_BUFFER_SIZE);
  final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
  out = new BufferedOutputStream(dataStream, IO_BUFFER_SIZE);
  copy(in, out);
  out.flush();
  final byte[] data = dataStream.toByteArray();

  Note that the more direct approach using e.g.
  BitmapFactory.decodeStream() does not work; see e.g. the following
  discussion for details:

 http://markmail.org/message/m2m3cpkh6ggrvj43#query:BitmapFactory.deco...

  Here is the code I used for writing the bitmap to the JPG file linked
  to above, with no compression:

  String filename = test ;
  ContentValues values = new ContentValues();
  values.put(Images.Media.TITLE, filename);
  values.put(Images.Media.DATE_ADDED, System.currentTimeMillis());
  values.put(Images.Media.MIME_TYPE, image/jpeg);

  Uri uri = mCtx.getContentResolver().insert
  (Images.Media.EXTERNAL_CONTENT_URI, values);
  try {
    OutputStream outStream = mCtx.getContentResolver().openOutputStream
  (uri);
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
    outStream.flush();
    outStream.close();} catch (FileNotFoundException e) {}

    catch (IOException e) {}

  Any help on this matter would be greatly appreciated.
  Thanks and best regards,
  Michael.- 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: BitmapFactory.decodeByteArray gives pixelated bitmap

2010-02-02 Thread Streets Of Boston
But that restriction is only for your mobile network. Chances are it
works well for your customers who are not bound to such a restriction.

Maybe your network tries to have you sign up for a better data-package
plan, that does not have this restriction... ? :-)


On Feb 2, 11:32 am, michael michael.d.peder...@googlemail.com wrote:
 Hi again,

 So I finally figured out that the problem is due to my mobile network
 operator doing image compression to save bandwidth. I discussed the
 problem further at the following URL, in case it could be of help to
 anybody:

 http://stackoverflow.com/questions/2183808/android-bitmapfactory-deco...

 I don't suppose there is anything I can do to get around this, but if
 anybody has an idea, it would be much welcome (-:

 Best,
 Michael.

 On Feb 1, 10:22 pm, michael michael.d.peder...@googlemail.com wrote:



  Hi,

   You are resaving a JPEG. You'll be compressing twice.

   Why don't you try to directly save the data obtained from the URL to a
   file on the SDCard. Don't do any compressing. Just a direct save of
   the JPG file from Flickr.

  Thanks for the suggestion!

  However, saving the bitmap to a JPEG file was really just to
  illustrate thepixelationproblem - I assumed there would be no
  quality loss with the quality parameter set to 100. What I'm actually
  doing is to draw the bitmap downloaded from Flickr onto a canvas in
  the onDraw method of my View class:

  Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG |
  Paint.FILTER_BITMAP_FLAG);
  canvas.drawBitmap(bitmap, 0, 0, paint);

  Pixelationsimilar to that shown in my example pictures then occurs.
  Any idea why this would be the case?

  Note that bitmaps loaded from my project resources draw just fine
  using this approach; although if I downscale using the
  Bitmap.createScaledBitmap() method, a similarpixelationproblem
  occurs. This problem was discussed e.g. here:

 http://stackoverflow.com/questions/2041207/android-quality-of-the-ima...

  but none of the suggested solutions seem to improve the situation in
  my case.

  Thanks again for your suggestions, I really hope there is a solution
  to this issue.
  Best,
  Michael.- 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: getChildAt sometimes giving wrong child at particular position?

2010-02-02 Thread Streets Of Boston
The getChildAt(x) method of a list-view does not return the view of
item number 'x'. It returns, more or less, the 'x'th visible child-
view of your list-view.

If you want to access an item amongst all your possible items that can
be shown in your list-view, you have to access it throug the list-
view's adapter (ListAdapter class, BaseAdapter class, etc).

On Feb 2, 10:42 am, pink 444 pnk...@gmail.com wrote:
 Hi,

     I have a listactivity in which i am displaying list of items more
 than 8 items.Thus there is scroll bar eneabled.

    When i click on list items some times getChildAt returing wrong
 View from the list.

   Why is it happening like that and how can i prevent from happening?

 Thanks in advance.

-- 
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: 3 dots at the end of the string in strings.xml

2010-02-02 Thread Streets Of Boston
I think it's just three dots (periods). As far as i know, these mean
nothing special.

On Feb 2, 2:37 pm, Rohit mord...@gmail.com wrote:
 I saw a strings.xml file and one of the entries in the xml was as
 follows

 string name=testStringthis is a long string to test .../string

 Why is there a space followed by 3 dots in the entry? Is that a
 shortcut for ellipsizing the string?

-- 
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: VerifyError - how can I solve this error?

2010-02-03 Thread Streets Of Boston
To help you, you need to post the log (form LogCat) showing the stack-
trace of the VerifyError.

As an example, VerifyErrors can occur when you load a class compiled
in Android 1.6 and using/calling 1.6 specific fields/methods and then
the class is run in a Android 1.5 environment.

I had one such (coding) error in my app, which should run on 1.5 (and
up)
e.g. i used the BitmapFactory.Options.inDensity field, which works
fine on 1.6 (or higher) phones.

However, when i ran my app on a 1.5 phone, i got a VerifyError because
of the use of use of 'inDensity' in my app's class.

On Feb 3, 5:45 am, Martin google-gro...@digle.de wrote:
 On my mobile, I do NOT have the VerifyError! This is strange. I just
 get the Error-Messages from Flurry-Analytics from people, who
 downloaded my game in the market, so I think that these error-messages
 come from a specific Android OS?

 What does it mean that some part of a class failed verification? Which
 verification?

 Greetings,
 Martin

 On 2 Feb., 00:19, fadden fad...@android.com wrote:



  On Jan 30, 3:16 am, Martin google-gro...@digle.de wrote:

   I am analyzing my game with flurry-analytics and some people, who play
   my game, receive the Exception java.lang.VerifyError in my Highscore-
   Activity.

   What do I have to do to solve this error?

  To figure this out you really need to see the log message associated
  with the failure.

  Verification errors generally mean that some part of a class failed
  verification, and as a result the entire class has been rejected by
  the VM.  It should be 100% repeatable.  The logcat output will tell
  you in great detail what went wrong and where.

  Are the failures always associated with a specific version of the
  Android OS?- 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 to get a remote logcat on error?

2010-02-03 Thread Streets Of Boston
This is not necessary, to catch every line of code.

Register an uncaught-exception-handler
(Thread.setDefaultUncaughtExceptionHandler). Before you set it, get
the current one. You may need to call it from your own uncaught-
exception-handler.

In this handler, print out the stack-trace (and some other info such
as OS-version, phone model, make, etc) to a file (on phone-memory or
sd-card)

These above steps are the bare basics.

In my app, I added a Service and an Activity, both running in a
different process than my app whose stack-traces i'm logging. If they
would run in the same process, it woudn't work (calling a Service and
Activity from a dying process).

The uncaught-exception-handling code binds to the Service
(initialization) and upon a stack-trace dump, after having generated
the file, it does a Service-request:

The Service starts the Activity that just shows a dialog asking the
using to submit an error report or not. If the user answers 'Yes',
then the Activity will read the file with the stack-trace info and
send it to a web-server (Http). The web-server gets this request,
generates an e-mail from it that is then sent to my inbox.

When the uncaught-exception-handler calls the service, it just kills
and extis the process. If the handler could not bind to the Service or
the Service-request failed, it calls the original default uncaught-
exception-handler that then shows the common 'Force Close' dialog.

This has been working well for me and found a few bugs here and
there :)

On Feb 3, 5:24 am, Martin google-gro...@digle.de wrote:
 Or is there another possibility to debug my game, while it is in the
 market?
 How can I intercept all the errors in my code to find out how I can
 solve them?

 If nobody has an answer to this, I have to put a
 try {
 ...} catch (Exception e) { /* send this exception and line number over

 internet to me */ }
 on EVERY line of code?

 For example:

         @Override
         public void onCreate(Bundle savedInstanceState) {

 try {
                 DisplayMetrics dm = new DisplayMetrics();
                 getWindowManager().getDefaultDisplay().getMetrics(dm);
                 Global.screen_width = dm.widthPixels;
                 Global.screen_height = dm.heightPixels;
                 Global.screen_width_factor = 320/Global.screen_width;
                 Global.screen_height_factor = 480/Global.screen_height;} 
 catch (Exception e) { /* send exception - METRICS */ }

 try {

                 super.onCreate(savedInstanceState);
                 requestWindowFeature(Window.FEATURE_NO_TITLE);
                 this.getWindow().setFlags
 (WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                 WindowManager.LayoutParams.FLAG_FULLSCREEN 
 );} catch (Exception e) { /* send exception - window */ }

 try {

                 setContentView(R.layout.main);} catch (Exception e) { /* send 
 exception - contentview */ }

 try {

                 //Sound starten
                 SharedPreferences prefs = getSharedPreferences(options, 0);
                 Global.bgmusic=prefs.getBoolean(music, true);
                 Global.soundeffects=prefs.getBoolean(soundeffects, true);} 
 catch (Exception e) { /* send exception - start sound */ }

 try {

                 b_start = (Button) findViewById(R.id.b_start);
                 b_start.layout(120*Global.screen_width_factor,
 55*Global.screen_height_factor,
                                 (120+buttonwidth)*Global.screen_width_factor, 
 (55+buttonheight)*

 } catch (Exception e) { /* send exception - startbuttoncreated */ }

 and so on

 or is there a better solution?

 Greetings, Martin

 On 3 Feb., 10:11, Martin google-gro...@digle.de wrote:



  Hi!

  I have a game in the market and with flurry analytics, I receive all
  my errors. Here are some of them:

   01/31/10 01:47:39 PM PST        0       class
  java.lang.IllegalArgumentException       parameter must be a descendant of
  this view
   02/02/10 12:40:41 PM PST        0       class
  java.lang.IllegalThreadStateException    Thread already started.
   01/26/10 09:25:36 PM PST        0       class 
  java.lang.NullPointerException
                   1.0 (beta)      uncaught                Android
   02/01/10 05:26:27 PM PST        0       class java.lang.OutOfMemoryError
  bitmap size exceeds VM budget    1.3 (beta)      uncaught                
  Android
   01/29/10 10:23:10 AM PST        0       class java.lang.RuntimeException
  Adding window failed     1.0 (beta)      uncaught                Android
   01/29/10 08:19:05 AM PST        0       class java.lang.RuntimeException
  Unable to start activity ComponentInfo{digle.de.LeonardFrog/
  digle.de.LeonardFrog.AHighscore}: java.lang.NullPointerException         1.0
  (beta)   uncaught                Android
   01/27/10 01:09:35 AM PST        0       class java.lang.VerifyError
  digle.de.LeonardFrog.AHighscore          1.0 (beta)      uncaught           
       Android

  I want to solve them but I 

[android-developers] Re: VerifyError - how can I solve this error?

2010-02-03 Thread Streets Of Boston
They are all related to creating a new instance of AHighScore.

Some part of the code in AHighScore uses a class, or classes, that are
'incompatible' with the version of the OS on which AHighScore would be
running.

Under what version of the Android OS did you compile your app?
Under what version of the Android OS is your app actually running?

On Feb 3, 8:34 pm, Martin google-gro...@digle.de wrote:
 Oh, I found out that they are all the same, although I got them at
 different times.
 So to keep it clearly, here is just one of them:

 java.lang.VerifyError: digle.de.LeonardFrog.AHighscore
        at java.lang.Class.newInstance(Native Method)
        at android.app.Instrumentation.newActivity(Instrumentation.java:
 1096)
        at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
 2061)
        at
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
 2157)
        at android.app.ActivityThread.access$1800(ActivityThread.java:
 112)
        at android.app.ActivityThread
 $H.handleMessage(ActivityThread.java:1581)
        at android.os.Handler.dispatchMessage(Handler.java:88)
        at android.os.Looper.loop(Looper.java:123)
        at android.app.ActivityThread.main(ActivityThread.java:3739)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit
 $MethodAndArgsCaller.run(ZygoteInit.java:739)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
        at dalvik.system.NativeStart.main(Native Method)

 Greetings, Martin

-- 
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: gluUnProject again - opengl bug?

2010-02-05 Thread Streets Of Boston
I found issues with the gluUnProject as well.
I wrote a new one for my own app (The Gube) and it works very well. I
use gluUnproject for tracking 2D finger-touches and flings into the 3D
model-view/space.

You can do a gluUnproject search on this forum and you will find this:
http://groups.google.com/group/android-developers/browse_frm/thread/9d2bf53e3a798cb6/07cfa3ee11507fc1?lnk=gstq=gluunproject#07cfa3ee11507fc1

Go to message# 8, which contiains the source control.

On Feb 5, 7:18 pm, Tim Newsham tim.news...@gmail.com wrote:
 Hi, I'm having problems with gluUnProject. I saw other discussions on
 this message base regarding this function and they did not solve my
 problem. When I use GLU.gluUnProject I get values that are close, but
 not quite right. I'm manually keeping track of my model matrix and I
 replicate the projection matrix manually.  (I have also tried setting
 the projection matrix to identity and manually incorporating a
 projection matrix into my model matrix, and I ended up with the same
 results). I tried using the builtin GLU.gluUnProject function and I
 also implemented my own based on reading that source and reading the C
 GLU sources and both seemed to give substantially similar results.

 So I put together a small demo, trying to keep it as minimal as
 possible and still get the point across.  Either this demo shows a
 misunderstanding I have of gluUnProject or it shows a bug in the
 function or opengl projections. Can someone check this over and see if
 I'm just doing something wrong or if there's a bug that needs to be
 filed?

 The files are here:http://www.thenewsh.com/~newsham/unproj/
 In particular:

     unproj.java         - full source to example
     unproj-debug.apk    - resulting apk file
     unproj              - directory with full ant-buildable project
     unproj.zip          - zip of directory

 Tim

-- 
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 Streets Of Boston
I don't if it was a typo or not, but shouldn't this code be like
this?:

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


  return m_connection;
}

(added 'm_connection = ' to the second line of the function's body).

On Feb 6, 7: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: gluUnProject again - opengl bug?

2010-02-06 Thread Streets Of Boston
I have no idea how it differs from the original version (as shipped in
the SDK).  :-)

The original version just didn't work and i ported a C-version (google
it) into Java. And this seems to work for my app and other developers'
apps.

On Feb 5, 11:22 pm, Tim Newsham tim.news...@gmail.com wrote:
 Could you explain how your version might differ from the original
 version?
 The version in the standard library:

    computes M = (Projection x Model)^-1
    puts world into a homogenous vector V,
       with x/y coordinates mapped from screen coords to -1.0 to 1.0
       and z coordinate mapped from (0,1) to (-1,1)
       w coordinate set t 1
    multiplies MxV, with the resulting w coordinate normalized to 1.0
    returns that value

 I implemented my own version (based on the C GLU library code) and
 got substantially the same results (differences less than 1/100th %
 off)

 On Feb 5, 5:40 pm, Streets Of Boston flyingdutc...@gmail.com wrote:



  I found issues with the gluUnProject as well.
  I wrote a new one for my own app (The Gube) and it works very well. I
  use gluUnproject for tracking 2D finger-touches and flings into the 3D
  model-view/space.

  You can do a gluUnproject search on this forum and you will find 
  this:http://groups.google.com/group/android-developers/browse_frm/thread/9...

  Go to message# 8, which contiains the source control.

  On Feb 5, 7:18 pm, Tim Newsham tim.news...@gmail.com wrote:

   Hi, I'm having problems with gluUnProject. I saw other discussions on
   this message base regarding this function and they did not solve my
   problem. When I use GLU.gluUnProject I get values that are close, but
   not quite right. I'm manually keeping track of my model matrix and I
   replicate the projection matrix manually.  (I have also tried setting
   the projection matrix to identity and manually incorporating a
   projection matrix into my model matrix, and I ended up with the same
   results). I tried using the builtin GLU.gluUnProject function and I
   also implemented my own based on reading that source and reading the C
   GLU sources and both seemed to give substantially similar results.

   So I put together a small demo, trying to keep it as minimal as
   possible and still get the point across.  Either this demo shows a
   misunderstanding I have of gluUnProject or it shows a bug in the
   function or opengl projections. Can someone check this over and see if
   I'm just doing something wrong or if there's a bug that needs to be
   filed?

   The files are here:http://www.thenewsh.com/~newsham/unproj/
   In particular:

       unproj.java         - full source to example
       unproj-debug.apk    - resulting apk file
       unproj              - directory with full ant-buildable project
       unproj.zip          - zip of directory

   Tim- 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: Handling large Bitmaps

2010-02-08 Thread Streets Of Boston
If you use them for fit-in screen display only, just scale them to the
screen-size. You don't need any bigger.

1. Figure out the actual width and height of the image
(inJustDecodeBounds = true)
2. When actually loading the pic, downsample (inSampleSize  1) so
that the resulting image fits the screen as good as possible (for best
result, make the loaded image a bit bigger than the screen instead of
a bit smaller). Also, the values of inSampleSize work best across most
phones when its value is a power of 2 (2, 4, 8, etc)
3. Then scale the image (down) a bit further to exactly fit the
screen.

E.g. say your screen is 800x400. Your image is 2048x1536. Then
downsample the image (inSampleSize = 2) -- Loaded image is 1024x768.
Then scale the downsampled image by 52.08333% -- a bitmap of 533x400
pixels. Cache this image. Still, be careful not to cache too many
images.



On Feb 8, 9:48 am, Samuh samuh.va...@gmail.com wrote:
 I have a bunch of image URLs. I have to download these images and
 display them in my application one-by-one. I am saving the images in a
 Collection using SoftReferences and also on Sdcard to avoid refetches
 and improve user experience.

 The problem is I dont know anything about the size of the bitmaps. And
 as it turns out, I am getting OutOfMemoryExceptions sporadically, when
 I am using BitmapFactory.decodeStream(InputStream) method. So, I chose
 to downsample the images using BitmapFactory Options(sample size=2).
 This gave a better output: no OOMs, but this affects the quality of
 smaller images.

 How should I handle such cases? Is there a way to selectively down
 sample only high resolution images?

 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: Handling large Bitmaps

2010-02-08 Thread Streets Of Boston
Store them full-sized (100%) on your SD-card. Then load the Bitmap
from the copy on your SD-card.
If you don't want these images to show up in the Gallery application,
be sure to put them into a directory that starts with a period '.' .

On Feb 8, 10:11 am, Samuh samuh.va...@gmail.com wrote:
  Sorry to state the obvious, but since you downloaded the file why
  don't you downsample only picture that are either :

  - Larger than 1024x768 in size
  - Bigger than 500 KB

  or a smart mix of the two  ?

 I guess because I was creating a Bitmap from the stream before I was
 writing it to the SD card. I can't figure out the size of the image
 from the stream, can I?

 Is there something I am missing here?

 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: Variable values just get lost!??!?

2010-02-08 Thread Streets Of Boston
Did you check if you service is being destroyed (onDestroy) or being
killed (entire service process is being killed by Android) and re-
created later at points in your code that are unexpected?

Put break-points in your service's onCreate, onDestroy and onBind and
see what's going on.

Another question: Do you run your service in a different process or in
the same process as your Activities?

On Feb 8, 5:58 am, Florian Lettner fl.lett...@gmail.com wrote:
  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.

 The variables are stored as class members in the server connection
 class, which is the static singleton. The singleon works fine, I
 checked that. The private ctor is only called once, if the
 getInstance() function is called for the first time. If a call
 setProperty(x); the x value is transported properly to the server
 connection class and applied to the member variable. Checked that too,
 after calling the method the member variable has the desired value. If
 afterwards connect() is called which uses the member variable, the
 member has got its initial value again, like it is a different object.
 However, only one server connection object exists for the application
 (ctor is definitely called only once):

  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.

 The service is needed to keep the application up and running since
 there is additional hardware used for device input (Anoto Pen). It is
 quite complex, but however the service is needed to react on any
 action of the pen also if the application is not in foreground. The
 server connection is needed to send input data to the server (using
 sockets), however, the server connection is not the service. In a
 previous version (before the server connection became a singleton) the
 background service owned a server connection object. Both work well,
 the server connection connects to the external server, sends data and
 receives data and the background service runs to keep track of the
 anoto pen. Additionally the service receives status messages from the
 server class (e.g. socket error, login error, data lost, ...). This
 all works well. The only thing that does not work is that if I set the
 port or IP from the background service or my activity, the data gets
 lost although the debugger tells me that it is in the variable after
 calling the setter.

  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.

 Life cycle is clear and correctly implemented (works on other
 platforms like Qt, Symbian and J2ME). Service is needed because of
 background communication with external hardware that is connected via
 bluetooth. Has actually nothing to do with the server connection. Its
 only purpose regarding the server connection is to re-login if the
 connection is lost.

  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.

 I would prefer that solution, however the server is developed and
 provided by Vodafone since this is a bigger university related
 project. So I have to work with their protocol although I would love
 to change some things.

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

 Thank you very much for the detailed explanations, however I am still
 trapped. Never had such a problem before.

-- 
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] Re: How to send motion Event down to another activity

2010-02-08 Thread Streets Of Boston
The activity that is no longer visible could have been destroyed by
the OS.
However, since your top-activity is (partially) translucent, this
probably won't happen.

If you really need to communicate back to the activity in the
background, there are various methods:

1. Use a static variable that holds the currently active 'background'
activity. Whenever you start your new 'foreground' activity, set this
static inside your 'background' activity and use it in your
'foreground' activity by calling one or more of its method.

2. Above won't work if your activities run in seperate process. If
this is the case, then you could use a background Service to deal with
the communication between the two activities.

But, be very careful with either of these approaches. Check or be
absolutely sure that this 'background' activity still exists...

On Feb 7, 11:50 pm, sheng wang banxia...@gmail.com wrote:
 Hi GuoBin,

 I understand what u mean below. I think that's the standard way the android
 deal with the event. Event goes through a current path within the activity.
 No event will go out of the current activity.

 As a surround way, is there any method that can let the current activity
 find out who is behind him? so he  might communicate with the one behind
 it?

 Anyway, think you for taking your time to think the question.

 Shawn.

 2010/2/8 Guobin zzg...@gmail.com



   1. Whether the event can be send down to any thing behind the current
   activity.
  No, you can't.
  On the Android platform, you define an Activity's UI using a hierarchy
  of View and ViewGroup nodes.
  Home  your activity are different activity, they have their own view
  hierarchy.
  Key events are always delivered to the View currently in focus. They
  are dispatched starting from the top of the View hierarchy, and then
  down, until they reach the appropriate destination.
  But not the view of other activity.
 http://developer.android.com/guide/topics/ui/ui-events.html

  Guobin

  --
  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- 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: Modal Dialogs: the definitive solution

2010-02-08 Thread Streets Of Boston
You must be absolutely sure that the 'alert(Strin msg)' runs in a
different thread than the UI-thread.

Why do it this way?

You can just call showDialog(int dialogID) in your activity.
Then in the onClickListener of this dialog, you can implement the
onClick method to handle the case when the user clicks OK, do what
needs to be done and dismiss the dialog.

On Feb 8, 5:02 pm, guich guiha...@gmail.com wrote:
 Hi,

 I decided to share the solution i found to the problem of Android not
 supporting real modal dialogs.

 The solution was to draw the dialog by myself. :-( Well, at least
 worked fine, besides the problem that its a bit ugly. :-)

 Here's the code i used:

    static boolean alertShowing;

    public static void alert(String msg)
    {
       int scrW=instance.getWidth(),scrH=instance.getHeight();
       alertShowing = true;
       final int fh = 18;
       // note: we have to draw the dialog on screen, otherwise if we
 use Dialog, the application just quits
       String[] msgs = msg.split(\n);
       Canvas canvas = surfHolder.lockCanvas();
       // fill with white
       Paint p = new Paint();
       p.setColor(0x);
       canvas.drawRect(0,0,scrW,scrH,p);
       p.setColor(0xFFAA);
       int ly = fh+fh/2;
       canvas.drawRect(0,0,scrW,ly,p);
       // draw caption in black
       p.setColor(0xFF00);
       p.setStyle(Paint.Style.STROKE);
       canvas.drawRect(0,0,scrW-1,scrH-1,p);
       p.setAntiAlias(true);
       p.setTextSize(fh);
       p.setTypeface(Typeface.DEFAULT_BOLD);
       p.setTextAlign(Paint.Align.CENTER);
       canvas.drawText(ALERT,scrW/2,fh+fh/4,p);
       canvas.drawLine(0,ly,scrW,ly,p);
       // draw message
       int maxy = scrH-fh*2;
       p.setTypeface(Typeface.DEFAULT);
       for (int i =0,y=fh*3; i  msgs.length  y  maxy; i++, y += fh
 +2)
          canvas.drawText(msgs[i], scrW/2, y,p);

       String ok = Ok;
       int tx = scrW/2;
       int ty = maxy+ly;
       canvas.drawText(ok,tx,ty,p);
       Rect bounds = new Rect();
       p.getTextBounds(ok, 0, ok.length(), bounds);
       int ww = bounds.width();
       int hh = bounds.height();
       canvas.drawRect(tx-ww,ty-hh-3,tx+ww,ty+3,p);

       surfHolder.unlockCanvasAndPost(canvas);
       while (alertShowing)
          try {Thread.sleep(200);} catch (Exception e) {}
    }

    public boolean onTouchEvent(MotionEvent event)
    {
       if (alertShowing)
       {
          alertShowing = false;
          return true;
       }
    }

 HTH.

    guich
    http://www.totalcross.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


[android-developers] Re: Inadvertent breakage by SDK going forward

2010-02-15 Thread Streets Of Boston
That would be very 'icky'... I hoped that the 'targetSdkVersion'
setting could prevent this.

On Feb 12, 7:20 pm, jasper jasper...@gmail.com wrote:
 Does this truly mean that even if I compile to the 1.6 platform, if my
 code implements a 2.1 callback method, that method will *never* be
 invoked on 1.6 devices but *will* be invoked on 2.1 devices?  Even
 though I compiled to the 1.6 platform?  That's crazy!

 On Feb 12, 4:01 pm, Mike Collins mike.d.coll...@gmail.com wrote:



  Ran into the below issue and wanted to see what solutions people
  have...

  In SDK 1.6 Activity did not have a method onBackPressed (), in 2.0 it
  appeared.
  Using the current docs I added an onBackPressed to a couple of our
  classes.
  We build against 1.6 (customer requirement) it seemed a bit odd that
  the compiler
  got upset when I put in a @Override, so I took it out and proceeded to
  verify that
  everything was working, which it was, the method was being invoked
  exactly as
  expected.

  Turns out this works only on phones/emulators with 2.0 or greater
  firmware.  On
  1.6 firmware it fails to function at all because nobody calls it.

  OK, with hindsight it's obvious what's happening and we've made the
  @Override
  an error not a warning.

  But it raises the issue of how to I protect my app if in the future
  Android implements
  a method that collides with the name of method I invent for my derived
  class.  In
  this case Android will be calling my method at inappropriate times and
  expecting
  it to do things that it probably doesn't do.

  One solution is prefix every method of ours of every class that
  derives from an Android
  class with something specific to the app.  Or use a different naming
  convention, like
  always use an initial capital or an underscore etc.

  thoughts?
    mike- 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: while onLongClick'ed

2010-02-15 Thread Streets Of Boston
Why not catch a MotionEvent and check for ACTION_DOWN (start rolling
the dice) and for ACTION_UP (stop rolling the dice).

On Feb 13, 12:11 pm, Ricky arsenickiss7...@gmail.com wrote:
 i have search and have not found a solution to my problem.

 my problem is that, i am trying to create a loop while the button is
 LongClicked. currently when i long click, the moreDice() method is
 only called once. i need to create a loop that will keep calling the
 moreDice() untill the user nolonger LongClick's the buttton.

        here is my simple code example:

         // + Button on LongClick
         up.setOnLongClickListener(new View.OnLongClickListener() {
                         @Override
                         public boolean onLongClick(View v) {
                                 moreDice();
                                 //return true because event has been handled, 
 do not pass onto any
 other listeners
                                 return true;
                         }
                 });

 thanks in advanced,
 -ricky

-- 
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 crop an image in android 2.x

2010-02-15 Thread Streets Of Boston
First, don't set the class-name.
Your customer's phone may not have this particular activity
(com.android.camera.CropImage) installed.

But this should not give you the 'permission denial' error.
Maybe the CROP action can only crop public images. You set yours to
PRIVATE.

On Feb 12, 9:18 am, Vaibhav Goel vaibhavgoe...@gmail.com wrote:
 I need to crop an image whose Uri is known.

 In 1.6 I used the below code.

  Intent i = new Intent(com.android.camera.action.CROP);
  i.setClassName(com.android.camera, com.android.camera.CropImage);
  i.setData(imageUri);      // imageUri = 
 content://media/external/images/media/40
  i.putExtra(noFaceDetection, false);
  i.putExtra(outputX, 75);
  i.putExtra(outputY, 75);
  i.putExtra(aspectX, 1);
  i.putExtra(aspectY, 1);
  i.putExtra(scale, true);

  ContentValues values = new ContentValues();
  values.put(Media.TITLE, User_t + _Image);
  values.put(Media.BUCKET_ID, User-T);
  values.put(Media.BUCKET_DISPLAY_NAME, image_t);
  values.put(Media.IS_PRIVATE, 1);
  userThumbnailUri = getContentResolver().insert(
                         Media.EXTERNAL_CONTENT_URI, values);
  i.putExtra(MediaStore.EXTRA_OUTPUT, userThumbnailUri);
 startActivityForResult(i, CROP_IMAGE);

 It worked fine on 1.6 but when i tested it on 2.1 it give error as
 shown below.

 02-12 19:09:43.504: ERROR/AndroidRuntime(851):
 java.lang.RuntimeException: Failure delivering result
 ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://
 media/external/images/media/40 }} to activity {net.urbansignals/
 net.urbansignals.activity.user.SignUpActivity}:
 java.lang.SecurityException: Permission Denial: starting Intent
 { act=com.android.camera.action.CROP dat=content://media/external/
 images/media/40 cmp=com.android.camera/.CropImage (has extras) } from
 ProcessRecord{44ae1ac8 851:net.urbansignals/10045} (pid=851,
 uid=10045) requires null
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.ActivityThread.deliverResults(ActivityThread.java:3329)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.ActivityThread.handleSendResult(ActivityThread.java:3371)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.ActivityThread.access$2700(ActivityThread.java:119)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1893)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.os.Handler.dispatchMessage(Handler.java:99)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.os.Looper.loop(Looper.java:123)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.ActivityThread.main(ActivityThread.java:4363)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 java.lang.reflect.Method.invokeNative(Native Method)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 java.lang.reflect.Method.invoke(Method.java:521)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 com.android.internal.os.ZygoteInit
 $MethodAndArgsCaller.run(ZygoteInit.java:860)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 dalvik.system.NativeStart.main(Native Method)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851): Caused by:
 java.lang.SecurityException: Permission Denial: starting Intent
 { act=com.android.camera.action.CROP dat=content://media/external/
 images/media/40 cmp=com.android.camera/.CropImage (has extras) } from
 ProcessRecord{44ae1ac8 851:net.urbansignals/10045} (pid=851,
 uid=10045) requires null
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.os.Parcel.readException(Parcel.java:1218)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.os.Parcel.readException(Parcel.java:1206)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:
 1214)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.Instrumentation.execStartActivity(Instrumentation.java:
 1373)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.Activity.startActivityForResult(Activity.java:2749)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 net.urbansignals.activity.user.SignUpActivity.onActivityResult(SignUpActivi­ty.java:
 326)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.Activity.dispatchActivityResult(Activity.java:3828)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     at
 android.app.ActivityThread.deliverResults(ActivityThread.java:3325)
 02-12 19:09:43.504: ERROR/AndroidRuntime(851):     ... 11 more

 Can any body suggest the proper way do crop an image in 2.x ?

 Thanks for your suggestions.

-- 
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] Re: Displaying thumbnails of images (present at different locations in the sdcard) in a listview

2010-02-16 Thread Streets Of Boston
Cache the thumbnails

In my app (Snap FX) I have two cache levels.

1. In-memory cache (hash-map)
2. Thumbnail record file, much like Thumbs.db on Windows.

1. When requesting a thumbnail of an image, read first from the in-
memory cache.
2. If this fails, read from the thumbnail record file (and put into in-
memory cache).
3. If that fails, read from thumbnail content-provider (and put into
thumbnail record file and into in-memory cache).
4. If that fails, generate a thumbnail from the original image (and
put it into the thumbnail content-provider, into the thumbnail record
file and into in-memory cache).

For fast access to the thumbnail record file, use RandomAccessFile as
a file-based hash-map.



On Feb 15, 11:33 pm, Pankaj pankajiit...@gmail.com wrote:
 Hi all,
     I have several images present in different folders in my sdcard. I
 would like to display a list of thumbnails. So what I have done is
 while rendering any row in the list I read the file in an input
 stream, get the byte array, decode it to obtain a bitmap and set it in
 an imageview.

 So far so good. But when I scroll the list, the list scrolls in jerks.
 I believe this is because decoding a bitmap from byte array takes some
 time. What I would like to know is that, is there any optimization
 which I can do to improve the performance, or better still is there
 any better method to achieve what I want ?

-- 
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 binder transaction when passing byte[] (from camera) between intents

2010-02-16 Thread Streets Of Boston
Binary data works upto about 100KByte. Anything larger, you very
likely get that error.

For images in RGB_565, this is about 277 x 184 pixels max (277 x 184 *
2 = 101936)

On Feb 16, 4:17 am, Bart bvandep...@gmail.com wrote:
 Hi, I have a problem with an app that lets the user take a picture.
 I've posted it on some forums already, but nobody seems to recognize
 the problem. Hopefully someone here knows a solution :)

 I've put the code of taking a picture in a seperate activity. Then I
 call the camera intent from my main activity using activityForResult.
 In the camera intent, I use putExtra to return the camera image (as a
 byte[] without doing anything to it). But when the program transitions
 back from the camera intent to the parent intent that called it I get
 a Failed Binder Transaction error in the logcat because the byte[] is
 too big. But I don't understand this, because the image is not even
 taken using the maximum resolution :S

 The code of my camera intent is:

 package example.imaging.ape;

 import java.io.IOException;
 import java.util.Iterator;
 import java.util.Set;

 import android.app.Activity;
 import android.content.Intent;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.PixelFormat;
 import android.hardware.Camera;
 import android.hardware.Camera.AutoFocusCallback;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.MotionEvent;
 import android.view.SurfaceHolder;
 import android.view.SurfaceView;
 import android.view.View;
 import android.view.Window;
 import android.view.WindowManager;
 import android.view.View.OnTouchListener;

 public class TakePicture extends Activity implements
 SurfaceHolder.Callback{
      Camera mCamera;
      Boolean mPreviewRunning = false;
      int imageLayoutHeight;
      int imageLayoutWidth;

     �...@override
      public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);

           //setup camera surface
           getWindow().setFormat(PixelFormat.TRANSLUCENT);
           requestWindowFeature(Window.FEATURE_NO_TITLE);

 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
 WindowManager.LayoutParams.FLAG_FULLSCREEN);
           setContentView(R.layout.cameralayout);

           SurfaceView mSurfaceView = (SurfaceView)
 findViewById(R.id.hist_surface_camera);
           SurfaceHolder mSurfaceHolder = mSurfaceView.getHolder();
           mSurfaceHolder.addCallback(this);

 mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
           Bundle extras = getIntent().getExtras();
           imageLayoutHeight = extras.getInt(layoutHeight);
           imageLayoutWidth = extras.getInt(layoutWidth);

           OnTouchListener touchListener = new View.OnTouchListener() {
                public boolean onTouch(View v, MotionEvent e) {

                     System.out.println(MAKING PICTURE);
                     mCamera.autoFocus(cb);
                     return false;
                }
           };

           //setup touch listener
           mSurfaceView.setOnTouchListener(touchListener);

      }

      AutoFocusCallback cb = new AutoFocusCallback() {
           public void onAutoFocus(boolean success, Camera c) {
                c.takePicture(null, null, mPictureCallback);
           }
      };

      Camera.PictureCallback mPictureCallback = new
 Camera.PictureCallback() {
           public void onPictureTaken(byte[] imageData, Camera c) {
                System.out.println(Picture taken, now
 returning);
                Intent resultIntent = new Intent();
                resultIntent.putExtra(cameraImage, imageData);
                System.out.println(put Extra);
                setResult(Activity.RESULT_OK, resultIntent);
                finish();
           }
      };

      //initialize camera
      public void surfaceCreated(SurfaceHolder holder) {
           mCamera = Camera.open();
      }

      public void surfaceChanged(SurfaceHolder holder, int format, int
 w, int h) {
           if (mPreviewRunning) {
                mCamera.stopPreview();
           }

           Camera.Parameters p = mCamera.getParameters();

           p.setPreviewSize(h, w);
           System.out.println(PreviewSize:  + h + , + w);
           p.setPictureSize(h*3,w*3); // is around 1200x900
           p.set(rotation, 90);
           mCamera.setParameters(p);

           try {
                mCamera.setPreviewDisplay(holder);
           } catch (IOException e) {
                e.printStackTrace();
           }

           mCamera.startPreview();
           mPreviewRunning = true;
      }

      public void surfaceDestroyed(SurfaceHolder holder) {
           mCamera.stopPreview();
           mPreviewRunning = false;
           mCamera.release();
      }

 }

 And this is how I call the camera activity:

 Intent intent = new Intent(mainActivity.this, TakePicture.class);
 intent.putExtra(layoutWidth,layoutWidth);
 

[android-developers] Re: Failed binder transaction when passing byte[] (from camera) between intents

2010-02-17 Thread Streets Of Boston
In onPictureTaken, save the camera to a file and insert into the media
content provider.
Then, when the image has been inserted, instead of sending the raw
binary data of the bitmap, send back the content-Uri of the image you
took.

On Feb 17, 3:07 am, Bart bvandep...@gmail.com wrote:
 So I can never make camera images that are higher resolution then
 277x184? :S
 If I stuff all the camera code into my main activity, then it should
 work. But that's a little messy. Are you sure there isn't another way
 to pass the camera images?

 Thanks

 On Feb 16, 10:05 pm, Streets Of Boston flyingdutc...@gmail.com
 wrote:



  Binary data works upto about 100KByte. Anything larger, you very
  likely get that error.

  For images in RGB_565, this is about 277 x 184 pixels max (277 x 184 *
  2 = 101936)

  On Feb 16, 4:17 am, Bart bvandep...@gmail.com wrote:

   Hi, I have a problem with an app that lets the user take a picture.
   I've posted it on some forums already, but nobody seems to recognize
   the problem. Hopefully someone here knows a solution :)

   I've put the code of taking a picture in a seperate activity. Then I
   call the camera intent from my main activity using activityForResult.
   In the camera intent, I use putExtra to return the camera image (as a
   byte[] without doing anything to it). But when the program transitions
   back from the camera intent to the parent intent that called it I get
   aFailedBinderTransaction error in the logcat because the byte[] is
   too big. But I don't understand this, because the image is not even
   taken using the maximum resolution :S

   The code of my camera intent is:

   package example.imaging.ape;

   import java.io.IOException;
   import java.util.Iterator;
   import java.util.Set;

   import android.app.Activity;
   import android.content.Intent;
   import android.graphics.Bitmap;
   import android.graphics.BitmapFactory;
   import android.graphics.PixelFormat;
   import android.hardware.Camera;
   import android.hardware.Camera.AutoFocusCallback;
   import android.os.Bundle;
   import android.util.Log;
   import android.view.MotionEvent;
   import android.view.SurfaceHolder;
   import android.view.SurfaceView;
   import android.view.View;
   import android.view.Window;
   import android.view.WindowManager;
   import android.view.View.OnTouchListener;

   public class TakePicture extends Activity implements
   SurfaceHolder.Callback{
        Camera mCamera;
        Boolean mPreviewRunning = false;
        int imageLayoutHeight;
        int imageLayoutWidth;

       �...@override
        public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);

             //setup camera surface
             getWindow().setFormat(PixelFormat.TRANSLUCENT);
             requestWindowFeature(Window.FEATURE_NO_TITLE);

   getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
   WindowManager.LayoutParams.FLAG_FULLSCREEN);
             setContentView(R.layout.cameralayout);

             SurfaceView mSurfaceView = (SurfaceView)
   findViewById(R.id.hist_surface_camera);
             SurfaceHolder mSurfaceHolder = mSurfaceView.getHolder();
             mSurfaceHolder.addCallback(this);

   mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
             Bundle extras = getIntent().getExtras();
             imageLayoutHeight = extras.getInt(layoutHeight);
             imageLayoutWidth = extras.getInt(layoutWidth);

             OnTouchListener touchListener = new View.OnTouchListener() {
                  public boolean onTouch(View v, MotionEvent e) {

                       System.out.println(MAKING PICTURE);
                       mCamera.autoFocus(cb);
                       return false;
                  }
             };

             //setup touch listener
             mSurfaceView.setOnTouchListener(touchListener);

        }

        AutoFocusCallback cb = new AutoFocusCallback() {
             public void onAutoFocus(boolean success, Camera c) {
                  c.takePicture(null, null, mPictureCallback);
             }
        };

        Camera.PictureCallback mPictureCallback = new
   Camera.PictureCallback() {
             public void onPictureTaken(byte[] imageData, Camera c) {
                  System.out.println(Picture taken, now
   returning);
                  Intent resultIntent = new Intent();
                  resultIntent.putExtra(cameraImage, imageData);
                  System.out.println(put Extra);
                  setResult(Activity.RESULT_OK, resultIntent);
                  finish();
             }
        };

        //initialize camera
        public void surfaceCreated(SurfaceHolder holder) {
             mCamera = Camera.open();
        }

        public void surfaceChanged(SurfaceHolder holder, int format, int
   w, int h) {
             if (mPreviewRunning) {
                  mCamera.stopPreview();
             }

             Camera.Parameters p

[android-developers] Re: add a scan barcode button to my webpage

2010-02-17 Thread Streets Of Boston
I just link to Google's charting site:

http://chart.apis.google.com/chart?cht=qrchs=135x135chl=market://search?q=pname:com.streetsofboston.smugdroid.snapfx.paid

This link generates a PNG image of 135x135 pixels.

Replace the package name (value after 'pname:') with your own package
name. Make it the value of the 'src' attribute of an img tag and
you're all set.

On Feb 17, 8:59 am, JB jeff.benton.r...@gmail.com wrote:
 Does anyone know how to add a scan barcode button to a webpage like
 google has in the shopping page?  I am wanting to allow my clients
 using a droid phone to press the button scan a barcode and post the
 data back into my webpage.

 any suggestions?

 thanks JB

-- 
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] Camera on HTC Hero: Calling camera.autoFocus(...) gives a IOException .. ?

2010-02-18 Thread Streets Of Boston
This is the stack trace:

Android OS: 1.5
Model: HERO200
Make: heroc:sprint

Caused by: java.io.IOException: autoFocus failed
at android.hardware.Camera.native_autoFocus(Native Method)
at android.hardware.Camera.autoFocus(Camera.java:313)
at com.streetsofboston.smugdroid.snapfx.camera.SmugCamera
$Preview.autoFocus(SmugCamera.java:1492)


This exception is not documented. The JavaDoc of Camea.autoFocus does
not mention this exception at all.
How can i prevent this from happening or can i just catch it and
continue to instruct the camera to take a picture.

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: Is there a normal human way to copy image from one folder to another?

2010-02-18 Thread Streets Of Boston
No. You have to do this all yourself :(

1. Query from the mediastore all the info for your original image,
including its file-path (DATA column).
2. Query from the thumbnail mediastore the info of all the thumbnails
(can have more than one) for the given image.

3. Copy your image-file to another location. Remember this location
for the new DATA column of your new image.

4. Insert into the mediastore all the data obtained from point (1.)
but set your DATA to the new file-path of your new image (from point
3.).
5. Insert into the thumbnail mediastore the thumbnails of this new
image. Use the data from point (2.), but update the IMAGE_ID with the
new image-id from point (4.) and make also copies of each thumbnail
file (DATA column).



On Feb 17, 9:19 pm, benderillo alex.vep...@gmail.com wrote:
 Hi everybody,

 Here is the problem:
 I'm trying to figure out the best way to copy exisitng jpeg image on
 SD card from one folder to another with MediaStore database properly
 updated.

 First approach I tried:
 1) Open IN and OUT streams; 2) Copy file to a new location as byte
 stream; 3) Use MediaScannerConnection.scanFile() to update MediaStore
 DB.
 This way works fine except one problem: image thumbnail is not
 generated (MediaStore.Images.Thumbnails is empty). I looked inside
 scanFile method; it doesn't seem to have any code for thumbnail
 generation.

 Second approach:
 Try to use Images.Media.insertImage() - with this approach I don't
 know how to chose the physical location of the new file. You can't
 control this. You just get an Uri to a copy of the image which is
 copied (re-encoded) to some place but not the folder you need it to be
 in.

 In other words, my question is: Is there any way to give MediaStore an
 image file and say Please, take this file and fill up your database
 with all the information it should have, including thumbnail?

-- 
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: Camera on HTC Hero: Calling camera.autoFocus(...) gives a IOException .. ?

2010-02-19 Thread Streets Of Boston
I found some posts about not have a preview-callback. But my camera
does not have a preview-callback set at all. I'm wondering where this
IOException is coming from. Is it specific to the Hero?

On Feb 18, 7:23 am, Streets Of Boston flyingdutc...@gmail.com wrote:
 This is the stack trace:

 Android OS: 1.5
 Model: HERO200
 Make: heroc:sprint

 Caused by: java.io.IOException: autoFocus failed
         at android.hardware.Camera.native_autoFocus(Native Method)
         at android.hardware.Camera.autoFocus(Camera.java:313)
         at com.streetsofboston.smugdroid.snapfx.camera.SmugCamera
 $Preview.autoFocus(SmugCamera.java:1492)

 This exception is not documented. The JavaDoc of Camea.autoFocus does
 not mention this exception at all.
 How can i prevent this from happening or can i just catch it and
 continue to instruct the camera to take a picture.

 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: $3.00 Marketplace chargeback ?!?!

2010-02-20 Thread Streets Of Boston
Relax!!!

It happened to me too a few times. It sucks, but this is just the cost
of doing business. And it's in the Android Market agreement that you
accepted.

If you were to handle the credit-card transations yourself, you would
be complaining much louder.
Just do a google search for 'chargeback' on credit cards and see what
small businesses (e.g. convenient stores, pop-and-moms stores) think
about this issue. Compared to them, this $3 is peanuts.

Google handles credit card transactions and checks for fraud and such.
This is not full-proof, but if you would have to deal with it
yourself... not fun.

For purchases of $10 or more, Google will initiate an investigation.
But under that, you'll get an automatic $3 chargeback.

Basically what happened to you is that your app has been 'stolen'
twice. Again, it sucks and i do hope that it won't happen again to you
(or me or anybody else). You've been victim of a petty crime...

On Feb 20, 8:49 am, Greg Donald gdon...@gmail.com wrote:
 Why do I incur a $3.00 Marketplace chargeback when someone else steals
 a credit card and buys my app?

 I'm not the one who stole the credit card, WTF?  That's insane.  I
 just lost $6.00 on two bogus sales.  That's a really significant when
 I'm only selling apps at $0.99/app.

 Broken Marketplace stats since fucking December, now I'm being raped
 by Google over some petty thieves.

 This is messed up.

 --
 Greg Donald
 destiney.com | gregdonald.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


[android-developers] Re: Petition: Google, please improve the Android Market.

2010-02-22 Thread Streets Of Boston
About the 325 char limit:
Maybe i'm a little slow, but I discovered just recently that you can
put a little more text into your app's description using FireFox than
when using IE.

IE adds 2 characters for each newline (\r\n), while FireFox only adds
1 char (\n only).
(and in FireFox, the screenshots and promo-image are properly shown...
not so in IE).

On Feb 22, 10:44 am, Vladimir vladimir.funti...@gmail.com wrote:
 For me the most important thing lacking is communication. Recent
 Market updates, plans for the future? If they told us they're working
 on features X and Y, and expecting to release an update by date Z, I
 wouldn't worry so much. Or if they told us we WILL NOT add features X
 and Y because of Z. But when there's silence, I assume the worst.

 Also, would love to see an update to app ratings. Not the sort of
 update that randomly moves your apps 50 spots up or down without any
 notice or explanation. How about sorting by download #? by rating? top
 of the day/month? etc. ATM it all depends too much on some secret
 formula, which seems to change over time. This is just wrong.

 Proper copy protection? not really important though compared to other
 issues.

 And yes, the limit is actually 325 chars. Wish it was 350, o,
 would be so awesome lol

 On Feb 21, 3:43 pm, Rob Irondad rob.iron...@gmail.com wrote:



  Hi fellow developers.
  I've come up with this text for a petition (warning: long):

 http://docs.google.com/View?id=dd9hmc43_0c9zh58gd

  You're all welcome to review it and send your comments before I
  publish it to some petition website.
  You can email me directly (rob.iron...@gmail.com).

  --
  Rob- 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: Camera on HTC Hero: Calling camera.autoFocus(...) gives a IOException .. ?

2010-02-22 Thread Streets Of Boston
Bump...
... I'm not sure where else to ask this question.

On Feb 19, 10:31 am, Streets Of Boston flyingdutc...@gmail.com
wrote:
 I found some posts about not have a preview-callback. But my camera
 does not have a preview-callback set at all. I'm wondering where this
 IOException is coming from. Is it specific to the Hero?

 On Feb 18, 7:23 am, Streets Of Boston flyingdutc...@gmail.com wrote:



  This is the stack trace:

  Android OS: 1.5
  Model: HERO200
  Make: heroc:sprint

  Caused by: java.io.IOException: autoFocus failed
          at android.hardware.Camera.native_autoFocus(Native Method)
          at android.hardware.Camera.autoFocus(Camera.java:313)
          at com.streetsofboston.smugdroid.snapfx.camera.SmugCamera
  $Preview.autoFocus(SmugCamera.java:1492)

  This exception is not documented. The JavaDoc of Camea.autoFocus does
  not mention this exception at all.
  How can i prevent this from happening or can i just catch it and
  continue to instruct the camera to take a picture.

  Thanks!- 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: Camera on HTC Hero: Calling camera.autoFocus(...) gives a IOException .. ?

2010-02-22 Thread Streets Of Boston
Thank you for your reply, Mark!

My code checks for the types of focus available on the phone and calls
'autoFocus(...)' only when available and needed. Even so, the SDK
documentation says that for devices that don't have auto-focus, the
callback specified in the call to 'autoFocus(callback)' will be called
immediately as if autofocus has been obtained. Quote from the JavaDoc
on developer.android.com:

If the camera does not support auto-focus, it is a no-op and
onAutoFocus(boolean, Camera) callback will be called immediately.

However, the link below says the HTC Hero for Sprint has autofocus:
http://www.htc.com/us/products/hero-sprint#tech-specs

Given all this, the IOException should not be thrown... But,
obviously, it is :=)
I patched the issue with catching the IOException and calling
'onAutoFocus(boolean,Camera)' in the catch-clause.

I tested my app thouroughly on the emulator, G1, N1 and a Moto Droid
and spent some time testing it on a Samsung Behold and a Motorola
CLIQ. I haven't had access to a Hero and I have not been able to
reproduce this error myself. Instead, I got one stack-trace e-mailed
to me automatically from a customer running an HTC Hero on Sprint
(users can agree to submit these error-reports/stack-traces
automatically when the app force-closes)

... which means that my patch may not work (i couldn't test it). This
has been the only stack-trace sent to me with this particular problem.
If other customers have HTC Heros, then they haven't encountered the
problem (yet).

I don't use uses-feature, because my app should work on phone
witouth auto-focus.

Can i send you a debug version of my app to your e-mail address?

Thank you very much for your reply and help, Mark.

-- Anton


On Feb 22, 11:34 am, Mark Murphy mmur...@commonsware.com wrote:
 Streets Of Boston wrote:
  Bump...
  ... I'm not sure where else to ask this question.

 At the same time, at least I don't know how to answer it. I have not
 seen this error, but, then again, I have not tried auto-focus on the
 Hero. To be honest, I wasn't aware it was running an Android version
 where auto-focus was available.

 Do you have the uses-feature element in your manifest to say you need
 auto-focus?

 If you can publish a project that demonstrates the error, upload it
 along with a description of the symptoms tohttp://b.android.com. If you
 think of it, post a link to the issue report here. I have a couple of
 Heros, though they're on kinda squirrelly ROM versions IIRC, so I'm not
 sure my tests will be definitive.

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

 Android Training in US: 26-30 April 2010:http://onlc.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


[android-developers] Re: Camera on HTC Hero: Calling camera.autoFocus(...) gives a IOException .. ?

2010-02-22 Thread Streets Of Boston
I understand.

The problem is that when i create this sample project, i cannot be
sure that it will recreate the problem, since i can't reproduce it.

I'll try to get a sample going (a simple camera app that uses
autofocus) and hopefully this will recreate the problem.

Thanks!

On Feb 22, 7:15 pm, Mark Murphy mmur...@commonsware.com wrote:
 Streets Of Boston wrote:
  Can i send you a debug version of my app to your e-mail address?

 Well, to be honest, I'd rather you created a little sample project that
 demonstrates the problem, so that:

 1. You can post it tohttp://b.android.com(even though it may be a
 Hero-specific problem, it's probably worthwhile to at least get people
 thinking about it, and it's a good central spot for the issue at least
 temporarily)

 2. I *and others* can test it (remember, I have a pair of strange Hero
 devices, so my tests may not be definitive; conversely, I can also test
 on a Tattoo that doesn't have auto-focus) and experiment with your
 IOException workaround

 3. If we do reproduce the problem and determine it is indeed a Hero or
 HTC thing, that we can get the project to HTC for analysis

 I realize your goal is to just get your app working, but my goal is to
 try to document and squash problems like this for everyone. Or at least
 for the subset of everyone who reads this stuff.

 So, if you can help us document the problem better, I can help you
 determine if your fix will hold up.

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

 _Beginning Android_ from Apress Now 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: Petition: Google, please improve the Android Market.

2010-02-23 Thread Streets Of Boston
Yep, you're correct.
Google gets only a small portion of the 30% to cover the costs of the
payment transactions. The bulk of the 30% goes to the carriers. At an
Android Dev Lab Google told us Google's share just covers their cost.

On Feb 22, 9:16 pm, Maps.Huge.Info (Maps API Guru)
cor...@gmail.com wrote:
 You might want to drop the let's not forget clause as it's something
 that wouldn't help any petition and could keep people from agreeing
 with you.

 Google doesn't get 30% of your app sales, the carrier's cut, taxes,
 fees for the merchant account and other costs eat that up to probably
 zero profit or near to it.

 -John Coryat

 On Feb 22, 7:56 pm, Matthew LeMieux cycleme...@gmail.com wrote:



  Has anybody else noticed that it is very difficult for many users to go
  through the flow to even be able to purchase an app?  I would like to see
  getting a paid app be as easy as getting a free app.  Perhaps giving users
  the opportunity to register and add apps to their phone on a desktop rather
  than only on the phone (similar to the experience iPhone users have).

  When I originally went through the flow on my G1, I found that the
  registration data was in a small dialog where I couldn't really see what was
  being entered while I was entering it.  I was a highly motivated user and
  hence completed the whole process, but what about a casual user?

  How many users do you think have fallen out of your sales funnel at that
  point?   I would be very interested to see data on how many android users
  have completed the registration flow for purchasing paid apps...

  -Matthew

  On Sun, Feb 21, 2010 at 5:43 AM, Rob Irondad rob.iron...@gmail.com wrote:
   Hi fellow developers.
   I've come up with this text for a petition (warning: long):

  http://docs.google.com/View?id=dd9hmc43_0c9zh58gd

   You're all welcome to review it and send your comments before I
   publish it to some petition website.
   You can email me directly (rob.iron...@gmail.com).

   --
   Rob

   --
   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- 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: Petition: Google, please improve the Android Market.

2010-02-23 Thread Streets Of Boston
Well,

This is what Google told us at the Android Developers Lab. The bulk of
the 30% goes to the carriers, a fraction of this 30% goes to google to
run Google Checkout and the payment processor.

I guess the bulk of the 30% that goes to the carrier is an incentive
to have Android Market (and not other markets?) installed.


On Feb 23, 10:49 am, Disconnect dc.disconn...@gmail.com wrote:
 Google has been very vague about where that 30% goes when you're on a nexus,
 adp, etc.



 On Tue, Feb 23, 2010 at 10:37 AM, Hekki kaye...@gmail.com wrote:
  Hi,

  Are you sure about the carrier thing ?

  I don't see when they are involved :

  Clients only use the carrier as a dumb pipe here to get internet
  access, they pay using google checkout which have their credit card
  information(much like itunes does).
  So google handle the payment itself.

  When is the carrier involved at all ? I don't understand.

  Yahel

  On 23 fév, 15:58, Streets Of Boston flyingdutc...@gmail.com wrote:
   Yep, you're correct.
   Google gets only a small portion of the 30% to cover the costs of the
   payment transactions. The bulk of the 30% goes to the carriers. At an
   Android Dev Lab Google told us Google's share just covers their cost.

   On Feb 22, 9:16 pm, Maps.Huge.Info (Maps API Guru)

   cor...@gmail.com wrote:
You might want to drop the let's not forget clause as it's something
that wouldn't help any petition and could keep people from agreeing
with you.

Google doesn't get 30% of your app sales, the carrier's cut, taxes,
fees for the merchant account and other costs eat that up to probably
zero profit or near to it.

-John Coryat

On Feb 22, 7:56 pm, Matthew LeMieux cycleme...@gmail.com wrote:

 Has anybody else noticed that it is very difficult for many users to
  go
 through the flow to even be able to purchase an app?  I would like to
  see
 getting a paid app be as easy as getting a free app.  Perhaps giving
  users
 the opportunity to register and add apps to their phone on a desktop
  rather
 than only on the phone (similar to the experience iPhone users have).

 When I originally went through the flow on my G1, I found that the
 registration data was in a small dialog where I couldn't really see
  what was
 being entered while I was entering it.  I was a highly motivated user
  and
 hence completed the whole process, but what about a casual user?

 How many users do you think have fallen out of your sales funnel at
  that
 point?   I would be very interested to see data on how many android
  users
 have completed the registration flow for purchasing paid apps...

 -Matthew

 On Sun, Feb 21, 2010 at 5:43 AM, Rob Irondad rob.iron...@gmail.com
  wrote:
  Hi fellow developers.
  I've come up with this text for a petition (warning: long):

 http://docs.google.com/View?id=dd9hmc43_0c9zh58gd

  You're all welcome to review it and send your comments before I
  publish it to some petition website.
  You can email me directly (rob.iron...@gmail.com).

  --
  Rob

  --
  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.comandroid-developers%2Bunsubs
  ­cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en-Hidequoted
  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.comandroid-developers%2bunsubs­cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en- 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: Gridview loads in reverse on onConfigurationChanged

2010-02-24 Thread Streets Of Boston
Thanks!

But I think you will get serious performance issues on GridViews and
ListViews with many items. In your fix, you cache the View for each
possible item. This defeats the purpose of the 'convertView' parameter
which has a non-null value when the GridView re-uses a cached View.
The amount of Views cached by the GridView is no more than the amount
of (partially) visible items on the screen
(=ListView.getChildCount()), not the number of possible items
(=BaseAdapter.getCount()), which can be much larger.

If you BaseApapter can have many items (more items than can be viewed
simultaneously on the screen), you'll likely to hit some serious
performance/memory/resource issues.

On Feb 24, 1:12 pm, Bolha lucasros...@gmail.com wrote:
 Hello, guys.

 I've had the same problem and solved it by saving the created views in
 an array inside the adapter. Check the chunks of code below:

 public class ImageButtonCanalAdapter extends BaseAdapter {
         private Context contexto;
         private ListMyClass list
         private View savedViews[];

        [...]

         public View getView(int position, View convertView, ViewGroup parent)
 {
                 if (convertView == null) {
                         this.viewsBotoes[position] = new MyView 
 (this.contexto);
                 }

                 return this.viewsBotoes[position];
         }

 }

 I hope it helps.

 Best regards.

 Bolha

 On 20 jan, 00:35, Streets Of Boston flyingdutc...@gmail.com wrote:



  The animation is not necessary to make it happen. It just makes it
  really easy to actually see the issue :-)

  On Jan 19, 6:06 pm, Mike M mike.mos...@gmail.com wrote:

   yeah,
   I get the same on Droid 2.0, Although I get it without having
   animation applied to the gridview...

   I wish there was a uniform / sequential way that getView() was
   called...

   On Jan 18, 5:29 pm, Streets Of Boston flyingdutc...@gmail.com wrote:

Hi Roman,

It does happen. :-)

I can reproduce it almost every time like this:
- Just create an activity with a Grid View with quite a few images (or
grid-items) and attach a grid-layout-animator to the grid-view.
Configure the grid-view-animator in such a way that you see how the
grid-view-items are laid-out. E.g. columns first, rows later.
- Create an (empty) sub-activity that can be launched from the one
having the grid-view.

- Start your grid-view's activiy in portrait orientation.
- Start your sub-activity.
- Rotate your phone into landscape orientation.
- Press back to finish the sub-activity.
  The grid-view's activity is shown again and...

... 9 out of 10 times, i see the grid-view being built up in reverse
mode (i'm running on 2.1, Nexus One).

In my app, the 'getView()' method does not rely on the order in which
the 'getView()' is called at all.

On Jan 18, 2:15 am, Romain Guy romain...@android.com wrote:

 I have never noticed such an issue. The only way I can think of that
 would cause this to happen would be if your adapter relies on the
 order of the getView() calls. Note there is absolutely no guarantee
 about the order in which getView() will be called (the position
 argument will not necessarily be sequential, incrementing or
 decrementing.)

 On Sun, Jan 17, 2010 at 8:57 PM, Mike M mike.mos...@gmail.com wrote:
  Streets of Boston,

  Thanks for the reply.  I do have an animation on my GridView, but I
  took it off and still notice the problem.

  Any ideas?

  Thanks

  On Jan 17, 1:23 pm, Streets Of Boston flyingdutc...@gmail.com 
  wrote:
  I've seen this too in my app.

  If you add a layout-animation, that animates the grid-view children
  (i.e. the grid-items), you can clearly see this reverse order.

  On Jan 17, 4:03 am, Mike M mike.mos...@gmail.com wrote:

   Hey everyone,

   I have a gridview of images that I load from the internet.  When 
   the
   phone rotates (or some other config change), 
   onConfigurationChanged()
   is called.  When that happens, the items in the gridview are 
   reversed
   (meaning, the 1st image is the last; they are in reverse order).

   Does anyone know why this is or how to change it?   I'm hoping 
   someone
   has run into this before...

   Sorry if I don't share any code.  I don't think It'd help; it's 
   more
   of a conceptual question.

   Thanks,

   Mike

  --
  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-developers] Re: No streamlined update system (What a mess)

2010-02-24 Thread Streets Of Boston
This is not an update issue. This is a fragmenation issue.

Application developers decide, depending on their resources (money and
time), to support only particular or all versions of the Android OS
for their apps.

Fragmentation is the problem here, since handset/phone makers still
bring out phones with old OS versions and are hesitant to update
existing ones.

Some fragmentation will be inevitable. Some phones just don't have the
hardware to deal with certain applications. They're too slow, screen
is too small, no GPU, etc. Phones, like many other gadgets, get old
very quickly.

On Feb 23, 6:05 pm, s3ction8 kennethjohns...@gmail.com wrote:
 I just posted this in the regular android discuss group but I do
 believe that developers should read this as well. This directly
 affects you as well.

 This first began with my personal experience, I have an HTC Magic and
 I'm at version 1.5 a friend of mine has a g1 while another just got a
 Milestone. The issue is one friend can't understand why one phone can
 see this app and another can't or why one phone can do one thing that
 another can't, Their both running android whats the problem (ex. The
 Milestone has maps 3.3.1 the G1 has old Maps 3.1). I'm getting tired
 of explaining that even though they are both androids one is more up
 to date then the other and there really is no way to update. Even IF
 you rooted the phone you have to deal with bugs and ports its
 ridiculous. Now I love Android and I want to see Android KILL iPhone
 and eventually Symbian and I DO know that this is not necessarily
 Google's problem but it is indeed a problem that affects Google and
 it's users wanting to get the full Google Experience. I recently read
 a PC World article stupidly titled Android doomed to self destruct
 which I do not believe and its at this 
 link:http://www.pcworld.com/article/189969/google_android_is_doomed_to_sel...
 but I realized that I am not the only person that sees this. Today
 there is an article on Slashdot as well as 2 on infoworld. We need to
 fix this at least some kind of update system that does not rely on
 manufacturers or at least forces them to act. Devices are releasing
 today with android 1.6 and if I research I'll probably find a few
 releasing 1.5. HTC is still pumping out Magic's with this old
 firmware, it's just getting very messy all across the board. Is there
 any suggestion as to what can be done at least on paper, any ideas?
 Thank you

-- 
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 know touched cube in opengl ?

2010-02-24 Thread Streets Of Boston
Brush up on your geometry. :=)

Map from a two dimensional coordinate (screen) to a 3 dimensional one
(model):

(ScreenX, ScreenY, 0) --gluUnproject-- (ModelX1, ModelY1, ModelZ1)
(ScreenX, ScreenY, 1) --gluUnproject-- (ModelX2, ModelY2, ModelZ2)

Now you 'draw' an invisible line from (ModelX1, ModelY1, ModelZ1) to
(ModelX2, ModelY2, ModelZ2) and find first intersection point of this
line with a cube. This cube is the one that has been touched.

I found that the gluUnproject that came with the SDK is buggy. I wrote
my own:
http://groups.google.com/group/android-developers/browse_frm/thread/9d2bf53e3a798cb6/c722628acdf6e2d9?lnk=gstq=gluUnproject#c722628acdf6e2d9
(go to message #8)

On Feb 24, 2:31 am, Louis Huh avatar@gmail.com wrote:
 I drew cubes using opengl,

 GLSurfaceView has onTouchEvent method. but I'd like to know

 what cube was touched ?

 cubes can move anywhere in the viewport...

-- 
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: Out of Memory resuming application

2010-02-25 Thread Streets Of Boston
It could be anything. You have to post some code-samples that you
think code be suspicious.
Check your (static) caches, if you have them.

On Feb 25, 6:49 am, REvolver luca.lupol...@gmail.com wrote:
 None?

-- 
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: why I can't see google's nexus one from eclipse

2010-02-25 Thread Streets Of Boston
The drivers that come with the latest Android SDK download work well
for Vista 64bit and Windows 7 64bit (i used it on both). I don't know
about XP 64bit, though...

On Feb 16, 9:51 pm, Bob Kerns r...@acm.org wrote:
 You might try running a VMWare Virtual Machine, with a 32-bit XP, and
 doing it from there.

 That's what I had to do to talk to my LiveScribe pen until they got
 their 64-bit drivers together. (I don't know if they ever work for
 XP-64, it's just not that common on a desktop, but Vista 64 and now
 Windows 7 64 are the norm now on new hardware).

 On Feb 16, 11:52 am, DonFrench dcfre...@gmail.com wrote:



  Unless you are on XP-64, in which case it appears that there is no
  way.  Someone correct me if they know different.- 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: Free Version of App

2010-02-25 Thread Streets Of Boston
How do you make a time limited trial version, where limiting the time
is fairly fool-proof? How do you know how long the user has your app
installed (including the possibility that the app has been uninstalled
one or more times...)?

Thanks!
On Feb 25, 2:34 am, String sterling.ud...@googlemail.com wrote:
 On Feb 25, 4:00 am, Carmen Delessio carmendeles...@gmail.com wrote:

  It seems like it should be possible to have 2 apps signed with same
  certificate.
  See the info below.  If your paid app exposed functionality to your free app
  you would get the free/paid goal.
  The free app would check whether paid app was installed, if it was it would
  be used.  If not an upgrade message would be displayed.

 This is exactly what I do with one of my apps, TerraTime. I call the
 paid app the license, and it has essentially no functionality of its
 own; it just needs to be present for the full functionality of the
 free app to be unlocked. I have a slightly different marketing
 strategy - my free app has the full feature set, but is just time-
 limited to a trial period. It's that time limit which the license
 unlocks. But the same approach should work for a freemium model like
 yours.

 The major advantage to this is a single code base. From this
 perspective, it works well.

 There are a number of small drawbacks that I've found, however.
 Primarily, it causes some confusion for the user... The free app is
 named TerraTime Trial, but it needs to stay installed when the user
 upgrades. I mostly get around this with clear instructions in all the
 relevant places. This may be less applicable with your strategy; just
 make sure you don't name the free version Lite or some such. And
 make VERY clear in the app description that it's a freemium model, or
 you'll get complaints.

 Overall, it'd be better if the Market supported in-app purchases (like
 certain other App Stores do). But there are so many other, more
 serious problems with the market that this feature is probably -
 hopefully - pretty far down the priority list.

 A completely different possibility might be to organize your code into
 a single JAR file which you can then include in both application
 packages. While this would let you maintain only a single version of
 your Java source, it wouldn't help you with other code (manifests,
 resources, etc). Also, I've personally never got it to work, but I
 think that's more to do with unfamiliarity with Eclipse  Java outside
 of the usual Android development track.

 String

-- 
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 I get the seconds since 1.1.1970 as a long in Android?

2010-02-25 Thread Streets Of Boston
System.currentTimeMillis() gets you the number of milliseconds sinc
1/1/1970 00:00:00.000 UTC.

On Feb 25, 1:21 pm, Martin google-gro...@digle.de wrote:
 Hi!

 There are so many Date-classes (GregorianCalendar, Calendar, TimeZone,
 Date,.), I lost track.

 How can I get the seconds now since 1.1.1970 as long in Android?

 Greetings, Martin

-- 
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, send me logs! - code library for detecting force-close and sending logs

2010-02-26 Thread Streets Of Boston
I haven't made it public yet (i will at some point), but i have a
similar system for my apps.

The process of my activities registers itself by calling
Thread.setDefaultUncaughtExceptionHandler(uncaughtXcptHandler) and
binds to service that i wrote that runs in a different process (since
my app will be dying because of an exception, it's tricky to properly
handle the exception in the dying process itself).

Then in the uncaughtXcptHandler.void uncaughtException(Thread t,
Throwable e), I write out an error-log file with the stack-trace and
some other info. Then i call an asynchronous method on my service that
will pop up a dialog allowing the user to send me the error report or
not. If the user clicks 'Yes', then the error-log file is read and
sent to my webserver. My webserver then sends me an e-mail. This way,
users can remain anonymous (no e-mail/reply address necessary).

I let my app die immediately after calling the asynchronous method. If
my app couldn't bind to the service for any reason, the old and
trusted force-close message from Android is shown instead.



On Feb 25, 3:10 pm, focuser linto...@gmail.com wrote:
 Hi fellow Android developers,

 How many times have you asked users to send you the logcat result to
 track down a nasty force-close?  How many users have actually replied?

 It's not that users are lazy or busy.  Having to run the logcat
 command or download an external log collector app just means too much
 trouble for them.  It should be much simpler.  It should be just one
 tap.

 In fact I'm surprised (or being ignorant) that an easier error
 reporting mechanism has not existed yet in the Android API, especially
 for the infamous force-close.  That is why I coded and open-sourced
 Android, send me logs!, a small code library that makes it easy to
 detect force-close and send logs from within your own apps.  You can
 program it to report errors with just one tap, and also include your
 own tracing information.

 Please check it out athttp://code.google.com/p/android-send-me-logs/.
 It's still in very early stage, and I would appreciate your critism,
 suggestions, comments, or even code contributions.

 Linton Ye

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


<    1   2   3   4   5   6   7   8   9   10   >