[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 AsyncTask {


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  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  wrote:
>
>
>
> > >private final class Task extends AsyncTask {
> > ...
> > >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  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  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  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  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  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 AsyncTask {
>
> > >         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  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  wrote:
>
> > > > > >private final class Task extends AsyncTask {
> > > > > ...
> > > > > >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);
>
> > > > > Thi

[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  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  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  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  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  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 AsyncTask {
>
> > > > >         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
> > >

[android-developers] Re: AsyncTask and ProgressDialog

2009-11-10 Thread Streets Of Boston
ted = true;
>                         notifyActivityTaskCompleted();
>                 }
>
>                 private void notifyActivityTaskCompleted() {
>                         if ( null != activity ) {
>                                 activity.onTaskCompleted();
>                         }
>                 }
>
>                 private void setActivity(MyActivity activity) {
>                         this.activity = activity;
>                         if ( completed ) {
>                                 notifyActivityTaskCompleted();
>                         }
>                 }
>
>         }
>
> }
>
> On Nov 10, 5:41 pm, Lee Jarvis  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  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,LeeJarvis 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  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,LeeJarvis 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,LeeJarvis 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  
> > > > > > > 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_IN

[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  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  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  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  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.com > > >  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"
 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  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  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  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  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  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  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  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=gst&q=gluUnproject#07cfa3ee11507fc1


On Nov 22, 3:35 am, Anfernee  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  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  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  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/AndroidRunti

[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  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?
>
> 
> 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()));
>         }
>
> 

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

[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  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
>
>
>
>
>
>  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  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
>
> >>  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  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):
> 

[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  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
> wrote:
>
>
>
> > 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  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
>
> > >  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  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
>
> > > >>  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: 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  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
> wrote:
>
>
>
> > 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  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
>
> > >  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  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
>
> > > >>  wrote:
> > > >> > i&#

[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  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  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
> > wrote:
>
> > > 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  wrote:
> > > > That would be worrisome because we do not save/restore the state of
> > > > views without ids.
>
> > > > On Tue, Nov 24, 20

[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  wrote:
> http://code.google.com/p/android/issues/detail?id=5045";>Issue
> 5045
>
> http://code.google.com/p/android/issues/detail?id=5045
>
> On Nov 25, 9:37 am, Matt Kanninen  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  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  wrote:
> On Tue, Nov 17, 2009 at 7:06 AM, Streets Of Boston
> wrote:
>
> > 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  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  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 
>
>
>
>
> > 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  wrote:
> > > On Tue, Nov 17, 2009 at 7:06 AM, Streets Of Boston
> > > wrote:
>
> > > > 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
>
> --
> 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  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  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  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 thread&handler 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: ProgressDialog from within ContentProvider class!

2009-12-05 Thread Streets Of Boston
If you need to inform user of progress of your ContentProvider's
actions, you shouldn't do it directly in your ContentProvicer, as the
other posters in this thread have said as well.

Instead, you could have your ContentProvider-process implement a
Service as well that will call back into any Activity ( that has
registered for such callbacks) when progress needs to be updated. The
activity can then show a progress indicator/dialog.

On Dec 5, 12:03 pm, Abdul Mateen  wrote:
> Hi,
> I have been stuck at a place , strange, I have a content provider class i.e
> class extends ContentProvider, I want to know about the method to show the
> dialog to the user when upgrading / creating a content provider or database
> from within content provider, I tried many ways for it, but nothing seems to
> be working, Can anybody here direct me to the reference or can tell me the
> way I can show progress dialog box from within contentprodiver.
>
> Thank You,
> Abdul Mateen.

-- 
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: Apps silently close due to low memory (in remote Content Providers)

2009-12-06 Thread Streets Of Boston
It would still be nice to see some kind of callback/warning that such
a thing is about to happen.

I'm writing an app that uses a cursor to iterate over images from the
system's media-content-provider.

Sometimes this content-provider is being shut-down (low memory) and it
takes my application down with it.

On Dec 6, 6:41 pm, Dianne Hackborn  wrote:
> The system raises the level of the process(es) hosting content providers you
> are using to the same level as yours; so if your app is in the foreground
> when this happens, it means that there is just so little memory available in
> the system that it can't even keep all of the foreground processes going,
> and aside from simply not using that provider there is little you can do.
>  (You can be sure to not keep open access on providers, if you are keeping
> them open for a long time, so the system has some other process to kill that
> you don't need right then.)
>
> If this is happening while you are in the background running a service...
>  well, getting killed while in the background is something that will happen,
> and the more sessions you have with providers the more likely it is to
> happen since this causes more memory pressure.  Again, only keep providers
> open while you need them, and accept you will have your service killed at
> some points, with or without it using providers.
>
> On 1.6 you can use "adb shell dumpsys activity" to see a list of all of the
> running processes, what level they are at, and why this is, which can help
> track down for example why a lot of processes may be in the foreground.
>  This is the second to last pocess list, with the oom_adj levels.
>
> On Sun, Dec 6, 2009 at 9:58 AM, Daniel wrote:
>
>
>
>
>
> > Some of my apps silently close on my G1 (Android 1.6) because some
> > Content Providers they use are hosted in processes that are killed due
> > to low memory. Is there anything to protect an app from silently
> > closing because a content provider it uses is shut down? Is there some
> > remote exception to give the app a change to continue its work with
> > less features (e.g. do not query dead content providers)?
> > Below is a trace that shows this situation.
>
> > Quickdroid uses the BrowserProvider. But since the BrowserProvider and
> > its hosting Linux process died, Quickdroid is also killed silently.
> > That is a really bad user experience :-(
>
> > I/ActivityManager(   75): Starting activity: Intent
> > { cmp=fm.last.android/.activity.Preferences }
> > I/ActivityManager(   75): Process fm.last.android:player (pid 17574)
> > has died.
> > I/ActivityManager(   75): Low Memory: No more background processes.
> > I/ActivityManager(   75): Displayed activity
> > fm.last.android/.activity.Preferences: 844 ms (total 844 ms)
> > D/dalvikvm(17546): GC freed 4991 objects / 247032 bytes in 155ms
> > I/ActivityManager(   75): Start proc fm.last.android:player for
> > service fm.last.android/.player.RadioPlayerService: pid=17676
> > uid=10051 gids={3003, 1015}
> > I/fm.last.android.player(17676): Player service started
> > I/ActivityManager(   75): Stopping service:
> > fm.last.android/.player.RadioPlayerService
> > I/fm.last.android.player(17676): Player service shutting down
> > I/ActivityManager(   75): Start proc vu.de.urpool.quickdroid for
> > activity vu.de.urpool.quickdroid/.Quickdroid: pid=17683 uid=10030 gids=
> > {}
> > I/ActivityManager(   75): Process fm.last.android:player (pid 17676)
> > has died.
> > I/ActivityManager(   75): Low Memory: No more background processes.
> > I/ActivityThread(17683): Publishing provider quickdroid:
> > vu.de.urpool.quickdroid.apps.AppProvider
> > I/ActivityManager(   75): Start proc com.android.browser for content
> > provider com.android.browser/.BrowserProvider: pid=17696 uid=10022
> > gids={3003}
> > I/ActivityThread(17696): Publishing provider browser:
> > com.android.browser.BrowserProvider
> > I/ActivityManager(   75): Displayed activity
> > vu.de.urpool.quickdroid/.Quickdroid: 2802 ms (total 2802 ms)
> > I/ActivityManager(   75): Process fm.last.android (pid 17546) has
> > died.
> > I/WindowManager(   75): WIN DEATH: Window{4397eb40 fm.last.android/
> > fm.last.android.activity.Profile paused=false}
> > I/ActivityManager(   75): Low Memory: No more background processes.
> > I/ActivityThread(17683): Removing dead content provider: browser
> > I/ActivityManager(   75): Process com.android.browser (pid 17696) has
> > died.
> > I/ActivityManager(   75): Killing app vu.de.urpool.quickdroid (pid
> > 17683) because provider com.android.browser.BrowserProvider is in
> > dying process com.android.browser
> > I/Process (   75): Sending signal. PID: 17683 SIG: 9
> > I/WindowManager(   75): WIN DEATH: Window{43a0eff0
> > vu.de.urpool.quickdroid/vu.de.urpool.quickdroid.Quickdroid
> > paused=false}
> > I/ActivityManager(   75): Low Memory: No more background processes.
> > I/ActivityManager(   75): Process vu.de.urpool.quickdroid (pid 17683)
> > has died.
> > W/UsageStats(   75): Unex

[android-developers] Re: Inconsistent results from date additions loop

2009-12-07 Thread Streets Of Boston
You don't know how many milliseconds there are in a day, or even how
many hours there are.

Most days have 24 hours, one may have 23 and an other may have 25
hours ( DST ). And this depends whether your timezone has DST or not.
The Calendar class should be able to figure all this out.

However, if you're just interested in 'before' or 'after', then
comparing the dates using the milliseconds is OK, since you don't need
to know the exact amount.

Andrew, post a code snippet and describe exactly what problem you see.

On Dec 7, 6:38 am, "Dexter's Brain"  wrote:
> Doing it the millisecond way might be more confortable.
>
> Convert both the dates to milliseconds, and then subtract one from the
> other, and then calculate the no of days.
>
> Thanks
> Kumar Bibekhttp://tech-droid.blogspot.co
>
> On Dec 7, 4:52 am, andrew android  wrote:
>
>
>
> > I am running code to return date-based calculations.  The method is
> > designed to calculate the number of work days given a beginning and
> > ending date and I pass in the elements of the dates, create two
> > calendar objects from the two dates and compare them.
>
> > Can anybody tell me if there is a bug causing inconsistent results
> > from
>
> > c2.add(Calendar.DATE, 1);
>
> > or possibly the Calendar.after method ...?
>
> > c2.set(ccyy, mm, dd);
> > c4.set(ccyyNew,mmNew, ddNew);
>
> > c4.after(c2)
>
> > Please help...- 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 Preview Filter Choppiness

2009-12-07 Thread Streets Of Boston
How fast is 'decodeYUV' method? You call this method while your canvas
is locked.
If 'decodeYUV' is slow, it not only makes your background thread
sluggish, but your main GUI-thread as well, because the canvas is
locked for too long.

Also, you don't synchronize on '_data'... Your implementation of
'onPreviewFrame' is filling '_data' and your background thread is
reading it. The filling(=arraycopy) of '_data' may not be finished
before your it's being read by your background thread.


On Dec 5, 9:41 pm, Greg  wrote:
> Hello,
> I've been working on creating a program that will output the Camera
> Preview with various user-chosen filters (SnapPhoto has this
> functionality) and I've run into some problems.
>
> I have the following set up.
> - Camera preview set to a SurfaceView (I had to set PUSH_BUFFERS or
> the program fails).
> - Have another SurfaceView lieing over the Camera preview SurfaceView
> (in a FrameLayout)
> - Registered a camera callback for the preview data
>
> My problem is that the output is extremely choppy and the program
> quickly becomes unresponsive. I've set up a thread to do the
> processing, but this doesn't seem to help. I've implemented the
> decoding (into rgb_) algorithm (courtesy of 
> dmanpearlhttp://groups.google.com/group/android-developers/msg/d3b29d3ddc8abf9b
> ) Is there anything I'm doing blatantly wrong or something I could fix
> to make this program run at a decent speed? Sorry if the code has poor
> style, I'm sort of an Android beginner and, for that matter, Java
> beginner.
>
> This code is inside the second SurfaceView, lieing over the Camera
> preview SurfaceView
>
> public void onPreviewFrame(byte[] data, Camera camera) {
>                 if(hasSurface) {
>                                 System.arraycopy(data, 0, _data, 0, 
> data.length);
>                                 outputThread = new HandleOutput();
>                                 outputThread.start();
>                 }
>         }
>
> where HandleOutput() extends Thread, and _data is a global array.
>
> and this is inside the Thread
>
> public void run() {
>                         while(!done) {
>                                 canvas = mHolder.lockCanvas();
>                                 PixelManip.decodeYUV(rgb, _data, width, 
> height); //courtesy of
> dmanpearl (link above)
>                                 PixelManip.applyFilter(filterID, _data, rgb);
>                                 bitmap.setPixels(rgb, 0, width, 0, 0, width, 
> height);
>                                 canvas.drawBitmap(bitmap, 0, 0, paint);
>                                 mHolder.unlockCanvasAndPost(canvas);
>                                 done = true;
>                         }
>                 }
>
> Thanks,
> Greg
>
> P.S. Let me know if I should post any more 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: Problem Troubleshooting Vista ADB USB Connection.

2009-03-12 Thread Streets Of Boston

If you have Vista 32 bit installed, it should work and i can't help
you to fix your problem.

However, if you have a 64bit system, check this thread:
http://forum.xda-developers.com/showthread.php?t=446274&highlight=64bit+usb

It may fix your issues :)

On Mar 11, 4:12 pm, JLMG  wrote:
> This one is kinda weird...
>
> I have a Ubuntu 8.10 box with everything including Eclipse working
> perfectly, both the emulator and USB connection to my ADP1... works
> perfectly!
>
> But I decide to inflict Vista on myself by attempting to get Eclipse
> and ADT working on my Vista laptop.
>
> I set up Vista with Eclipse and installed the Android plug-in...
> but... the only thing NOT working is the USB connection using the
> exact same USB cable to the exact same ADP1.
>
> Everything including the emulator is just fine, but no USB to ADP1.  ;o
> (
>
> Here is the message I get when I try to use the ADB command line:
> --
>
> Microsoft Windows [Version 6.0.6000]
> Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
>
> C:\Users\John>adb version
> Android Debug Bridge version 1.0.20  < (Same version as on the
> Linux box)
>
> C:\Users\John>adb shell
> * daemon not running. starting it now *
> * daemon started successfully *
> error: device not found
>
> C:\Users\John>adb shell
> error: device not found
>
> C:\Users\John>
>
> --
>
> And to top it all off, the Device Manager shows the ADP1 sdcard as a
> USB mass storage device. but won't let me install the USB driver over
> the Microsoft version.
>
> I've been scouring around looking for a solution but remain flummoxed
> so far.
>
> Thanks for any pointers to a solution for this vexing pain in the
> Windows!
>
> JLMG
--~--~-~--~~~---~--~~
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: Menu option starts Thread - menu hangs.

2009-03-12 Thread Streets Of Boston

Could you provide a code-snippet showing how you coded the menu-
handling and the starting of your thread?


On Mar 12, 10:00 am, Ikon  wrote:
> Hi,
>
> I am developing a game based on the SurfaceView/LunarLander example in
> the sample code.
> I have one activity, with one menu option that is "new game".
>
> My activity listens for the menu selection, and once new game is
> selected, doStart of the Game thread is called.  The game starts up
> after 3-4 seconds, but the menu option sticks around on the screen
> until the game has started.  I think the main thread is waiting on the
> doStart to do its thing, but since it's creating a new thread, how do
> I get it to just start the thread and continue its business of hiding
> the menu option right away, instead of after 3 seconds?
>
> Thanks,
> Ayan
--~--~-~--~~~---~--~~
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 transfer an action(ex:key press) from an Activity to other Activities

2009-03-12 Thread Streets Of Boston

First you should figure out what you really try to accomplish. I don't
know the details of your app, but i guess that your goal is not to
push a button. The goal is the action that occurs when the button is
pushed.

I would just call the action (method/java-code/etc) directly that
would have been called by the button-click of the other activity.

On Mar 12, 7:31 am, "npak...@gmail.com"  wrote:
> Hi all,
> When my application is running, a button is pressed.After my
> application processes this event, i want to continue to transfer this
> event to other applications. Is it possible? If yes, how to do that?
> I very appreciate your advices,
> Thanks,
> NPAK
--~--~-~--~~~---~--~~
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: Does Camera API really works ?

2009-03-12 Thread Streets Of Boston

Maybe i'm stating the obvious here: Did you assign the camera-
permission to your application in your manifest file?

On Mar 12, 12:18 pm, crowcasso  wrote:
> Currently the above code is crashing for me (even after fixing the 3
> params instead of 2) when performing takePicture() with a IOException:
>
> W/System.err( 1470): java.io.IOException: takePicture failed
> W/System.err( 1470):    at android.hardware.Camera.native_takePicture
> (Native Method)
>
> I've written a different Camera application that crashes as well on
> takePicture(). Is this a known issue? Any suggestions?
>
> On Mar 10, 6:50 pm, Streets Of Boston  wrote:
>
>
>
> > Maybe this piece of code won't work, but i'm writing an app that
> > successfully uses thecamera.
> > No crashes :)  ...   ... so far ... :=)
>
> > On Feb 17, 1:35 am, cindy  wrote:
>
> > > I tried google'scameraAPI sample code. I found there are 2 problems:
> > > 1> It only can take picture in Landscape orientation
> > > 2> After click the space "key", the application crashes. WOw:)
>
> > > XML:
> > > http://schemas.android.com/apk/res/
> > > android"
> > >     android:layout_width="fill_parent"
> > > android:layout_height="fill_parent"
> > >     android:orientation="vertical">
> > >      > >         android:layout_width="fill_parent"
> > > android:layout_height="10dip"
> > >         android:layout_weight="1">
> > >     
> > > 
> > > Java code:
> > > /**
> > >  * Copyright (c) 2007, Google Inc.
> > >  *
> > >  * Licensed under the Apache License, Version 2.0 (the "License");
> > >  * you may not use this file except in compliance with the License.
> > >  * You may obtain a copy of the License at
> > >  *
> > >  *    http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing,
> > > software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > implied.
> > >  * See the License for the specific language governing permissions
> > > and
> > >  * limitations under the License.
> > >  */
>
> > > package com.android.cameraapitest;
>
> > > import android.app.Activity;
> > > import android.content.Intent;
> > > import android.graphics.Canvas;
> > > import android.graphics.Paint;
> > > import android.graphics.PixelFormat;
> > > import android.graphics.Rect;
> > > import android.net.Uri;
> > > import android.os.Handler;
> > > import android.os.Message;
> > > import android.os.Bundle;
> > > import android.provider.MediaStore.Images;
> > > import android.provider.MediaStore.Video;
> > > import android.view.Menu;
> > > import android.view.MenuItem;
> > > import android.view.SurfaceHolder;
> > > import android.view.SurfaceView;
> > > import android.view.KeyEvent;
> > > import android.hardware.Camera;
>
> > > import android.util.Log;
>
> > > public class CameraApiTest extends Activity implements
> > > SurfaceHolder.Callback
> > > {
> > >     private static final String TAG = "CameraApiTest";
> > >    CameramCamera;
> > >     boolean mPreviewRunning = false;
>
> > >     public void onCreate(Bundle icicle)
> > >     {
> > >         super.onCreate(icicle);
>
> > >         Log.e(TAG, "onCreate");
>
> > >         getWindow().setFormat(PixelFormat.TRANSLUCENT);
>
> > >         setContentView(R.layout.camera_api_test);
> > >         mSurfaceView = (SurfaceView)findViewById(R.id.surface);
>
> > >         mSurfaceHolder = mSurfaceView.getHolder();
> > >         mSurfaceHolder.addCallback(this);
> > >         mSurfaceHolder.setType
> > > (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
> > >     }
>
> > >     public boolean onCreateOptionsMenu(android.view.Menu menu) {
> > >         MenuItem item = menu.add(0, 0, 0, "goto gallery");
> > >         item.setOnMenuItemClickListener(new
> > > MenuItem.OnMenuItemClickListener() {
> > >             public boolean onMenuItemClick(MenuItem item) {
> > >                 Uri target = Uri.parse("content://media/external/
> > > image

[android-developers] Re: How to implement android's Gallery fling action in my own widget

2009-03-12 Thread Streets Of Boston

Take a look at the GestureDetector class.

- Create an instance of GestureDetector.
- Handle the onTouch event of your activity.
  In your onTouch event handler, forward the MotionEvent to this
GestureDetector instance.
- Assign a listener to this GestureDetector (one that implements
onFling, amongst others)
  Implement the onFling method in your listener to handle flings.

On Mar 12, 1:27 pm, Meryl Silverburgh 
wrote:
> Hi,
>
> Can you please tell me how implement android's Gallery fling action
> (with the animation) in my own widget?
>
> 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 port AbsoluteLayout to FrameLayout?

2009-03-12 Thread Streets Of Boston

Where did you read it became obsolete.
I just checked the reference docs and it's not been obsoleted/
deprecated.

On Mar 12, 7:34 pm, Meryl Silverburgh 
wrote:
> Hi,
>
> AbsoluteLayout has become obsolete, I need to convert it to FrameLayout.
>
> My problem is in AbsoluteLayout.LayoutParams, I can specify (x,y) in
> the constructor, which specify the location of my view during layout.
> How can I achieve using  FrameLayout + FrameLayout.LayoutParams?
>
> 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] RemoteCallbackList.getBroadcastItem(int) sometimes returns null

2009-03-12 Thread Streets Of Boston

Hi,

I found out that RemoteCallbackList.getBroadcastItem(int) sometimes
returns null.  I have this code in my Service and it raises a null-
pointer exception:

...
// instance variable of my Service
final RemoteCallbackList mCallbacks
= new RemoteCallbackList();


...
...
public boolean sendProgressCallback(String imgUri, int albumId, int
progressBytes, int progressPercent) {
final QueuedImageUpload qiu = getUploadingImage(imgUri, albumId);
if (qiu == null)
return true;

qiu.setSizeUploaded(progressBytes);

final int totalSizePercent = mQueues.calculateRemainingSizePercent();
final int N = mCallbacks.beginBroadcast();
try {
for (int i = 0; i < N; i++) {
try {
if 
(!mCallbacks.getBroadcastItem(i).progressChanged(qiu.getID(),
imgUri, albumId, progressPercent, totalSizePercent)) {
return false;
}
} catch (RemoteException e) {
// The RemoteCallbackList will take care of 
removing
// the dead object for us.
}
}
}
finally {
mCallbacks.finishBroadcast();
}
return true;
}

This line is the one throwing a nullpointer exception:
"if (!mCallbacks.getBroadcastItem(i).progressChanged(qiu.getID(),
imgUri, albumId, progressPercent, totalSizePercent))"

- The mCallbacks is never null. It is declared as final.
- The local 'qui' stack-variable is never null. It is guarded by a
null-pointer check.

That only leads me to conclude that the call getBroadcastItem(i)
returns null. However, the documentation states that this method never
returns null. Is this a bug in Android?

This problem only happens on occasion (I can not reproduce it
consistently), but it happens often enough to be of concern for my
app.

BTW, someone else reported the same problem a while ago:

http://groups.google.com/group/android-developers/browse_thread/thread/804e27f717d4296d/7aa863a31c220b44?show_docid=7aa863a31c220b44&fwc=1

Thank you.
-- Anton Spaans
http://soft.antonspaans.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: Menu option starts Thread - menu hangs.

2009-03-12 Thread Streets Of Boston

I'm assuming that gameThread is something that has its own thread and
runs the game. And the main thread (on which onOptionsItemSelected is
running) is seperate and handles the user-interface.

If so, the it may be that createShapes() is pretty expensive and takes
a while. This'll hang the menu-option item until it's done and ready.

You could startup the game thread in yet another thread.
This other thread could be your gameThread. But i don't know its
interface and whether it has something that does except jobs/tasks,
e.g. gameThread.submitTask(new Runnable() {  public void run()
{ dosomething } }); Let's assume that it doesn't and this submitTask
on gameThread does not exist.

Then you have to create another thread to do this. I would use the
java.util.concurrent package for this:

in your activity you declare an instance variable:
  private ExecutorService mGameStarter;

in your onCreate of your activity:
  mGameStarter = Executors.newSingleThreadExecutor();

in your onDestroy:
  mGameStarter.shutdownNow();

And in your onOptionsItemSelected, inside your case START_GAME
  mGameStarter.submit(new Runnable() {
public void run() {
  gameThread.doStart();
}
  });


Every time you call submit() the new thread (hed by mGameStarter) will
wake up and execute the Runnable you specified when calling submit().
When the Runnable ends, this thread will sleep until you submit yet
another task.

On Mar 12, 9:48 pm, Ikon  wrote:
> Streets,
>
> Here is the snippet where I do the menuHandling:
>
>     @Override
>     public boolean onOptionsItemSelected(MenuItem item) {
>
>         switch( item.getItemId()){
>         case START_GAME:
>                 gameThread.doStart();
>                 return true;
>         case STOP_GAME:
>                 gameThread.setState(gameThread.STATE_LOSE);
>             return true;
>         case PAUSE_GAME:
>                 gameThread.pause();
>             return true;
>         case RESUME_GAME:
>                 gameThread.unpause();
>             return true;
>         }
>
>         return super.onOptionsItemSelected(item);
>     }
>
> Here is my doStart method:
>
>     public void doStart() {
>         synchronized (mSurfaceHolder) {
>
>                 createShapes(mContext);
>                 shape[0].visible = true;
>                 score = 0;
>
>             mLastTime = System.currentTimeMillis() + 100;
>             setState(STATE_RUNNING);
>         }
>     }
>
> Thanks,
> Ayan
>
> On Mar 12, 10:28 am, Streets Of Boston 
> wrote:
>
>
>
> > Could you provide a code-snippet showing how you coded themenu-
> > handling and the starting of yourthread?
>
> > On Mar 12, 10:00 am, Ikon  wrote:
>
> > > Hi,
>
> > > I am developing a game based on the SurfaceView/LunarLander example in
> > > the sample code.
> > > I have one activity, with onemenuoption that is "new game".
>
> > > My activity listens for themenuselection, and once new game is
> > > selected, doStart of the Gamethreadis called.  The game starts up
> > > after 3-4 seconds, but themenuoption sticks around on the screen
> > > until the game has started.  I think the mainthreadis waiting on the
> > > doStart to do its thing, but since it's creating a newthread, how do
> > > I get it to just start thethreadand continue its business of hiding
> > > themenuoption right away, instead of after 3 seconds?
>
> > > Thanks,
> > > Ayan- 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 transfer an action(ex:key press) from an Activity to other Activities

2009-03-12 Thread Streets Of Boston

You could figure how to start the original dialer's activity
(startActivity(Intent)) providing the correct Intent... I'm not sure
how to do that, which action/category/extra-data/etc. to set to make
this happen. Maybe someone else can help you with that.

On Mar 12, 10:38 pm, Anh Khoa Nguyen Pham  wrote:
> Thanks for your replies,
>
> Actually, my application will run when incoming call is detected. Because i
> do not know how to integrate my application into original dialer so i must
> implement my application as a separate application. So when users press
> Green Key, i want my application to exit and transfer this EVENT to original
> dialer. Do you have any idea to solve my problem?
>
> On Fri, Mar 13, 2009 at 2:12 AM, Streets Of Boston
> wrote:
>
>
>
>
>
> > First you should figure out what you really try to accomplish. I don't
> > know the details of your app, but i guess that your goal is not to
> > push a button. The goal is the action that occurs when the button is
> > pushed.
>
> > I would just call the action (method/java-code/etc) directly that
> > would have been called by the button-click of the other activity.
>
> > On Mar 12, 7:31 am, "npak...@gmail.com"  wrote:
> > > Hi all,
> > > When my application is running, a button is pressed.After my
> > > application processes this event, i want to continue to transfer this
> > > event to other applications. Is it possible? If yes, how to do that?
> > > I very appreciate your advices,
> > > Thanks,
> > > NPAK- 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: RemoteCallbackList.getBroadcastItem(int) sometimes returns null

2009-03-12 Thread Streets Of Boston

m you mean that the value of 'N 'could be larger than the
actual elements accessed by getBroadcastItem(i), i.e. HashMap changes
while looping over the 'N' items...?

For now, i'm check for null and just ignore it. The problem is that it
is very hard to reproduce. It happens on rare occasions, but often
enough to be problematic.

This line has only 3 points in which it could throw a null-pointer
exception (the stack-trace reports the NPE on this line, not inside
progressChanged(...)):
- mCallbacks is null: Not possible. It is declared final and refers to
an instance.
- qiu is null: Not possible. It is a stack-variable and it has been
guarded against null value.
- getBroadcastItem(i): The only one left...

I thought that beginBroadcast() would lock the callback-list for
modification and finishBroadcast() would unlock it again. This way, N
should always be the number of items in this HashMap you were
mentioning. Am i correct in this.

I'll let you know if i can figure out which values for 'i' are
problematic :-)

Thanks for your help.

On Mar 12, 9:27 pm, Dianne Hackborn  wrote:
> Hm actually could you see if it is the -last- ones that are null?  The code
> that makes the list gets a count from the HashMap, and then iterates through
> its values and puts them in the array, and returns the original count.  So
> if that count is different than the number it iterated over, that could be a
> problem.  I'll change it to return the actual number it iterated over, but
> in theory these shouldn't be different.
>
> On Thu, Mar 12, 2009 at 6:25 PM, Dianne Hackborn wrote:
>
>
>
>
>
> > The callbacks are just stored in a HashMap, and the entries there are never
> > set null (actually that field is final), so I don't really see how that can
> > happen.  Are you sure you aren't potentially doing this loop from different
> > threads without doing your own synchronization?
>
> > On Thu, Mar 12, 2009 at 6:07 PM, Streets Of Boston <
> > flyingdutc...@gmail.com> wrote:
>
> >> Hi,
>
> >> I found out that RemoteCallbackList.getBroadcastItem(int) sometimes
> >> returns null.  I have this code in my Service and it raises a null-
> >> pointer exception:
>
> >> ...
> >>    // instance variable of my Service
> >>    final RemoteCallbackList mCallbacks
> >>            = new RemoteCallbackList();
>
> >> ...
> >> ...
> >> public boolean sendProgressCallback(String imgUri, int albumId, int
> >> progressBytes, int progressPercent) {
> >>        final QueuedImageUpload qiu = getUploadingImage(imgUri, albumId);
> >>        if (qiu == null)
> >>            return true;
>
> >>        qiu.setSizeUploaded(progressBytes);
>
> >>        final int totalSizePercent =
> >> mQueues.calculateRemainingSizePercent();
> >>        final int N = mCallbacks.beginBroadcast();
> >>        try {
> >>                for (int i = 0; i < N; i++) {
> >>                        try {
> >>                                if
> >> (!mCallbacks.getBroadcastItem(i).progressChanged(qiu.getID(),
> >> imgUri, albumId, progressPercent, totalSizePercent)) {
> >>                                        return false;
> >>                                }
> >>                        } catch (RemoteException e) {
> >>                                // The RemoteCallbackList will take care of
> >> removing
> >>                                // the dead object for us.
> >>                        }
> >>                }
> >>        }
> >>        finally {
> >>                mCallbacks.finishBroadcast();
> >>        }
> >>        return true;
> >> }
>
> >> This line is the one throwing a nullpointer exception:
> >> "if (!mCallbacks.getBroadcastItem(i).progressChanged(qiu.getID(),
> >> imgUri, albumId, progressPercent, totalSizePercent))"
>
> >> - The mCallbacks is never null. It is declared as final.
> >> - The local 'qui' stack-variable is never null. It is guarded by a
> >> null-pointer check.
>
> >> That only leads me to conclude that the call getBroadcastItem(i)
> >> returns null. However, the documentation states that this method never
> >> returns null. Is this a bug in Android?
>
> >> This problem only happens on occasion (I can not reproduce it
> >> consistently), but it happens often enough to be of concern for my
> >> app.
>
> >> BTW, someone else reported the same problem a while ago:
>
> >>h

[android-developers] Re: RemoteCallbackList.getBroadcastItem(int) sometimes returns null

2009-03-13 Thread Streets Of Boston

Ah, thanks.

Either way, it means that the number of items in the list accessed by
getBroadcastItem is always equal to N.
The problem remains: How can getBroadcastItem(int) return null?

On Mar 13, 4:53 am, Dianne Hackborn  wrote:
> On Thu, Mar 12, 2009 at 8:08 PM, Streets Of Boston
> wrote:
>
> > I thought that beginBroadcast() would lock the callback-list for
> > modification and finishBroadcast() would unlock it again. This way, N
> > should always be the number of items in this HashMap you were
> > mentioning. Am i correct in this.
>
> No, it only locks internally in beginBroadcast() to create the list.  If you
> may have multiple threads calling beginBroadcast(), they need to do their
> own synchronization, holding your own lock from before calling
> beginBroadcast() to after finishBroadcast().
>
> --
> 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.  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: How to port AbsoluteLayout to FrameLayout?

2009-03-13 Thread Streets Of Boston

I'm using the AbsoluteLayout in one of my apps and it can be useful.
However, i think it'll be deprecated because the AbsoluteLayout is
device(/screen) dependent. E.g., if a new phone comes out with a
square screen instead of 320x480, your app starts to look funny. You
can mitigate this somewhat by using 'dp' units, for example, instead
of using 'px' units.

Although, all other measures (e.g. widths of views) can still be
expressed in pixels, which is device dependent as well.

So, why will AbsoluteLayout become deprecated and not the measures
expressed in pixels?

On Mar 13, 11:15 am, Edward  Falk  wrote:
> On Mar 12, 5:03 pm, Romain Guy  wrote:
>
> > AbsoluteLayout is deprecated in Cupcake.
>
> Why?  And what do we use in its place?
--~--~-~--~~~---~--~~
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: service start and ui hanging

2009-03-13 Thread Streets Of Boston

Hi Bob,

Your code snippet is not enough to give you some more info.
E.g. how does backgroundRefresh2 looks like (it public void run()
implementation).

Based on its name 'backgroundRefresh2': does it access View-s and
modify these view (e.g. update text-view, images, etc.)?
If so, that may explain your crash. You should not access any View (or
subclass of View) in any other thread than your main message-
dispatching thread (i.e. the thread on which your onCreate/onDestroy/
onPause/onResume/on is called).


On Mar 13, 11:05 am, Bob  wrote:
> Hi,
> I have moved some intensive processing from my main thread to a
> service.  My UI is hanging and then crashing when I start the service,
> even if I put the service start in a new thread started via
>
>  Thread updateThread = new Thread(null, backgroundRefresh2,
> "new_thread");
>                   updateThread.start();
>
> What am I doing wrong?  Also, it seems like the cause of the eventual
> crash in the service/worker thread doesn't show up in LogCat.
>
> Thanks,
> Bob
--~--~-~--~~~---~--~~
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: RemoteCallbackList.getBroadcastItem(int) sometimes returns null

2009-03-13 Thread Streets Of Boston

Ah, now i get it! :-)

Indeed, sendProgressCallback can be called from multiple threads. And
with your earlier explanation that the beginBroadcast does not do
locking (only a brief internal lock), it may explain the problem. In
other words, RemoteCallbackList is not thread-safe across multiple
calls to it.

I should put the broadcast code inside a 'synchronized(mCallbacks)
{ ... }' block or surround it with a ReentrantLock.
Or create mCallbacks instances for each possible thread and have my
listeners register with each of them.

Thank you very much for your help.
Have a great weekend!

On Mar 13, 12:58 pm, Dianne Hackborn  wrote:
> On Fri, Mar 13, 2009 at 7:27 AM, Streets Of Boston
> wrote:
>
> > Either way, it means that the number of items in the list accessed by
> > getBroadcastItem is always equal to N.
> > The problem remains: How can getBroadcastItem(int) return null?
>
> I'm not sure what you mean by "either way" -- if you are doing this from
> multiple threads, your threads can clobber the list, which can lead to this
> kind of problem.
>
> --
> 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.  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: RemoteCallbackList.getBroadcastItem(int) sometimes returns null

2009-03-13 Thread Streets Of Boston

Alas, this one is not a one-way interface. It expects a boolean back:
False = cancel upload of image, True = continue uploading image. It
allows the (remote) client to cancel uploads forcefully. Luckily, the
client receiving the call-back can return this answer really fast.

The client is not the same process. It is a different app (Activity)
in a different process.

What is your opinion, in terms of speed/performance: One 'mCallbacks'
instance for the Service, sending this callback to its clients, inside
a synchronized(...) block or having each a 'mCallbacks' for each
thread (max 3)? Which one would be better?
The client is always remote (other process).

Thanks!
On Mar 13, 2:29 pm, Dianne Hackborn  wrote:
> If your callbacks are oneway, the easiest thing to do is put it all in a big
> synchronized() block.  Be aware though that if the callback is into the
> local process, it will still be synchronous, so holding a lock while doing
> this can be a problem.
>
> Usually the safest thing is to have a handler that you post a message to,
> which does the callbacks.  Then you don't need any locking since the
> broadcasts are serialized by the handler.
>
> On Fri, Mar 13, 2009 at 10:55 AM, Streets Of Boston 
>
>
>
>
> > wrote:
>
> > Ah, now i get it! :-)
>
> > Indeed, sendProgressCallback can be called from multiple threads. And
> > with your earlier explanation that the beginBroadcast does not do
> > locking (only a brief internal lock), it may explain the problem. In
> > other words, RemoteCallbackList is not thread-safe across multiple
> > calls to it.
>
> > I should put the broadcast code inside a 'synchronized(mCallbacks)
> > { ... }' block or surround it with a ReentrantLock.
> > Or create mCallbacks instances for each possible thread and have my
> > listeners register with each of them.
>
> > Thank you very much for your help.
> > Have a great weekend!
>
> > On Mar 13, 12:58 pm, Dianne Hackborn  wrote:
> > > On Fri, Mar 13, 2009 at 7:27 AM, Streets Of Boston
> > > wrote:
>
> > > > Either way, it means that the number of items in the list accessed by
> > > > getBroadcastItem is always equal to N.
> > > > The problem remains: How can getBroadcastItem(int) return null?
>
> > > I'm not sure what you mean by "either way" -- if you are doing this from
> > > multiple threads, your threads can clobber the list, which can lead to
> > this
> > > kind of problem.
>
> > > --
> > > 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.  All such questions should be posted on public
> > > forums, where I and others can see and answer them.
>
> --
> 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.  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: Development Platform Compatibility

2009-03-16 Thread Streets Of Boston

I'm developing on my Vista 64 with Eclipse and all works very well.
(I have the unsigned 64 bit USB driver, with Vista 64 running in
'test' mode)

On Mar 16, 4:02 am, Al Sutton  wrote:
> I'd go for XP64 personally.
>
> No matter what I do I can't get the G1 recognised by adb on 32 bit
> Vista, but I don't know if the same problem will happen on 64 bit vista,
> but I wouldn't take the chance.
>
> Al.
>
>
>
> Ralf wrote:
> > I think the SDK and the Eclipse tools will work reasonably well with
> > an XP or Vista 64 bit now. The latest SDK has the USB driver in 64
> > bit. However at that point Vista 7 is totally unsupported (i.e. not
> > tested at all) and I would not recommend it.
>
> > R/
>
> > On Sat, Mar 14, 2009 at 11:05 PM, javame.developer
> >  wrote:
>
> >> Hi,
> >> I am getting a new OS, which OS is Android SDK/IDE development
> >> environment compatible with XP64, Vista64 or Windows7? Or Do I need to
> >> keep a XP32 partition around?- 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: Paid applications and market feedback/rating

2009-03-16 Thread Streets Of Boston

I'm not absolutely sure, but i'm pretty sure this is possible. It'll a
different application with its own set of comments and ratings.

In one way it makes sense. When people pay for an application, their
ratings may be different than for a free version of it. When people
pay, they may have a different level of expectations.

Make sure in your apps description that there is a free version of
your app. People may go take a look at it and see its ratings and,
hopefully, relate these ratings to your paid version.

On Mar 16, 11:02 am, Keith Wiley  wrote:
> I have had a free version of my app available for several months.
> With the new features I am about to release in the latest version, and
> with paid apps now possible, I intend to split the app into a free
> lite/trial version and a paid full version.  I am aware that I must
> create a new app with a new signature for the full version b/c I can't
> change the current free app to a paid one.  I don't mind this, but, is
> there any way I can transfer the thousands of feedback and ratings I
> have accumulated so far to the paid version even though it will have a
> totally new signature?
>
> If there is no way to do this then, permit me to say, I am a little
> miffed.  :-/
>
> ...but I'm holding out hope that I missed this somewhere, that's it's
> possible.  Am I right?  I'm sorry if I missed the explanation for how
> to do this.
>
> Thank you very much.
>
> Cheers!
--~--~-~--~~~---~--~~
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: Paid applications and market feedback/rating

2009-03-16 Thread Streets Of Boston

I had a typo in my previous message:

Change this

   "... but i'm pretty sure this is possible ... "

to this
   "... but i'm pretty sure this is NOT possible ... "

On Mar 16, 11:33 am, Streets Of Boston 
wrote:
> I'm not absolutely sure, but i'm pretty sure this is possible. It'll a
> different application with its own set of comments and ratings.
>
> In one way it makes sense. When people pay for an application, their
> ratings may be different than for a free version of it. When people
> pay, they may have a different level of expectations.
>
> Make sure in your apps description that there is a free version of
> your app. People may go take a look at it and see its ratings and,
> hopefully, relate these ratings to your paid version.
>
> On Mar 16, 11:02 am, Keith Wiley  wrote:
>
>
>
> > I have had a free version of my app available for several months.
> > With the new features I am about to release in the latest version, and
> > with paid apps now possible, I intend to split the app into a free
> > lite/trial version and a paid full version.  I am aware that I must
> > create a new app with a new signature for the full version b/c I can't
> > change the current free app to a paid one.  I don't mind this, but, is
> > there any way I can transfer the thousands of feedback and ratings I
> > have accumulated so far to the paid version even though it will have a
> > totally new signature?
>
> > If there is no way to do this then, permit me to say, I am a little
> > miffed.  :-/
>
> > ...but I'm holding out hope that I missed this somewhere, that's it's
> > possible.  Am I right?  I'm sorry if I missed the explanation for how
> > to do this.
>
> > Thank you very much.
>
> > Cheers!- 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: ContentProvider not backed by SQLLite?

2009-03-16 Thread Streets Of Boston

I wrote one that goes out to the internet and fetches data.

In my code, I use the 'String[] projections' to create my own Cursor
implementation. I make a subclass of 'Cursor', an instance of which
will be returned by my ContentProvider's query method. The constructor
of this Cursor-subclass takes the 'projections' as an input parameter
and the subclass uses it to correctly implement the method
'getColumnIndex(String columnName)'.

I don't know about MatrixCursor, though. I can't help you there :)

If 'projections' is null, I simply pass a String-array to this
constructor holding all possible column-names for my ContentProvider.
On Mar 16, 1:45 pm, Ray Bellis  wrote:
> Has anyone got an example of how to write a ContentProvider that gets
> its data from somewhere other than a SQLLite database?
>
> Mine is half working, in so much as I can retrieve the requested data
> and apparently populate a MatrixCursor, but I can't figure out what
> I'm supposed to do with the 'projections' parameter supplied to the
> 'query()' method.
>
> thanks,
>
> Ray
--~--~-~--~~~---~--~~
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 ImageView and performance

2009-03-17 Thread Streets Of Boston

I had similar issues. I managed to fix the performance of the list-
view, but i ran into memory issues.

My app downloads images from Smugmug, images that are 'front-page'
images of galleries/albums.
First, my app needed to get the information about the album, to get
the image-id of the album's front-page image. This would result in a
URL and then my app downloads the image using this URL and then shows
it in a list-item.

I used the ExecutorService to fetch the necessary album information
and image-retrieval and image decoding in a limited number of
background threads.

In the list-adpater's getView method, i would tag (setTag) the list-
item view with the album-id and submit a new (cancelable) task using
the ExecutorService (java.util.concurrent packages). This task
downloads the album info and then downloads the image. While the album
information and the image were downloading, i showed a place-holder
picture in my list-item's imageview (a bitmap from the res/drawable
directory)

When the task that has been submitted finishes, it posts the result
back to the main-thread: Loop over the current list-view children
(which are the visible list-items). For each child get its tag
(getTag) and if this tag matched the task-result, i would set the
child's imageview's bitmap to the image i just downloaded.

This all worked quite well, with images downloading at their own pace
and the list-view kept performing well.
However, at some point i got memory errors when calling
ImageView.setImageBitmap(Bitmap). I checked my code. I made sure to
recycle not-used bitmaps, i did not cache bimtaps, etc., but i kept
getting memory errors (note that the smugmug images downloaded were
small: 100x100 pixels).

I was not able to solve these memory errors and i abandoned this idea.
Any ideas to prevent these memory errors? :-)

On Mar 17, 7:28 am, ifuller1  wrote:
> Thanks gesh - as suggested the problem was related to recycling.
> Preformance is pretty good now, sadly my images keep shuffling but
> given your recent input this should be easy to fix.
>
> On Mar 15, 10:03 pm, Gesh  wrote:
>
>
>
> > > I'm currently using the ImageAdapter from the Hello GridView sample.
> > > But loading the images from the web rather than using resources.
>
> > I think you need a better understanding of how adapters work to solve
> > your problem. The getView() method of your Adapter is inkoved every
> > time an image in your grid becomes visible (yes, including when you
> > scroll back and forth to previously visible images). So if you have
> > just replaced that one line image.setImageResource(int) with
> > image.setImageDrawable(Drawable.createFromStream()) it means you are
> > re-downloading images every time they get scrolled into view.
>
> > So you need to cache those downloaded images and while you are at it
> > make sure you cache scaled thumbnail of the image, just as big as you
> > need them to avoid the possible problem Romain suggested. Use
> > Bitmap.createScaledBitmap() - it's worked great for me.
>
> > Also be aware that the emulator is running on your PC using that same
> > network speed. If you want to test for real network problems you might
> > get on a real device try starting the emulator with limited network
> > (or on your G1 disable wireless and 3G). I alwasy run my emulator with
> > network speed and latency set to EDGE, or for some debugging purposes
> > even GPRS or GSM.
>
> > hope that helps you,
> > gesh.
>
> > On Mar 15, 7:22 am, ifuller1  wrote:
>
> > > Hi Gesh,
>
> > > Thanks for the response. I'll certainly give the bitmap factory a go.
> > > I'm currently using the ImageAdapter from the Hello GridView sample.
> > > But loading the images from the web rather than using resources. The
> > > problem is immediate, in that the performance doesn't degrade after re-
> > > visits to the activity, but is instead directly proportional to the
> > > number of images I'm displaying.
>
> > > As well as trying the bitmap factory can I ask what you think is the
> > > best way to encourage garbage collection? Will nulling my objects be a
> > > big help.
>
> > > Once I have it optimized I'm going to release it for free... I think
> > > there's a big hole in androids picasa support.
>
> > > Ian
>
> > > On Mar 14, 11:38 pm, Gesh  wrote:
>
> > > > hi,
>
> > > > I have written 2 connected apps with some image content pulled from
> > > > the web and must say if you handle your resources right it shouldn't
> > > > be a problem at all.
>
> > > > Do you use your own Adapter for theGridViewor do you use some of the
> > > > already available ones in the SDK? If you use your own you should keep
> > > > in mind that when you deal with AdapterViews in general they keep
> > > > references to Views you create in your adapter and recycle them, so
> > > > try to reuse the convertView reference you get in the Adapter.getView
> > > > (int position, View convertView, ViewGroup parent) method.
>
> > > > And although memory leaks are difficult to achieve 

[android-developers] Re: how to take small picture

2009-03-18 Thread Streets Of Boston

Take a look at the Bitmap and BitmapFactory classes in the Android SDK

On Mar 18, 1:52 pm, cindy  wrote:
> Hi,
>
> Is there anyway to reduce the resolution of picture taken using
> camera? It takes long time to upload the image to server. Does anyone
> use any compression software for image ?
>
> Thanks!
>
> Cindy
--~--~-~--~~~---~--~~
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 detect Fling action in my widget

2009-03-18 Thread Streets Of Boston

Make sure you return the correct boolean-values in the other methods
of your OnGestureDetector (onDown, onScroll, etc).

On Mar 18, 2:51 pm, Meryl Silverburgh 
wrote:
> Hi,
>
> Can you please tell me how can I detect Fling action in my own widget?
> I have implemented my widget as OnGestureListener.
>
> And like in Gallery, I have a
> "GestureDetector mGestureDetector = new GestureDetector(this);"
>
> For my onTouchEvent(), I have
> @Override
>     public boolean onTouchEvent(MotionEvent event) {
>
>         // Give everything to the gesture detector
>         boolean retValue = mGestureDetector.onTouchEvent(event);
>         return retValue;
>     }
>
> But my  public boolean onFling(MotionEvent e1, MotionEvent e2, float
> velocityX, float velocityY) is never get claeed.
>
> CAn you please tell me why?
>
> 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: Scheduling a repeating task and being notified

2009-03-19 Thread Streets Of Boston

I did something similar, however, i did not use a BroadcastReceiver to
get callbacks back from the service.
Instead i used the RemoteCallbackList class:

  http://developer.android.com/reference/android/os/RemoteCallbackList.html

No fiddling with intents and such. Just define a callback interface
and bind to it in your client and call it in your service and you're
done.

It works like a breeze :-)

On Mar 16, 6:16 am, BoD  wrote:
> Replying myself, for future reference.
> For the scheduling part I used AlarmManager and a Service as mentioned
> before.
> For the "notification back" part I ended up using sendBroadcast from
> the service and a BroadcastReceiver on my Activity (registering/
> unregistering it in onResume/onPause). It works fine.
>
> BoD
>
> On Mar 15, 7:22 pm, BoD  wrote:
>
>
>
> > Hi!
>
> > I'm trying to find the "correct" way to do the following:
>
> > . I have an activity with a button that starts a repeating task in the
> > background. That is, if the user goes away from my activity, I want my
> > task to still be scheduled and executed every x minutes.
>
> > . I want a status TextView to be displayed on the activity, and if the
> > task happens to start executing while my activity is showing, the
> > TextView should be updated so the user can be aware of what's going
> > on.
>
> > So basically, is there a way to start a scheduled background repeating
> > task and be notified when it is executed?
>
> > From what I saw in the sample applications, I understand I'm supposed
> > to use AlarmManager and a Service but I'm not sure about the
> > notification part.
>
> > Thanks a lot for your help.
>
> > BoD- 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] Problem launching my own (camera) application on press of Camera-button

2009-03-19 Thread Streets Of Boston

When i press the phone's camera button, both my application and the
system's camera application are launched:
- I press camera button
- After a few seconds, my camera app appears and all looks good.
- However, when i go back (back-button), i'm not brought back to where
i was before.
  Instead, i'm brought (back) to the system's camera application.

It looks like both camera apps are launched: The system's camera app
is launched and on top of that my camera app is launched.

I expected the activity-chooser to appear asking which camera app i'd
like to start (with an option of making one the default).

Here are some code snippets:
Manifest:

















CameraReceiver.java:
public void onReceive(Context context, Intent intent) {
KeyEvent event = (KeyEvent) intent.getParcelableExtra
(Intent.EXTRA_KEY_EVENT);

if (event == null) {
return;
}

Intent i = new Intent(Intent.ACTION_MAIN);
i.setClass(context, SmugCamera.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}

Do i have to change the onReceive method to use Intent.createChooser
(...) instead?
Or is there some other problem i'm not aware of?

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 do I draw on canvas instantly?

2009-03-19 Thread Streets Of Boston

Use a different Thread that draws on the SurfaceView directly. You can
draw as fast and as immediate as your Thread allows.

http://developer.android.com/reference/android/view/SurfaceView.html

- Get the SurfaceHolder of the SurfaceView.
- Every time you want to draw, begin by calling the SurfaceHolder's
lockCanvas.
-   This will give you a Canvas to draw on directly.
-   End this by calling unlockCanvasAndPost

You should be able to find some examples when you google
SurfaceHolder. Here is one such result:
http://www.anddev.org/2d_tutorial-t3120.html

On Mar 19, 5:31 pm, mcmc  wrote:
> Hello,
>
> I'm trying to use java and android's 2D drawing APIs (no openGL) to
> draw to a canvas instantly.
>
> Right now, I am using the SurfaceView class (surfaceCreated,
> surfaceChanged, and surfaceDestroyed functions) to draw to a canvas,
> but it does not get called at the time I want it to.
>
> I understand that SurfaceChanged is called "immediately after any
> structural changes (format or size) have been made to the surface." If
> this is the case, how would I explicitly change the size or format of
> the surface to call SurfaceChanged instantly?
>
> If there is a better method to draw to a canvas instantly, such as not
> using the SurfaceView class (surfaceCreated, surfaceChanged, and
> surfaceDestroyed functions) or View class (onDraw function) entirely,
> that would be ideal.
>
> Can anyone help? this is urgent... and I've been stuck here for a very
> long time! :(
>
> 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: Problem launching my own (camera) application on press of Camera-button

2009-03-20 Thread Streets Of Boston

Thanks!
I'll give that a try.

On Mar 19, 7:12 pm, Marco Nelissen  wrote:
> Try calling abortBroadcast() in your receiver.
>
> On Thu, Mar 19, 2009 at 7:18 AM, Streets Of Boston
>
>
>
>  wrote:
>
> > When i press the phone's camera button, both my application and the
> > system's camera application are launched:
> > - I press camera button
> > - After a few seconds, my camera app appears and all looks good.
> > - However, when i go back (back-button), i'm not brought back to where
> > i was before.
> >  Instead, i'm brought (back) to the system's camera application.
>
> > It looks like both camera apps are launched: The system's camera app
> > is launched and on top of that my camera app is launched.
>
> > I expected the activity-chooser to appear asking which camera app i'd
> > like to start (with an option of making one the default).
>
> > Here are some code snippets:
> > Manifest:
> >        
> >            
> >                 > android:name="android.intent.action.CAMERA_BUTTON"/>
> >            
> >        
> >         >                android:label="@string/app_name"
> >                android:screenOrientation="landscape" 
> > android:icon="@drawable/
> > camera"
> >            android:clearTaskOnLaunch="true"
> >            android:taskAffinity="smugdroid.task.camera">
> >            
> >                
> >                 > android:name="android.intent.category.DEFAULT" />
> >                 > android:name="android.intent.category.LAUNCHER" />
> >            
> >        
> >                
> >                
> >        
> >        
>
> > CameraReceiver.java:
> > public void onReceive(Context context, Intent intent) {
> >        KeyEvent event = (KeyEvent) intent.getParcelableExtra
> > (Intent.EXTRA_KEY_EVENT);
>
> >        if (event == null) {
> >            return;
> >        }
>
> >        Intent i = new Intent(Intent.ACTION_MAIN);
> >        i.setClass(context, SmugCamera.class);
> >        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> >        context.startActivity(i);
> > }
>
> > Do i have to change the onReceive method to use Intent.createChooser
> > (...) instead?
> > Or is there some other problem i'm not aware of?
>
> > Thank you.- 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: Help with dialog builder and resource problem please

2009-03-20 Thread Streets Of Boston

If i understand various messages i've read on this board correctly,
you can not bundle Android resources in a shared library.
You can only bundle share classes (and regular java-resources, i hope)
in JARs.

I was trying to do the same, sharing layouts, bitmaps, etc among a
suite of applications. It did not work, because Android resources can
not be shared from a jar to an apk.

Any Android engineer; correct me if i'm wrong (i hope i am :=)).

On Mar 20, 11:31 am, madcoder  wrote:
> I'm trying to build an alert dialog with a builder.  The code is from
> the svn here:
>
> http://code.google.com/p/apps-for-android/source/browse/trunk/DivideA...
>
> There is also a web site with description of how to use the code 
> here:http://androiddevstudio.com/tutorials/adding-eula-to-android-app/comm...
>
> So far the class successfully runs this code:
>
> ...previous code
> builder.setPositiveButton(com.mywebsite.MyLib.R.string.eula_accept,
> new DialogInterface.OnClickListener() {
>                 public void onClick(DialogInterface dialog, int which)
> {
>                     accept(preferences);
>                     if (activity instanceof OnEulaAgreedTo) {
>                         ((OnEulaAgreedTo) activity).onEulaAgreedTo();
>                     }
>                 }
>             });
>
> Then I try to run this code immediately after it:
>
> builder.setNegativeButton(com.mywebsite.MyLib.R.string.eula_refuse,
> new DialogInterface.OnClickListener() {
>                 public void onClick(DialogInterface dialog, int which)
> {
>                     refuse(activity);
>                 }
>             });
>
> And then I get Force Close.  I've placed several log messages in my
> code for debug and I'm fairly certain this is where it hangs up.
>
> The DDMS indicates:
>
> W  535  ResourceType  getEntry failing because entryIndex 3 is beyond
> type entryCount 3
> W  535  ResourceType  Failure getting entry for 0x7f040003 ( t=3 e=3 )
> in package 0: 0x8001
>
> I have commented out this single builder.setNegativeButton code and
> the file runs with no force closure.  I'm also absolutely sure that
> both string resources are in the strings.xml file.
>
> You may notice my string designation:
>
> com.mywebsite.MyLib.R.string.eula_accept
>
> This is because I'm trying to access this eula from a reusable library
> class.  This is where is gets a little weird.  The title in the dialog
> displays this:
>
> "res/raw/button_click.ogg"
>
> And the accept button at the bottom of the dialog displays this text:
>
> "res/raw/instructions.ogg"
>
> Those files are both from the main project itself, in another package,
> hence the use of long definitions for the string files.  Unfortunately
> it still doesn't access those strings.
>
> I would like to know how to do this correctly, so I can reuse this
> library class.  And more importantly, so I can understand what I'm
> doing wrong.
>
> I'm using Eclipse and the latest SDK of Android.
>
> 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: Retreivng data from internet source.

2009-03-21 Thread Streets Of Boston

Your use of HttpGet is good.
However, you cast an InputStream to a char-sequence when calling
tv.setText((CharSequence)input);.
This will give you a class-cast exception. Read char-data from the
InputStream instead.

Also, try to find out if 'entity' has some methods to get a String
back that has the content of the HttpResponse. Then you can skip
handling the InputStream and reading a string from it.


Also, did you give your app internet-permission?

On Mar 21, 5:10 pm, murphy  wrote:
> Hi all, I am having difficulty retrieving data from the internet to be
> displayed in a TextView. When I run the application it says the
> application has stopped unexpectedly. I am using the code:
>
> String urls = "http://www.indulec.ie/weather.txt";;
>
>             HttpClient client = new DefaultHttpClient();
>
>             // Create a method instance.
>             HttpGet method = new HttpGet(urls);
>             method.getParams().setIntParameter
> (CoreConnectionPNames.CONNECTION_TIMEOUT, 1 );
>             method.getParams().setIntParameter
> (CoreConnectionPNames.SO_TIMEOUT, 1 );
>             method.getParams().setIntParameter
> (CoreConnectionPNames.SOCKET_BUFFER_SIZE, 20 );
>             method.getParams().setIntParameter
> (ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, 5 );
>             method.getParams().setIntParameter
> (ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 10 );
>
>             HttpResponse response = null;
>             InputStream input = null;
>
>             try
>             {
>                 response = client.execute( method );
>                 HttpEntity entity = response.getEntity();
>                 input = entity.getContent();
>
>                 TextView tv = (TextView)findViewById(R.id.somenews);
>                 tv.setText((CharSequence) input);
>
>                 setContentView(R.layout.latestnews);
>
>             }
>             catch ( IOException e )
>             {
>                 Log.d("", "Can not connect to the target server!" );
>                 try {
>                                         throw new IOException();
>                                 } catch (IOException e1) {
>                                         // TODO Auto-generated catch block
>                                         e1.printStackTrace();
>                                 }
>             }
>             finally
>             {
>                 Log.d("", "close Expired Connections!" );
>                 client.getConnectionManager().closeExpiredConnections
> ();
>             }
--~--~-~--~~~---~--~~
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: Where is the source code for "Pictures" app

2009-03-22 Thread Streets Of Boston

http://android.git.kernel.org/?p=platform/packages/apps/Camera.git;a=tree;f=src/com/android/camera;h=b59e44fcf7eda59ed76597efe26ac8a25696c798;hb=8250896ab37545f4499da79f54c19af2e5018b80


On Mar 22, 8:24 pm, Yves Liu  wrote:
> Thanks.
>
>
>
> On Sun, Mar 22, 2009 at 4:38 PM, Andrew Stadler  wrote:
>
> > You'll probably get better results asking this question on the
> > android-platform mailing list, as the gallery is part of the platform
> > distribution, and folks on that mailing list are working on apps like
> > that.
>
> > On Sun, Mar 22, 2009 at 4:01 PM, yves...@gmail.com 
> > wrote:
>
> > > I just downloaded Android source code, but I can't find the source
> > > for "Pictures" app. I did see "Calculator" code. Anyone know where I
> > > can find the "Pictures" or why it is not in the source code package?- 
> > > 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: Displaying image from internet source

2009-03-23 Thread Streets Of Boston

We won't know what's going on unless you show us a strack-trace of the
error. :=)
Look at LogCat and copy/paste the strack-trace in this thread.

All i can do now is guess:
How big is your image?
You create two arrays (int[] and byte[]) which are never used. This is
memory waste.
The inputstream 'is' may hold a large image as well.
You may have gotten a out-of-memory error or an error occurring
because you exceeded the allowed bitmap allocation budget.



On Mar 23, 11:49 am, murphy  wrote:
> Hi, I'm trying to display an image using a URL. When I run the code I
> get an error telling me the application has stopped unexpectedly. Can
> anyone see what's wrong in my code.
>
> Bitmap bmImg;
>
>                 URL myFileUrl =null;
>
>                 try {
>
>                         myFileUrl= new 
> URL("http://www.starling-fitness.com/wp-content/
> 240384vBdA_w.jpg");
>                 } catch (MalformedURLException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>                 }
>
>                 try {
>                         URLConnection conn= 
> (URLConnection)myFileUrl.openConnection();
>                         conn.setDoInput(true);
>                         conn.connect();
>
>                         int length = conn.getContentLength();
>                         int[] bitmapData = new int[length];
>                         byte[] bitmapData2 = new byte[length];
>
>                         InputStream is = conn.getInputStream();
>                         bmImg = BitmapFactory.decodeStream(is);
>
>                         /*timetableImage.setImageBitmap(bmImg);*/
>                         setContentView(R.layout.timetable);
>                         ImageView iv = 
> (ImageView)findViewById(R.id.timetableImage);
>                         iv.setImageBitmap(bmImg);
>
>                         } catch (IOException e) {
>                                 // TODO Auto-generated catch block
>                                 e.printStackTrace();
>                 }
--~--~-~--~~~---~--~~
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: Problem in converting byte array in Bitmap.

2009-03-23 Thread Streets Of Boston

Is the byte-array you saved in the database *exactly* the same as the
byte-array returnes by src.getBytes() in your getBitmapFromString
(String) method?

I'd be worried that c.getString() may change the underlying byte-array
to adher to the default UTF-8 encoding.

On Mar 23, 12:10 am, Komal  wrote:
> Somebody please help me,,why decodeByteArray(...) returns null
> Thanxs
> komal
>
> On Mar 20, 11:45 am, Komal  wrote:
>
>
>
> > Hello,
> > I want to store image in sqlite database.
> > I tried to store it using BLOB and String, in both cases it store the
> > image and can retrieve it but when  i convert it to Bitmap using
> > BitmapFactory.decodeByteArray(...) it return null.
> > Below is my code please have a look and suggest me where i m making
> > mistake.
>
> > public class imagesql extends Activity {
> >     /** Called when the activity is first created. */
>
> >         Bitmap bi=null;
>
> >     @Override
> >     public void onCreate(Bundle savedInstanceState) {
> >         super.onCreate(savedInstanceState);
> >         setContentView(R.layout.main);
>
> >         InputStream in=this.getResources().openRawResource
> > (R.drawable.dig);
> >         bi  = BitmapFactory.decodeStream(in);
> >         Log.i("bitmap1",""+bi);
> >         ImageView iv1=(ImageView)findViewById(R.id.img1);
> >         iv1.setImageBitmap(bi);
>
> >         String str= convertBitmapToString(bi);
> >         Log.i("image string",str);
> >         myDB a=new myDB(this);
> >         a.open();
> >         a.insertTag(str);
>
> >         Cursor c=a.fetchData(myDB.TABLE_NAME_TAG,new String[]
> > {myDB.KEY_TAG_IMG},null,null);
> >         startManagingCursor(c);
> >         int rc=c.getCount();
>
> >         ImageView iv;
> >         c.moveToFirst();
>
> >         if(rc!=0)
> >         {
> >                 String s=c.getString(0);
> >                 Log.i("cursor string image",s);
> >                 Bitmap bitmap=getBitMapFromString(s);
> >                 Log.i("bitmap2",""+bitmap);
> >                  iv=(ImageView)findViewById(R.id.img);
> >                  iv.setImageBitmap(bitmap);
> >         }
> >     }
>
> >     public static String convertBitmapToString(Bitmap src)
> >     {
> >     ByteArrayOutputStream os=new ByteArrayOutputStream();
> >     src.compress(android.graphics.Bitmap.CompressFormat.PNG, 100,
> > (OutputStream) os);
> >     return os.toString();
> >     }
>
> >     public static Bitmap getBitMapFromString(String src)
> >     {
> >         Log.i("b=",""+src.getBytes().length);//returns 12111 as a length.
> >     return BitmapFactory.decodeByteArray(src.getBytes(),0,src.getBytes
> > ().length);
> >     }
>
> > }- 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: Displaying image from internet source

2009-03-23 Thread Streets Of Boston

These two items stand out, with the most important one here:

03-23 16:20:37.199: ERROR/AndroidRuntime(767):
java.lang.NullPointerException
03-23 16:20:37.199: ERROR/AndroidRuntime(767): at
com.organiser.college.CollegeOrganiser$3.onClick
(CollegeOrganiser.java:
145)

Your CollegeOrganiser class throws a null-pointer exception in an
onClick method on line 145. You may want to solve this issue first.


The other error:
03-23 16:20:36.965: DEBUG/skia(767): xx failure to skip
request 2875 actual 1896
03-23 16:20:36.969: DEBUG/skia(767): xxx jpeg error 91
Miscellaneous marker 0x%02x, length %u

may be a problem. Althouhg, i've seen these debug-messages before and
all worked fine anyway.
Any google-engineer want to chime in :-)?


On Mar 23, 12:21 pm, murphy  wrote:
> 03-23 16:20:28.858: DEBUG/dalvikvm(91): GC freed 1176 objects / 62728
> bytes in 81ms
> 03-23 16:20:36.965: DEBUG/skia(767): xx failure to skip
> request 2875 actual 1896
> 03-23 16:20:36.969: DEBUG/skia(767): xxx jpeg error 91
> Miscellaneous marker 0x%02x, length %u
> 03-23 16:20:37.000: DEBUG/AndroidRuntime(767): Shutting down VM
> 03-23 16:20:37.000: WARN/dalvikvm(767): threadid=3: thread exiting
> with uncaught exception (group=0x40010e28)
> 03-23 16:20:37.000: ERROR/AndroidRuntime(767): Uncaught handler:
> thread main exiting due to uncaught exception
> 03-23 16:20:37.189: DEBUG/dalvikvm(767): GC freed 1718 objects /
> 425896 bytes in 151ms
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):
> java.lang.NullPointerException
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> com.organiser.college.CollegeOrganiser$3.onClick(CollegeOrganiser.java:
> 145)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.view.View.performClick(View.java:2109)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.view.View.onTouchEvent(View.java:3523)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.widget.TextView.onTouchEvent(TextView.java:4410)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.view.View.dispatchTouchEvent(View.java:3178)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:857)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:857)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:857)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:857)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> com.android.internal.policy.impl.PhoneWindow
> $DecorView.superDispatchTouchEvent(PhoneWindow.java:1561)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent
> (PhoneWindow.java:1085)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.app.Activity.dispatchTouchEvent(Activity.java:1873)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> com.android.internal.policy.impl.PhoneWindow
> $DecorView.dispatchTouchEvent(PhoneWindow.java:1545)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.view.ViewRoot.handleMessage(ViewRoot.java:1140)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.os.Handler.dispatchMessage(Handler.java:88)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.os.Looper.loop(Looper.java:123)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> android.app.ActivityThread.main(ActivityThread.java:3742)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> java.lang.reflect.Method.invoke(Method.java:515)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> (ZygoteInit.java:739)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
> 03-23 16:20:37.199: ERROR/AndroidRuntime(767):     at
> dalvik.system.NativeStart.main(Native Method)
> 03-23 16:20:37.280: INFO/Process(51): Sending signal. PID: 767 SIG: 3
> 03-23 16:20:37.299: INFO/dalvikvm(767): threadid=7: reacting to signal
> 3
> 03-23 16:20:37.418: INFO/dalvikvm(767): Wrote stack trace to '/data/
> anr/traces.txt'
> 03-23 16:20:38.829: INFO/Process(767): Sending signal. PID: 767 SIG: 9
> 03-23 16:20:38.901: INFO/ActivityManager(51): Process
> com.organiser.college (pid 767) has died.
> 03-23 16:20:39.030: INFO/WindowManager(51): WIN DEATH: Window{4342f180
> com.organiser.college/com.organiser.college.CollegeOrg

[android-developers] Re: " IWindowManager Not Available "

2009-03-23 Thread Streets Of Boston

And that's a BIIIGG 'if'. :-)

Trust Dianne on this. Do not use any API that is private. If you do,
at some point in time you will (and that's a 100% sure) break your
application and you will get a lot of angry customers.


On Mar 23, 3:16 pm, Rajendrakumar Chinnaiyan
 wrote:
> If they won't change the internal API's.. Our application also won't get any
> problem..
>
> On Mon, Mar 23, 2009 at 11:42 PM, Dianne Hackborn wrote:
>
>
>
>
>
> > On Mon, Mar 23, 2009 at 11:42 AM, AndRaj  wrote:
>
> >> oh... Good.. So it will change only if they change in new release
>
> > They will.  You will break.  Plus, you are linking against a special build
> > of a part of the Android platform that was designed to run on the desktop
> > for the UI editor.  There may be duplicate classes in there that you are
> > linking into your app instead of using in the system, and all kinds of
> > problems.
>
> >> i fthey won't change that it also won't change rt...
>
> > Sorry, I can't parse that sentence.
>
> > --
> > 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.  All such questions should be posted on public
> > forums, where I and others can see and answer them.
>
> --
> Regards
> Rajendrakumar Chinnaiyan
> COE | Testing Services | Wipro Technologies
> Mob : +919886293435- 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: Get scroll position in a list activity

2009-03-24 Thread Streets Of Boston

I've done the same in my apps for ListView (whether they be in
ListActivity or in a plain Activity) with good success.

I use the java.util.concurrent's ExecutorService to obtain images:

1. Your getView(..) (or bindView/newView/etc) needs to assign an image/
thumbnail (bitmap) to an ImageView. But you don't have the bitmap yet.
If you do have it (store in a limited size cache), just set it .
2. If not, obtain a FutureTask from the ExecutorService and this
FutureTask then will download the image, create a thumbnail from it
and creates a Bitmap from this thumbnail. Remember the id of the image
(can be an id, Uri, URL, whatever, as long as it is unique) and assign
it to the ImageView (setTag()).
3. When ready, the FutureTask will 'post' back to the main-thread that
it has an new thumbnail.
4. On the 'post'-back, loop through the children of ListView, get the
appropriate ImageView, the one whose tag (getTag()) is equal to the
one that FutureTask you got the image for, assign the Bitmap to this
ImageView. This is it.

For myself I created a sub-system of ExecutorService and FutureTask,
called 'Cancelable' tasks, which make it easier to cancel queued up
tasks when they're no longer necessary. But this is an optimization.

On Mar 24, 8:06 am, Mark Murphy  wrote:
> Ivan Soto wrote:
> > Do you have any article/tutorial about the placeholder images to share?
> > I'm trying to find one with no luck.
>
> I have used the technique, but not in code I'm allowed to share. I do
> need to more formally write this up at some point, but I do not have
> anything immediately handy.
>
> The gist of it is that you create your adapter and set it up, in
> getView() or newView()/bindView() (depending on adapter choice), to see
> if the thumbnail has been downloaded. If so, use it for the list row
> being inflated/updated; if not, leave the ImageView in the row pointing
> to some placeholder Drawable resource. This means as the user scrolls,
> she will pick up the thumbnails. Also, at the end, you can quickly
> iterate over the rows (ListView is a ViewGroup, IIRC, so there are
> methods to iterate its children) and ensure each of those rows'
> ImageViews are using their associated thumbnails.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> Android App Developer Books:http://commonsware.com/books.html
--~--~-~--~~~---~--~~
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: Get scroll position in a list activity

2009-03-24 Thread Streets Of Boston

Here is a code-snippet. I may not compile, but i think you'll get the
idea :-)

[code]
ExecutorService EXECUTOR = Executors.newFixedThreadPool(3); // max 3
worker threads.
...
public View getView(final AbsListView listView, View convertView, int
pos, long id) {

  ...
  ...

  final String imgUrl = ...
  ...
  final ImageView imgView = ...
  ...
  Bitmap bm = mBitmapCache.get(imgUrl);
  if (bm != null)
imgView.setImageBitmap(bm);
  else {
imgView.setTag(imgUrl);
FutureTask task = EXECUTOR.submit(new Runnable() {
  public void run() {
final Bitmap newBM = getImageFrom(imgUrl); // you have to
write this method
if (newBM == null)
  return;

// be sure that mBitmapCache is thread-safe.
mBitmapCache.put(imgUrl, newBM);

// instead of 'listView', you could use a new Handler
instance.
listView.post(new Runnable() {
  public void run() {
  String checkUrl = (String)imgView.getTag();
  if (checkUrl != null && !checkUrl.equals(imgUrl))
return;

  imgView.setImageBitmap(newBM);
  }
});
  }

  private Bitmap getImageFrom(String url) {
// download the data from imgUrl.
// create a bitmap from it.
return bitMap;
  }
});
  }

  // if you want, you can hold on to 'task' and call 'cancel' on it if
necessary, e.g.
  // when this convertView is about to be re-used and to be assigned
to a different image.
  return convertView;
}
[/code]

On Mar 24, 10:13 am, Streets Of Boston 
wrote:
> I've done the same in my apps for ListView (whether they be in
> ListActivity or in a plain Activity) with good success.
>
> I use the java.util.concurrent's ExecutorService to obtain images:
>
> 1. Your getView(..) (or bindView/newView/etc) needs to assign an image/
> thumbnail (bitmap) to an ImageView. But you don't have the bitmap yet.
> If you do have it (store in a limited size cache), just set it .
> 2. If not, obtain a FutureTask from the ExecutorService and this
> FutureTask then will download the image, create a thumbnail from it
> and creates a Bitmap from this thumbnail. Remember the id of the image
> (can be an id, Uri, URL, whatever, as long as it is unique) and assign
> it to the ImageView (setTag()).
> 3. When ready, the FutureTask will 'post' back to the main-thread that
> it has an new thumbnail.
> 4. On the 'post'-back, loop through the children of ListView, get the
> appropriate ImageView, the one whose tag (getTag()) is equal to the
> one that FutureTask you got the image for, assign the Bitmap to this
> ImageView. This is it.
>
> For myself I created a sub-system of ExecutorService and FutureTask,
> called 'Cancelable' tasks, which make it easier to cancel queued up
> tasks when they're no longer necessary. But this is an optimization.
>
> On Mar 24, 8:06 am, Mark Murphy  wrote:
>
>
>
> > Ivan Soto wrote:
> > > Do you have any article/tutorial about the placeholder images to share?
> > > I'm trying to find one with no luck.
>
> > I have used the technique, but not in code I'm allowed to share. I do
> > need to more formally write this up at some point, but I do not have
> > anything immediately handy.
>
> > The gist of it is that you create your adapter and set it up, in
> > getView() or newView()/bindView() (depending on adapter choice), to see
> > if the thumbnail has been downloaded. If so, use it for the list row
> > being inflated/updated; if not, leave the ImageView in the row pointing
> > to some placeholder Drawable resource. This means as the user scrolls,
> > she will pick up the thumbnails. Also, at the end, you can quickly
> > iterate over the rows (ListView is a ViewGroup, IIRC, so there are
> > methods to iterate its children) and ensure each of those rows'
> > ImageViews are using their associated thumbnails.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > Android App Developer Books:http://commonsware.com/books.html- 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] Question about one application requiring another application or service

2009-03-24 Thread Streets Of Boston

Hi everyone,

I'm writing an app that needs one or more applications/services that
are distributed with their own seperate apk file.

I'm writing a user-app that allows the user to upload pics using a
service. The service can be used by multiple user-apps, not just mine.
I'd like to have the service being installed in its own apk, instead
of bundling it with each user-app.

Has anyone had experience with this scenario?
What is the best scenario i should implement so that the user
downloads the service that the user-app needs? Can be this be done
automatically (that would be best)? If not, in your opinion, what
would be the most user-friendly way for doing so?

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: Question about OpenGL literature

2009-03-25 Thread Streets Of Boston

Google this

  opengl es

I found the links to the khronos web-pages most helpful.
Other links found by google can be helpful as well :-)

Another source is the OpenGL examples on the APIDemos bundled with the
Android SDK.

For books; i cannot help you there.

On Mar 25, 7:43 am, EvgenyV  wrote:
> Hi all,
>
> Can you please suggest some book(s) or any other useful references
> about OpenGL?
>
> Thanks in advance,
> Evgeny
--~--~-~--~~~---~--~~
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 the current matrix mode?

2009-03-25 Thread Streets Of Boston

Before you do all the work, take a look these classes bundled in the
OpenGL session of the APIDemos of the samples in the Anroid SDK:

MatrixTrackingGL.java. In your SDK or online:
http://code.google.com/p/apps-for-android/source/browse/trunk/Samples/OpenGLES/SpriteText/src/com/google/android/opengles/spritetext/MatrixTrackingGL.java?r=35

MatrixGrabber.java. In your SDK or online:
http://code.google.com/p/apps-for-android/source/browse/trunk/Samples/OpenGLES/SpriteText/src/com/google/android/opengles/spritetext/MatrixGrabber.java?r=35

On Mar 25, 4:33 am, tcassany  wrote:
> I will write a wrapper as you explain. It's not very beautifull but
> it's the only solution that I see now.
>
> Thank you.
>
> Thomas
>
> On Mar 24, 8:31 am, Anton  wrote:
>
>
>
> >     Thomas, I just tested this using the glGetIntegerv method that
> > takes an int array instead of a Buffer.  It also returned 0 for me.
> > So I dug into the source and found that the implementation of
> > glGetIntegerv doesn't have a case for GL_MATRIX_MODE.  And it sets the
> > GL error to GL_INVALID_ENUM (1280).  And sure enough, 1280 is returned
> > by a call to glGetError right after the call to glGetIntegerv.  So it
> > looks like you can't get the GL_MATRIX_MODE that way on Android.
>
> >     And upon further looking through the code I don't see anywhere
> > that the matrixMode state variable is accessed.  So I doubt that
> > you'll have any luck getting it from the java API.
>
> >     If you control all of your OpenGL code you can work around this by
> > using a wrapper to change GL state.  It's not ideal, but it should
> > work.  That wrapper class could then be queried for the current matrix
> > mode.
>
> >     -Anton
>
> > On Mar 23, 7:39 am, tcassany  wrote:
>
> > > Hello,
>
> > > I just would to know how can I get the currentmatrixmode. I try whit
> > > this :
>
> > > ByteBuffer buffer = ByteBuffer.allocate(4);
> > > buffer.order(ByteOrder.nativeOrder());
> > > IntBuffer matrixMode = buffer.asIntBuffer();
> > > gl.glGetIntegerv(GL11.GL_MATRIX_MODE, matrixMode);
>
> > > ..
>
> > > gl.glMatrixMode(matrixMode.get(0))
>
> > > But it's alway return 0 instead of GL_MODELVIEW(5888) in my case.
>
> > > Thanks,
>
> > > Thomas- 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: photo picker Uri issue

2009-03-25 Thread Streets Of Boston

This Uri is the logical (not physical) path used by the image content
provider.
If you want to get the physical path to the actual file on the SD-
card, query this Uri:

  Cursor cursor = query(photoUri, new String[]
{MediaStore.Images.ImageColumns.DATA}, null, null, null);
  String absoluteFilePath = cursor.getString(0);

Now, absoluteFilePath is the physical path to your image, which you
can use in Drawable.createFromPath

Question: Why don't you create a Bitmap instead?

   ...
   InputStream is = getContentResolver().openInputStream(photoUri);
   Bitmap bm = BitmapFactory.decodeStream(is);
   ...
   is.close();

I ask this, because it is safer to cache Bitmaps instead of Drawables.
If you cache Drawables, you run the risk of memory leaks. Drawables
have handles to your activity and when your activity gets destroyed
while your Drawables are still cached, your activiy will never be
garbage collected --> memory leak.
Bitmaps don't have this problem. They are basically byte-arrays with
some behavior :).

On Mar 25, 3:15 am, beachy  wrote:
> In some code I call this;
>                                         Intent photoPickerIntent = new Intent
> (Intent.ACTION_PICK);
>                                     photoPickerIntent.setType("image/*");
>                                     startActivityForResult(photoPickerIntent,
> 1);
>
> then implement this method
>
> protected void onActivityResult(int requestCode, int resultCode,
> Intent intent)
>         {
>              super.onActivityResult(requestCode, resultCode, intent);
>
>              if (resultCode == RESULT_OK)
>              {
>                      Uri photoUri = intent.getData();
>                      Log.d(TAG, "should be adding a photo");
>                      if (photoUri != null)
>                      {
>
>                              Log.d(TAG, "photo uri is not blank");
>                                  // do something with the content Uri
>                              //TODO figure out why this does not work!!
>                              Log.d(TAG, "the photo URI is " + 
> photoUri.getPath());
>                          Drawable thePic = Drawable.createFromPath
> (photoUri.getPath());
>                          //thePic is Null
>                                      if(thePic != null){
>                              Log.d(TAG, "the pic has loaded");
>                                  myRecipe.addPic(thePic);
>                                  ((RecipeAdapter)myListView.getAdapter
> ()).notifyDataSetChanged();
>
>                          }
>                      }
>              }
>         }
>
> trying to get a image and load it in to a drawable object. The Uri
> that is returned seems logical
>
> 03-25 08:12:58.554: DEBUG/ConvertScaleScreen(174): the photo URI is /
> external/images/media/1
>
> but when i start up a shell with adb the file location or even the
> root drive does not exitst, am I missing something here? should the be
> a symbolic link on the file system?
--~--~-~--~~~---~--~~
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: File size column in image database is always 0 for the newest image

2009-03-26 Thread Streets Of Boston

I had the same problem and it was driving me nuts. I think it's a bug.
Below is how i worked-around it.

Do what you do now by calling insertImage(...).
This will insert the image into the data-base; however, thumbnails are
not correctly generated and the SIZE attribute is 0 (your problem that
you see).

Execute a query, and use the cursor to get the physical file-path (use
the ImageColumns.DATA).
Using the physical file-path, use the MediaScanner
(MediaScannerConnection) to scan your newly inserted image.
After the MediaScanner has finished, querying your image on
ImageColumns.SIZE (and other attributes) should work correctly.

I suggest to do this in a seperate worker-thread... it is kinda-slow.

On Mar 26, 9:47 am, Matthias  wrote:
> Hi,
>
> I am uploading images to our webservice from the phone, and thus I
> need to know the exact size of an image. I noticed that with some
> photos from the G1, the webservice always failed, and found out that
> it's due to the file size always being 0 for the latest image in the
> database.
>
> Is this a known bug? What else can I do to find out the size of an
> image on the phone without going through the DB? I want to avoid
> writing the whole image to a byte buffer just to find out its size...
>
> here is some code to play with:
>
>                 ContentResolver contentResolver = getContentResolver
> ();
>                 Cursor c = contentResolver.query(
>                         Uri.parse("content://media/external/images/
> media"),
>                         new String[] { Images.ImageColumns._ID,
>                                 Images.ImageColumns.DISPLAY_NAME,
>                                 Images.ImageColumns.SIZE }, null,
> null, null);
>                 while (c.moveToNext()) {
>                     Log.d("PHOTO", c.getLong(0) + " " + c.getString(1)
> + " "
>                             + c.getLong(2));
>                 }
>                 c.close();
>
> This gives me 0 in the third column for the last entry (that's the
> newest photo).
--~--~-~--~~~---~--~~
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: Anything on Android that can do smooth scrolling?

2009-03-26 Thread Streets Of Boston

Add my vote for this option/feature: A permission for an app to become
the only app running (except maybe the phone-app and incoming SMS,
etc).

On Mar 26, 7:26 am, Stoyan Damov  wrote:
> I've also proposed a solution to this - adding a permission for apps
> to request that they run alone, uninterrupted by other processes.
>
> That is, the app can request a permission, demanding that the app can
> only be interrupted by an external event, such as phone call, all
> other services and background processes (other than the ones the OS
> can't go without) are paused when app is running.
>
> I know it's quite tricky to implement this, because, for example, when
> an SMS is received it needs to be stored in the database, and this
> will require some memory, which will need to be discarded, when the
> SMS is written to the database, and this will trigger GC. However,
> when such a message is received, and the OS knows that an app with the
> special permission runs in the foreground, it could delay the GC
> either until:
>
> - the app itself allocates memory (no matter if it might not be
> actually GC'ed until the app finishes) OR
> - the systems goes pretty low on memory
>
> At least, non-stock services (i.e. services, developed by 3rd parties)
> can be suspended during the lifetime of an application requesting the
> special permission.
>
> Cheers
>
>
>
> On Thu, Mar 26, 2009 at 11:51 AM, Stoyan Damov  wrote:
> > On Wed, Mar 25, 2009 at 11:02 PM, Romain Guy  wrote:
>
> >> The trick is simple: avoid any allocation that might trigger a GC.
>
> > It's not that simple at all.
> > In fact, it is *impossible* on Android, or any other mobile OS which
> > allows background processes.
>
> > I've already said this once -- even though your game can be tuned to
> > the max, nothing prevents *other* apps from triggering GC.
> > That is, in my game, I *never*, *ever* do any allocation after startup.
> > However, other background processes do trigger GC, and voila - my game
> > stutters for a bit when GC kicks in.
>
> > Compare to iPhone, which disallows background processing and the
> > foreground app is never interrupted.
>
> > Cheers- 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: File size column in image database is always 0 for the newest image

2009-03-26 Thread Streets Of Boston

You still may need to do this, though.

With my application; if i don't do the MediaScanner thing, the
'Pictures' application will crash!
You may find the same problem. Try to insert an image (with the SIZE
being 0), then close your app and start the stock 'Pictures'
application. Check if it crashes or not.

If it does, you should do the MediaScanner thing. You don't want to
get angry customers :-)

On Mar 26, 10:32 am, matthias  wrote:
> Hi,
>
> thanks for the swift reply!
>
> Hm, if the workaround you suggest is slow, maybe I am better off with
> writing the image to a byte buffer and taking its size after all? I
> just tested that solution, and it was much faster than I expected.
> Since I upload images in a background service, it may not even be a
> noticeable overhead to the user.
>
> But still, this is an annoyance, did you already raise a bug for this?
>
> Cheers,
> Matthias
--~--~-~--~~~---~--~~
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: Anything on Android that can do smooth scrolling?

2009-03-26 Thread Streets Of Boston

I should have added that this would apply to the phone's *foreground*
application only.

Or at least something that allows the foreground app to get a very
high priority and resource allowance from the operating system to
minimize the influence of non-essential (background) applications.

On Mar 26, 4:50 pm, Sundog  wrote:
> On Mar 26, 12:22 pm, Dianne Hackborn  wrote:
>
> > No.
>
> Agreed. A race condition-like situation waiting to happen.
--~--~-~--~~~---~--~~
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: Anything on Android that can do smooth scrolling?

2009-03-26 Thread Streets Of Boston

Yep, *exclusively* would not be a good idea. The user still would want
phone-calls to come in and other such tasks.
But wouldn't causing Android to be a bit (a lot) more aggresive in
cleaning up not-so-important processes be something that is possible?

Another (outlandish?) possibility:
A phone-setting that's something similar like 'Airplane Mode' (the
mode disabling all the phone's radio-activity). Let's call it 'Game
Mode'. It'll give the user a better game-console experience, but a
lousier (or non-existent) phone experience.

Android engineers:
We heard from you what's *not* possible.
But what could be possible? I'd be interested in hearing about this
from you all, even if the ideas seam outlandish. :-)

On Mar 26, 6:05 pm, Sundog  wrote:
> On Mar 26, 3:52 pm, Streets Of Boston  wrote:
>
> > I should have added that this would apply to the phone's *foreground*
> > application only
>
> I knew I shouldn't have compared it to a race situation... bad
> analogy!
>
> Here's a better example: Imagine you're running Linux and the program
> you're interested in is running slow. Why not just go set your nice
> level to get all the processor time?
>
> Anyone who's a Linux or Unix administrator type at all just got
> it.  ;)
>
> > Or at least something that allows the foreground app to get a very
> > high priority and resource allowance from the operating system to
> > minimize the influence of non-essential (background) applications.
>
> Exactly. But running our foreground app EXCLUSIVELY is just out of the
> question, for reasons which should be clear by now.
--~--~-~--~~~---~--~~
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: File size column in image database is always 0 for the newest image

2009-03-27 Thread Streets Of Boston

Read my post from yesterday at 10am again :-)

Execute a query using your content-uri, and use the returned cursor to
obtain the physical file-path (use the ImageColumns.DATA).

On Mar 27, 9:27 am, matthias  wrote:
> okay, one solution is to do something like this:
>
>         String path = Environment.getExternalStorageDirectory
> ().getAbsolutePath()
>                 + "/dcim/Camera/" + [value of DISPLAY_NAME column for
> this image];
>
> and then do a new File(path).length()
>
> but I'm not sure if that path value is portable between Android
> devices.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Anything on Android that can do smooth scrolling?

2009-03-27 Thread Streets Of Boston

"But discarding background apps is not the
appropriate solution, it's just one easy solution"
Easy solutions are usually pretty good! :-) But maybe not in this
case.
Romain, what would you deem to be appropriate solutions?

Thanks Dianna,
"We are looking at more strongly enforcing that background
applications can
not take too many cycles from the foreground"
Good to know your team is looking into this. Would this be a good
enough solution?

On Mar 27, 6:16 am, Romain Guy  wrote:
> You are looking at *ONE* use case. Android is trying to provide an
> efficient system to the users that also allows background apps. I'm
> not saying it's an easy problem to solve, I'm saying that the
> comparison with some other devices out there is moot when they're not
> trying to reach the same goals. We would all very much like to see
> this issue disappear and what we need is hard data and discussions on
> how to solve this issue. But discarding background apps is not the
> appropriate solution, it's just one easy solution.
>
>
>
>
>
> On Fri, Mar 27, 2009 at 3:06 AM, Al Sutton  wrote:
>
> > I guess it comes down to the choice of do we want high performance games on
> > Android or not.
>
> > At the moment it seems clear that due to the ability of background tasks to
> > continue running it is next to impossible to provide predictable performance
> > for resource demanding games on all users devices and thus games can not
> > make the most out of the hardware without risking 1* ratings and being
> > called laggy by those running a number of background apps.
>
> > Maybe this is where Android is trying to be different. Maybe games are not
> > best suited to an Android based platform because of this. I guess time and
> > users will be the judge of whether this is the right way to go.
>
> > Personally I don't think it is, but hey, I'm only one voice.
>
> > Al.
>
> > -Original Message-
> > From: android-developers@googlegroups.com
> > [mailto:android-develop...@googlegroups.com] On Behalf Of Romain Guy
> > Sent: 27 March 2009 09:47
> > To: android-developers@googlegroups.com
> > Subject: [android-developers] Re: Anything on Android that can do smooth
> > scrolling?
>
> > No, I was not pointing back to this idea.
>
> > And the PS3 does that because it's a *video game console.* On which you
> > usually do *one thing at a time.*
>
> > On Fri, Mar 27, 2009 at 2:44 AM, Al Sutton  wrote:
>
> >> And once again we get pointed back to the idea of pausing most (if not
> >> all) background apps to achieve a good user experience.
>
> >> Even the PS3 which has far better hardware than the G1 goes down this
> >> route as it pauses the game just to bring up an in-game menu. The only
> >> thing it ever tries to run in the background is the PlayTV system and
> >> that comes with a big warning about affecting game performance.
>
> >> Al.
>
> >> -Original Message-
> >> From: android-developers@googlegroups.com
> >> [mailto:android-develop...@googlegroups.com] On Behalf Of Romain Guy
> >> Sent: 27 March 2009 09:38
> >> To: android-developers@googlegroups.com
> >> Subject: [android-developers] Re: Anything on Android that can do
> >> smooth scrolling?
>
> >> Yeah... none of them have background apps.
>
> >> On Fri, Mar 27, 2009 at 2:33 AM, Al Sutton  wrote:
>
> >>> Ahh so that's how the PSP, DS, and iPhone do it Hold up, that
> >>> doesn't sound right... :).
>
> >>> Al.
>
> >>> -Original Message-
> >>> From: android-developers@googlegroups.com
> >>> [mailto:android-develop...@googlegroups.com] On Behalf Of Romain Guy
> >>> Sent: 26 March 2009 22:12
> >>> To: android-developers@googlegroups.com
> >>> Subject: [android-developers] Re: Anything on Android that can do
> >>> smooth scrolling?
>
> >>> Have multiple cores :)
>
> >>> On Thu, Mar 26, 2009 at 3:10 PM, Stoyan Damov
> >>> 
> >>> wrote:
>
>  On Thu, Mar 26, 2009 at 11:53 PM, Romain Guy 
> >> wrote:
>
> > Once again it has NOTHING to do with GC, it's just another app
> > using the CPU. It could be for any reason, not just GC.
>
> > I hope you get it now.
>
>  Aaaah, @#$ me. I GET it now!
>
>  Thanks Romain, and thanks again for patiently explaining this
>  several
> >>> times!
>
>  So, we're back then to square 1 - how do we make Android *appear*
>  that it runs an application exclusively.
>  That is, what's the best way to ensure great user experience for
>  demanding apps, such as games, without pausing all other processes.
>
>  Any ideas besides the permission thing, anyone?
>
>  Cheers
>
> >>> --
> >>> 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
>
> >> --
> >> Romain Guy
> >> Android framework engineer
> >> romain...@android.com
>
> >> Note: please don't send private que

[android-developers] Re: need some collection help

2009-03-27 Thread Streets Of Boston

You can not create a Collection. It is an interface, as other already
pointed out.

Judging from your other posts, i'd suggest your using an
ArrayList.
An ArrayList is basically some behavior around an array of objects (in
your case Car[]). Internally, it's using an array and it handles all
the insertions, removals, etc. for you. To avoid too many object-
allocations, initialize your ArrayList with an appropriate capacity.
E.g. if you think you'll never need more than 100 objects do
"Collection _cars = new ArrayList(100);"

If you want to make your objects searchable, e.g. making this code
work "int idx = _cars.indexOf(someCar);", implement a "public boolean
equals(Object otherCar)" method on your Car class.

On Mar 26, 9:50 pm, Josh Dobbs  wrote:
> I want to keep track of multiple instances of a class without hardcoding a
> bunch of variables. I can use either an array or collection it doesnt really
> matter to me but I cant seem to get either to work. I cant seem to find an
> example of what I want to do anywhere. Im also open to suggestions if their
> is a better way to do this.
>
> On Thu, Mar 26, 2009 at 6:34 AM, Stoyan Damov wrote:
>
>
>
>
>
> > I don't understand what are you really asking? Whether arrays are
> > faster than collection classes? Yes, they are faster, but you have to
> > manage their contents (insertions, deletions, etc.) yourself.
>
> > On Thu, Mar 26, 2009 at 3:31 PM, Josh Dobbs  wrote:
> > > Here's what my code looks like...
>
> > > private
>
> > > Collection _cars;
>
> > > Car myCar=
>
> > > new Car(1,1,false,5, "blue");
>
> > > Car myCar2= new Car(1,1,false,5, "red");
>
> > > _cars.add(myCar);
> > > _cars.add(myCar2);
>
> > > On Thu, Mar 26, 2009 at 6:18 AM, Josh Dobbs  wrote:
>
> > >> >You mean like the ones in the java.util
> > >> Yes, specifically java.util.collection
> > >> >What's a VO?
> > >> A VO is basically a class that only contains properties(Value Objects).
>
> > >> On Thu, Mar 26, 2009 at 4:53 AM, Mark Murphy 
> > >> wrote:
>
> > >>> Josh wrote:
> > >>> > I want to store objects into an array or collection(whichever is best
> > >>> > suited to this in dalvik).
>
> > >>> You mean like the ones in the java.util package?
>
> > >>> > the objects are basically just VO's all of
> > >>> > the same class that i want to keep track of.
>
> > >>> What's a VO?
>
> > >>> --
> > >>> Mark Murphy (a Commons Guy)
> > >>>http://commonsware.com
> > >>> _The Busy Coder's Guide to Android Development_ Version 2.0 Available!- 
> > >>> 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: Question about one application requiring another application or service

2009-03-28 Thread Streets Of Boston

Bump :-)
Has anyone dealt with a similar problem before?

Thanks!

On Mar 24, 3:32 pm, Streets Of Boston  wrote:
> Hi everyone,
>
> I'm writing an app that needs one or more applications/services that
> are distributed with their own seperate apk file.
>
> I'm writing a user-app that allows the user to upload pics using a
> service. The service can be used by multiple user-apps, not just mine.
> I'd like to have the service being installed in its own apk, instead
> of bundling it with each user-app.
>
> Has anyone had experience with this scenario?
> What is the best scenario i should implement so that the user
> downloads the service that the user-app needs? Can be this be done
> automatically (that would be best)? If not, in your opinion, what
> would be the most user-friendly way for doing so?
>
> 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: Question about one application requiring another application or service

2009-03-29 Thread Streets Of Boston

Thanks for your answer.

That's what i feared. I knew that you can start the Market to the apps/
packages you need to download when your code detects certain classes/
intents/services are missing. I was just hoping something more
userfriendly was available (e.g. automatic download after app-
permissions are confirmed by the user).

On Mar 28, 8:46 pm, Mark Murphy  wrote:
> Streets Of Boston wrote:
> > Bump :-)
> > Has anyone dealt with a similar problem before?
>
> I will be dealing with a similar problem over the next month or so. Take
> these thoughts with a decent-sized grain of salt.
>
> >> I'm writing a user-app that allows the user to upload pics using a
> >> service. The service can be used by multiple user-apps, not just mine.
> >> I'd like to have the service being installed in its own apk, instead
> >> of bundling it with each user-app.
>
> >> Has anyone had experience with this scenario?
>
> Only theory, not practice as yet.
>
> >> What is the best scenario i should implement so that the user
> >> downloads the service that the user-app needs?
>
> U...that depends a bit on how you define "best".
>
> >> Can be this be done
> >> automatically (that would be best)?
>
> No. Android does not have a package management system that tracks
> dependencies (a la apt or yum in Linux).
>
> >> If not, in your opinion, what
> >> would be the most user-friendly way for doing so?
>
> Set up your UI to detect if the service is or is not installed. When the
> user clicks the menu choice (or whatever) that leads down the path where
> you need the service, display a "hey, you need to grab the such-and-so
> add-on to enable this feature -- click here!" screen. The "click here"
> would either open a Market Uri (if you're distributing the add-on via
> the Market) or your Web site (if you're not). They'd download/install
> the service and eventually wander their way back to your app, at which
> point you can detect that the service is available.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Warescription: Three Android Books, Plus Updates, $35/Year
--~--~-~--~~~---~--~~
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: Paid upgrades discussion

2009-03-29 Thread Streets Of Boston

I'm not a hundred percent sure, but very close to 100% :-)

Google's Android Market does not provide upgrade functionaliy, except
free upgrades forever.
Sorry... :(

I'm sorry to say this, but you could have known this before you put
all this work in, if you had read the terms and agreements of the
Android Market.

For now, you could -

- either maintain two versions: The old one and upgrade this one just
a bit for users to upgrade for free; The new one for a higher price as
a new application.

- or you could just have current customers have free upgrades and new
customers pay the somewhat higher price. Since you improved your app,
hopefully you will get your rewards by even more customers.



On Mar 29, 10:41 pm, Keith Wiley  wrote:
> I'm not sure whether to bring this up on the developer or market
> group.  Since it is a developer-oriented discussion, I have chosen to
> put it here.  I apologize if I was incorrect in this choice.
>
> I am about to release a major upgrade for my app.  It represents
> hundreds of hours of work spanning several weeks of my life.  The
> increase in functionality and change in behavior and UI are
> significant, so much so that I intend to raise the price (slightly)
> after uploading the new version.  Problem is, current users will
> simply download the new upgrade for free without paying me
> anything...unless they are kind enough to make a donation.  I don't
> want to make the new app a completely different package because then
> new and upgrading users would have to pay the full price, which would
> probably (rightfully) infuriate the current users.  I don't want to
> charge them full price, I honestly don't want that kind of money from
> them
>
> ...but just because you bought MS Office in 1987 or whatever doesn't
> mean you get to walk out of a store with every new version for free
> for the rest of your life after that...
>
> I don't know what to do, but I hate the idea of just giving all this
> effort away for free, I've worked insanely long hours on this
> project.  I am looking or any suggestions.  The only approach I've
> thought of so far is the beg and plead for upgrade donations on the
> splash screen or something pathetic like that.
>
> Ideas?
--~--~-~--~~~---~--~~
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: IntBuffer Overflow - OpenGL ES

2009-03-30 Thread Streets Of Boston

Good to know. At least it's good to know that i was not going crazy :-
D
I used the for-loop solution to get around this issue.

On Mar 30, 7:04 am, Daniel Johansson  wrote:
> I'm experiencing the same behavior, and I'm pretty sure it's a bug.
>
> I have been testing this thoroughly and it simply does not work to put
> an array och another IntBuffer into a "direct" IntBuffer.
>
> intBuffer.clear();
> intBuffer.put(otherIntBuffer);
>
> This does not work if "intBuffer" is a direct IntBuffer. It does work
> for indirect IntBuffers and also for direct/indirect FloatBuffers.
> The error shows itself through that the intBuffer.clear() operation
> does not clear the buffer the second time i run this code. That means
> the next put() will append the new information to the old and there is
> a buffer overflow.
>
> The workaround is to create a for-loop that puts one element at a time
> from "otherIntBuffer" into "intBuffer". Or to use FloatBuffers.
>
> On Feb 2, 4:24 pm, shaun  wrote:
>
>
>
> > I am trying to optimize the OpenGL ES rendering pipeline, along with
> > general optimizations for a proof of concept.  One thing I did was to
> > take vertex and texture coordinate float[] data and FloatBuffer that
> > are passed to gl*Pointer methods and convert them into int[] data 
> > andIntBufferobjects, because I am using GL_FIXED and fixed point math.
>
> > After initializing/allocateDirect()'ing the IntBuffers and put()'ing
> > the int[] data in them for the first time, the render() method is
> > called once per frame.  After the rendering, the int[] data is updated
> > for both vertex and texture data.  Then, the following methods are
> > called on theIntBufferobjects:
> >    -vertices_buffer.clear()
> >    -vertices_buffer.put(vertices) // vertices is a int []
> >    -vertices_buffer.position(0)
>
> > This was not problem when using float[] and FloatBuffer, but a
> > BufferOverflowException is being thrown on that call to put().  The
> > API says this is only thrown when the remaining size of theIntBuffer
> > is less than the length of the int[] passed in.  Well, both of those
> > values are output to the log on the line just prior to calling put()
> > (intBuf.remaining() and intArr.length).  They both output 600, and
> > last I checked 600 is not less than 600!
>
> > I figure I am missing something simple.  I checked the call made to
> > allocateDirect() and it looks like this:
> >    -vertices_direct = ByteBuffer.allocateDirect (vertices.length *
> > (Integer.SIZE >> 3));
> >    -vertices_direct.order (ByteOrder.nativeOrder ());
> >    -vertices_buffer = vertices_direct.asIntBuffer();
>
> > The original code (using floating point math and Android SDK m3-rc37a)
> > can be found 
> > here:http://www.enfis.it/wp-content/uploads/2008/01/tunnel3d.ziphttp://www...
>
> > Obviously, I had to convert the original code up to Android SDK 1.0
> > r2.  I ended up using EGL as I did not see a way around it.  Keep in
> > mind I have little OpenGL experience, let alone ES 1.0 on Android.- 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: Photo Picker

2009-03-30 Thread Streets Of Boston

This works as designed.

The getDataString() is the string of the content Uri that refers to
the image.
If you want the physical filename, do a 'Cursor cursor =
getContentResolver().query(intent.getData(), null, null, null, null)'
and query the column ImageColumns.DATA on the returned cursor.

The cursor.getString(ImageColumns.DATA) will return the physical file-
path on your SC-card.


On Mar 30, 3:58 pm, Bobbie  wrote:
> I am having issues with some "photo picker" code that I am using.  All
> of my pictures are stored on an SD card.  The SD card is mounted and I
> can take pictures no problem.  However, when I select a picture from
> the picker and output the location of the file, I should get:
>
> "/sdcard/dcim/Camera/FILENAME.jpg"
>
> But instead, I get:
>
> "content://media/external/images/media/7"
>
> Any ideas what could be causing this?  Here is my code, a button
> invokes the "takePic()" function:
>
> 
>
>     public void takePic() {
>         Intent photoPickerIntent = new Intent
> (Intent.ACTION_GET_CONTENT);
>         photoPickerIntent.setType("image/*");
>         startActivityForResult(photoPickerIntent, 1);
>     }
>
>     @Override
>     protected void onActivityResult(int i, int j, Intent intent) {
>         super.onActivityResult(i, j, intent);
>
>         textview.append(intent.getDataString());
>     }
--~--~-~--~~~---~--~~
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 Physics Engine

2009-03-30 Thread Streets Of Boston

I wonder how well this one works on Android:

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

-- Anton Spaans

On Mar 30, 4:58 pm, Anton  wrote:
>     I have a simple 2D physics engine written and running.  It uses
> the now famous Jacobson physics tricks (Verlet integration and hard
> constraints).  I can manage 40 balls on the screen, with fill n^2
> interaction between balls.  I am working on spatial data structure
> optimizations now to improve the computational complexity of the
> collision detection code.  I run the constraint update loop five times
> per frame and get 30 frames per second.  Once the engine is up and
> running there are no memory allocations done in my program.  And once
> the system settles down from the app launch there are very few GC
> events from other programs.  Though they do still happen.  Viewing
> LogCat I see a GC every 10 or 20 seconds because of some background
> application.  But between those events I get a consistent frame rate.
> I am using OpenGL for my rendering.
>
>     -Anton
>
> On Mar 30, 1:14 pm, mscwd01  wrote:
>
>
>
> > Does anyone know of, or have implemented, a physics engine which runs
> > smoothly in Android?
>
> > I have spent the last couple of days trying Phys2D and JBox2D, however
> > both perform very poorly - I am struggling to get even a few objects
> > to simulate smoothly as frequent garbage collection spoils it.
>
> > One question I do have is will these run smoother on an actual G1
> > device or is the performance of the emulator accurate?
>
> > 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: Android Physics Engine

2009-03-30 Thread Streets Of Boston

Try the demo on firefox. It works really well.

On Mar 30, 5:59 pm, Anton  wrote:
>     Could be good.  I tried to check out the demo but it crashed my
> browser.  :)  I'm sure that's not really indicative of the engine, and
> more of my browser's stability.  I did look through the code and found
> that it does a lot of memory allocation in it's inner loops (Verlet
> update step in particular), and that it uses floating point math,
> though it looks like there is a branch that uses fixed point that
> might be worth trying out.
>
>     -Anton
>
> On Mar 30, 2:41 pm, Streets Of Boston  wrote:
>
>
>
> > I wonder how well this one works on Android:
>
> >  http://code.google.com/p/simpull/
>
> > -- Anton Spaans
>
> > On Mar 30, 4:58 pm, Anton  wrote:
>
> > >     I have a simple 2D physics engine written and running.  It uses
> > > the now famous Jacobson physics tricks (Verlet integration and hard
> > > constraints).  I can manage 40 balls on the screen, with fill n^2
> > > interaction between balls.  I am working on spatial data structure
> > > optimizations now to improve the computational complexity of the
> > > collision detection code.  I run the constraint update loop five times
> > > per frame and get 30 frames per second.  Once the engine is up and
> > > running there are no memory allocations done in my program.  And once
> > > the system settles down from the app launch there are very few GC
> > > events from other programs.  Though they do still happen.  Viewing
> > > LogCat I see a GC every 10 or 20 seconds because of some background
> > > application.  But between those events I get a consistent frame rate.
> > > I am using OpenGL for my rendering.
>
> > >     -Anton
>
> > > On Mar 30, 1:14 pm, mscwd01  wrote:
>
> > > > Does anyone know of, or have implemented, a physics engine which runs
> > > > smoothly in Android?
>
> > > > I have spent the last couple of days trying Phys2D and JBox2D, however
> > > > both perform very poorly - I am struggling to get even a few objects
> > > > to simulate smoothly as frequent garbage collection spoils it.
>
> > > > One question I do have is will these run smoother on an actual G1
> > > > device or is the performance of the emulator accurate?
>
> > > > Thanks- 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: Photo Picker

2009-03-30 Thread Streets Of Boston

int idx = cursor.getColumnIndex(ImageColumn.DATA);
String fname = cursor.getString(idx);

On Mar 30, 7:45 pm, Bobbie  wrote:
> Wow... It's so simple, but still got an error... I got this:
>
> Cursor cursor = getContentResolver().query(datatoget, null, null,
> null, null);
> String fname = cursor.getString(ImageColumns.DATA);
>
> It won't let me run the code... "getString" is underlined in red and
> it just wants me to change it to "getLong" but if I do that, it just
> tells me to change it back to "getString" again... Am I doing
> something wrong here, or am I that bad at coding Android?
>
> On Mar 30, 4:37 pm, Streets Of Boston  wrote:
>
>
>
> > This works as designed.
>
> > The getDataString() is the string of the content Uri that refers to
> > theimage.
> > If you want the physical filename, do a 'Cursor cursor =
> > getContentResolver().query(intent.getData(), null, null, null, null)'
> > and query the column ImageColumns.DATA on the returned cursor.
>
> > Thecursor.getString(ImageColumns.DATA) will return the physical file-
> > path on your SC-card.
>
> > On Mar 30, 3:58 pm, Bobbie  wrote:
>
> > > I am having issues with some "photo picker" code that I am using.  All
> > > of my pictures are stored on an SD card.  The SD card is mounted and I
> > > can take pictures no problem.  However, when I select a picture from
> > > the picker and output the location of the file, I should get:
>
> > > "/sdcard/dcim/Camera/FILENAME.jpg"
>
> > > But instead, I get:
>
> > > "content://media/external/images/media/7"
>
> > > Any ideas what could be causing this?  Here is my code, a button
> > > invokes the "takePic()" function:
>
> > > 
>
> > >     public void takePic() {
> > >         Intent photoPickerIntent = new Intent
> > > (Intent.ACTION_GET_CONTENT);
> > >         photoPickerIntent.setType("image/*");
> > >         startActivityForResult(photoPickerIntent, 1);
> > >     }
>
> > >     @Override
> > >     protected void onActivityResult(int i, int j, Intent intent) {
> > >         super.onActivityResult(i, j, intent);
>
> > >         textview.append(intent.getDataString());
> > >     }- 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: dispatchTouchEvent works differently when finger hold on touch screen in G1 & emulator

2009-03-30 Thread Streets Of Boston

Override you dispatchTouchEvent(...), as you do right now, and forward
its MotionEvent to a GestureDetector you created.

public class MyView {

   GestureDetector mGD = new GestureDetector(this);

   public MyView(...) {
  ...
  ...
  mGD.setIsLongPressEnabled(true);
  ...
   }
   public boolean dispatchTouchEvent(MotionEvent event) {
  ... you may want to handle the MotionEvent.ACTION_UP yourself
first. ...
  ... but always call this at the end:
  return mGD.onTouchEvent(event);
   }

   // Called by the GestureDetector mGD.
   public void onLongPress(MotionEvent event) {
  // do your stuff here.
   }
}

On Mar 30, 9:51 pm, Oceanedge  wrote:
> Thank you very much!
>
> But my current usecase is not to detect motion, but hold. I have a
> PhotoView which display an icon. It needs to respond to click and hold
> event.
> If user click on it, it will scroll other widget content in one step.
> If user touch & hold on it, it will scroll the widget content one by
> one continually in about 800ms interval.
>
> Currently I implement the behavior by setOnClickListener() method for
> the click event.
> For touch & hold, I override dispatchTouchEvent() method and check for
> the holding status by checking the move shall be less than 10 pixels
> and event.getEventTime() - event.getDownTime() > 800ms for
> MotionEvent.ACTION_MOVE event.
>
> It works fine in G1 but not work in emulator.
> Is there any better solution?
> Thanks!
>
> On Mar 30, 11:17 am, Romain Guy  wrote:
>
>
>
> > They work the same.
>
> > > I have a class inherited from RelativeLayout and override public
> > > booleandispatchTouchEvent(MotionEvent event) method. After I touch &
> > > hold on the touch screen, in emulator I got MotionEvent.ACTION_DOWN
> > > event only. But in G1, I got MotionEvent.ACTION_DOWN first and then
> > > MotionEvent.ACTION_MOVE continuously, even if I try my best to hold
> > > still my finger tip.
>
> > That's simply because you cannot hold your finger still. With a mouse
> > cursor you have a 1px precision, with a finger, it's a lot more. The
> > way to "work around" this is simply to use thresholds when you try to
> > detect motion. For instance in a ScrollView or ListView a scroll
> > happens only if the finger has moved by 16 pixels or more. You can use
> > the same values as the framework by looking at the ViewConfiguration
> > class.
>
> > --
> > 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: Save an mp3 from a remote site

2009-03-31 Thread Streets Of Boston

This is just copying the file.
The question remains if you can play it or not... :=)

I have not looked into this at all, but DRM could prevent the mp3 from
playing.

On Mar 31, 9:55 am, iDeveloper  wrote:
> Thanks a ton. Didn't know android allowed saving to mp3 directly  
> unlike an iphone.
>
> On 31-Mar-09, at 5:32 PM, MrChaz wrote:
>
>
>
>
>
> > Sure,
> > Something like
>
> > //Where the file comes from
> > URL sourceURL = new URL("address");
> > URLConnection conn = sourceURL.openConnection();
>
> > InputStream inStream = sourceURL.openStream();
>
> > // Where the file is going to go
> > FileOutputStream outStream= new FileOutputStream("sdcard/file.mp3");
>
> > //a read buffer
> > byte[] bytes = new byte[20480];
>
> > //read the first chunk
> > int readBytes = file.read(bytes);
>
> > //read the rest
> > while (readBytes > 0){
> > //Write the buffered chunk to the file
> > outStream.write(bytes, 0, readBytes);
> > readBytes = file.read(bytes);
> > }
> > inStream.close();
> > outStream.close();
>
> > should do it.  I've typed that more or less by hand so it's missing
> > error checking etc.
>
> > On Mar 31, 8:10 am, idev  wrote:
> >> Hi
>
> >> I am able to stream an mp3 at real time on my android phone. I wanted
> >> to know if it is possible to save an mp3 file residing on a remote
> >> location to my SD card.
>
> >> Any heads up is greatly appreciated.
>
> >> 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: fullscreen rendering and MEMORY_TYPE_GPU?

2009-03-31 Thread Streets Of Boston

This means that the RenderThread has been paused or not yet been
started properly. Make sure you resume it when your activity's
onResume is called.
If you're using the code from example GLSurfaceView, removing the 'wait
()' will make your future customers quite angry: Their battery will be
drained quite quickly, with the RenderThread looping as fast as it can
all the time.

On Mar 30, 11:39 pm, Jint3i  wrote:
> Actually, if you're using GlSurfaceView check the following function:
> private void guardedRun() throws InterruptedException
>
> Specifically the section regarding wait:
>  if(needToWait())
>  {
>       while (needToWait())
>       {
> //          wait(); /* I commented out this line*/
>       }
>
> }
>
> It seems to hang in the wait function indefinitely on the first frame.
> Not sure why.
> Other than that if the screen is allowed to sleep or forced to sleep
> GL seems to lose the context.
> Hope that helps anybody else.
>
> On Mar 30, 10:12 pm, Jint3i  wrote:
>
>
>
> > To add, when I hit the back button to exit the application the last
> > frame of the scene is rendered properly but of course because I'm
> > exiting the application at that point it does me little good.
>
> > On Mar 30, 1:19 am, Jint3i  wrote:
>
> > > I would like to know why this doesn't work as well. I'm able to use
> > > the options mentioned by gigadude but the device fails to hide the
> > > notification and title bars and also fails to render the OpenGL scene
> > > when the MEMORY_TYPE_GPU flag is set with Window.requestFeature
>
> > > On Mar 6, 1:16 am, gigadude  wrote:
>
> > > > While trying to get a GLES demo running full screen I came across:
>
> > > >http://groups.google.com/group/android-developers/browse_thread/threa...
>
> > > > which is out of date, the correct code now seems to be:
>
> > > >         // We don't need a title either.
> > > >         requestWindowFeature(Window.FEATURE_NO_TITLE);
>
> > > >         // remove status bar
> > > >         int flags = WindowManager.LayoutParams.FLAG_FULLSCREEN;
> > > >         getWindow().setFlags(flags, flags);
>
> > > > I noticed there are some other interesting WindowManager.LayoutParams
> > > > flags:
>
> > > > WindowManager.LayoutParams.MEMORY_TYPE_GPU
> > > > WindowManager.LayoutParams.MEMORY_TYPE_PUSH_BUFFERS
> > > > WindowManager.LayoutParams.MEMORY_TYPE_HARDWARE
>
> > > > all but WindowManager.LayoutParams.MEMORY_TYPE_HARDWARE seem to
> > > > prevent
> > > > the app from drawing anything, is there a detailed description of what
> > > > said flags actually do?
>
> > > >   - Ed- 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: Photo Picker

2009-03-31 Thread Streets Of Boston

Did you debug it?
Did you get a null-pointer-exception?

(The code i gave you may have some issues: I just typed it in, without
using any IDE such as Eclipse. But it should give you a general idea
of what to do)

On Mar 30, 10:16 pm, Bobbie  wrote:
> I must have a bad phone or something...  Now the program force closes
> on me?  Here's what I have for "onActivityResult."
>
> Cursor cursor = getContentResolver().query(intent.getData(), null,
> null, null, null);
> int idx = cursor.getColumnIndex(ImageColumns.DATA);
> String fname = cursor.getString(idx);
>
> On Mar 30, 9:08 pm, Streets Of Boston  wrote:
>
>
>
> > int idx = cursor.getColumnIndex(ImageColumn.DATA);
> > String fname = cursor.getString(idx);
>
> > On Mar 30, 7:45 pm, Bobbie  wrote:
>
> > > Wow... It's so simple, but still got an error... I got this:
>
> > > Cursor cursor = getContentResolver().query(datatoget, null, null,
> > > null, null);
> > > String fname = cursor.getString(ImageColumns.DATA);
>
> > > It won't let me run the code... "getString" is underlined in red and
> > > it just wants me to change it to "getLong" but if I do that, it just
> > > tells me to change it back to "getString" again... Am I doing
> > > something wrong here, or am I that bad at coding Android?
>
> > > On Mar 30, 4:37 pm, Streets Of Boston  wrote:
>
> > > > This works as designed.
>
> > > > The getDataString() is the string of the content Uri that refers to
> > > > theimage.
> > > > If you want the physical filename, do a 'Cursor cursor =
> > > > getContentResolver().query(intent.getData(), null, null, null, null)'
> > > > and query the column ImageColumns.DATA on the returned cursor.
>
> > > > Thecursor.getString(ImageColumns.DATA) will return the physical file-
> > > > path on your SC-card.
>
> > > > On Mar 30, 3:58 pm, Bobbie  wrote:
>
> > > > > I am having issues with some "photo picker" code that I am using.  All
> > > > > of my pictures are stored on an SD card.  The SD card is mounted and I
> > > > > can take pictures no problem.  However, when I select a picture from
> > > > > the picker and output the location of the file, I should get:
>
> > > > > "/sdcard/dcim/Camera/FILENAME.jpg"
>
> > > > > But instead, I get:
>
> > > > > "content://media/external/images/media/7"
>
> > > > > Any ideas what could be causing this?  Here is my code, a button
> > > > > invokes the "takePic()" function:
>
> > > > > 
>
> > > > >     public void takePic() {
> > > > >         Intent photoPickerIntent = new Intent
> > > > > (Intent.ACTION_GET_CONTENT);
> > > > >         photoPickerIntent.setType("image/*");
> > > > >         startActivityForResult(photoPickerIntent, 1);
> > > > >     }
>
> > > > >     @Override
> > > > >     protected void onActivityResult(int i, int j, Intent intent) {
> > > > >         super.onActivityResult(i, j, intent);
>
> > > > >         textview.append(intent.getDataString());
> > > > >     }- 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: Photo Picker

2009-03-31 Thread Streets Of Boston

Do you have code in your 'onPause()' method of your activity.
If so, it looks like this code is blocking (never returning).

On Mar 31, 11:39 am, Bobbie  wrote:
> When I choose the image, this is what I get in the debug log:
>
> 03-31 11:34:36.055: INFO/ActivityManager(55): Displayed activity
> com.android.camera/.ImageGallery2: 2455 ms
> 03-31 11:34:39.525: VERBOSE/ImageGallery2(11143): /
> ImageBlockManager.onPause
> 03-31 11:34:49.519: WARN/ActivityManager(55): Launch timeout has
> expired, giving up wake lock!
>
> On Mar 31, 10:24 am, Streets Of Boston 
> wrote:
>
>
>
> > Did you debug it?
> > Did you get a null-pointer-exception?
>
> > (The code i gave you may have some issues: I just typed it in, without
> > using any IDE such as Eclipse. But it should give you a general idea
> > of what to do)
>
> > On Mar 30, 10:16 pm, Bobbie  wrote:
>
> > > I must have a bad phone or something...  Now the program force closes
> > > on me?  Here's what I have for "onActivityResult."
>
> > > Cursor cursor = getContentResolver().query(intent.getData(), null,
> > > null, null, null);
> > > int idx = cursor.getColumnIndex(ImageColumns.DATA);
> > > String fname = cursor.getString(idx);
>
> > > On Mar 30, 9:08 pm, Streets Of Boston  wrote:
>
> > > > int idx = cursor.getColumnIndex(ImageColumn.DATA);
> > > > String fname = cursor.getString(idx);
>
> > > > On Mar 30, 7:45 pm, Bobbie  wrote:
>
> > > > > Wow... It's so simple, but still got an error... I got this:
>
> > > > > Cursor cursor = getContentResolver().query(datatoget, null, null,
> > > > > null, null);
> > > > > String fname = cursor.getString(ImageColumns.DATA);
>
> > > > > It won't let me run the code... "getString" is underlined in red and
> > > > > it just wants me to change it to "getLong" but if I do that, it just
> > > > > tells me to change it back to "getString" again... Am I doing
> > > > > something wrong here, or am I that bad at coding Android?
>
> > > > > On Mar 30, 4:37 pm, Streets Of Boston  wrote:
>
> > > > > > This works as designed.
>
> > > > > > The getDataString() is the string of the content Uri that refers to
> > > > > > theimage.
> > > > > > If you want the physical filename, do a 'Cursor cursor =
> > > > > > getContentResolver().query(intent.getData(), null, null, null, 
> > > > > > null)'
> > > > > > and query the column ImageColumns.DATA on the returned cursor.
>
> > > > > > Thecursor.getString(ImageColumns.DATA) will return the physical 
> > > > > > file-
> > > > > > path on your SC-card.
>
> > > > > > On Mar 30, 3:58 pm, Bobbie  wrote:
>
> > > > > > > I am having issues with some "photo picker" code that I am using. 
> > > > > > >  All
> > > > > > > of my pictures are stored on an SD card.  The SD card is mounted 
> > > > > > > and I
> > > > > > > can take pictures no problem.  However, when I select a picture 
> > > > > > > from
> > > > > > > the picker and output the location of the file, I should get:
>
> > > > > > > "/sdcard/dcim/Camera/FILENAME.jpg"
>
> > > > > > > But instead, I get:
>
> > > > > > > "content://media/external/images/media/7"
>
> > > > > > > Any ideas what could be causing this?  Here is my code, a button
> > > > > > > invokes the "takePic()" function:
>
> > > > > > > 
>
> > > > > > >     public void takePic() {
> > > > > > >         Intent photoPickerIntent = new Intent
> > > > > > > (Intent.ACTION_GET_CONTENT);
> > > > > > >         photoPickerIntent.setType("image/*");
> > > > > > >         startActivityForResult(photoPickerIntent, 1);
> > > > > > >     }
>
> > > > > > >     @Override
> > > > > > >     protected void onActivityResult(int i, int j, Intent intent) {
> > > > > > >         super.onActivityResult(i, j, intent);
>
> > > > > > >         textview.append(intent.getDataString());
> > > > > > >     }- Hide quoted text -
>
> > > > > - Show quoted text -- 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: Troubles with SurfaceView's surfaceCreated/Destroyed

2009-03-31 Thread Streets Of Boston

I haven't read through all your code, but you should not call
thread.start() in your surfaceCreated method.
Instead, create and start your thread asap and have it paused when
necessary.

When 'onPause()' or when surfaceDestroyed is called, pause your thread
(CupThread).
When 'onResume()' or surfaceCreated is called, resume your thread.
Only stop and terminate your thread when 'onDestroy()' is called.

Take a look at the OpenGL Cube example from the API demos.
I think the class is called RenderThread.
It creates and starts the thread when the activity is created, stops
it when the activity is destroyed.
It pauses the thread on surfaceDestroyed, it resumes it on
surfaceCreated. This also makes sure that your CupThread does not eat
CPU-cycles when your app moves to the background. If you don't pause
the thread when your app is in the background, your phone will eat a
lot of CPU cycles basically doing nothing --> battery drain -->
unhappy customers.

Pausing and resuming threads should be done using synchronized blocks,
wait() statements and notify() statements.

On Mar 31, 10:35 pm, kbeal10  wrote:
> This is where the thread variable is declared.
>
>         private Context mContext;
>         /** The thread that actually draws teh animations. */
>         private CupThread thread;
>         private TextView mStatusText;
>
>         public CupView(Context context, AttributeSet attrs){
>                 super(context,attrs);
>
>                 //register our interest in hearing about changes to our 
> surface
>                 SurfaceHolder holder = getHolder();
>                 holder.addCallback(this);
>                 mContext = context;
>                 setFocusable(true);
>                 // create thread only; it's started in surfaceCreated()
>         }
>
> I'm sorry for the confusion about "exiting" in rollDice(). Indeed, I
> am not exiting here, but starting another Activity.
>
> I believe, as you mentioned, this is a case where the original
> activity is still there, and then being re-displayed. However,
> CupView's surfaceDestroyed() is called when I start the other Activity
> in rollDice(). This means that when the Activity holding CupView
> resumes I should be able to create a new thread and start it. I am
> aware you can't call start() on the same thread twice, but since
> surfaceDestroyed() is called that thread is terminated with the .join
> () call. A new thread is then created and started in surfaceCreated().
>
> I will post the full code to both the Activity holding the CupView, as
> well as the CupView in the following post.
>
> On Mar 31, 10:17 pm, Dianne Hackborn  wrote:
>
>
>
> > I don't think you've included enough code.  Where is this 'thread' variable
> > defined?  Where do you clear it after finishing the thread?
>
> > I am also confused by the comment saying you "exiting" the activity in
> > rollDice -- you aren't calling finish, you are just starting another
> > activity, so the original activity is still there, and its window will just
> > be re-displayed when it is shown again.
>
> > The only thing I can think of is that you aren't handling the case where
> > your window is hidden and then shown again, causing surfaceCreated to be
> > called a second time on the same SurfaceView, but again there isn't enough
> > code here to really tell what is happening.
>
> > Also you do know that you can only call Thread.start() once on a particular
> > thread object, right?
>
> >http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#start()
>
> > On Tue, Mar 31, 2009 at 6:46 PM, kbeal10  wrote:
>
> > > I'm writing a game using two different SurfaceView's (RollView and
> > > CupView) in two different activities. Both SurfaceView's heavily
> > > resemble the LunarLander demo.
>
> > > The RollView SurfaceView is working fine. When leaving the Activity,
> > > RollView's surfaceDestroyed() is called, killing the thread. If I then
> > > re-enter that Activity, the thread is recreated in RollView's
> > > constructor and then started in surfaceCreated().
>
> > > However in CupView the thread never seems to go away. SurfaceDestroyed
> > > is being called, but upon reentering the Activity I get the following
> > > error:
>
> > > java.lang.IllegalThreadStateException: Thread already started.
>
> > > This thrown is in surfaceCreated() at the thread.start() call.
>
> > > The difference between the two, and apparently the problem, is that in
> > > the RollView Activity I call finish() when done. When leaving the
> > > CupView Activity, I'm doing a startActivityForResult
> > > (i,ClassWithRollView.class);..not calling finish().
>
> > > This is because after leaving the RollView, I want to return to the
> > > CupView. Below is relevant code:
>
> > >   /** This where I'm exiting the Activity with the CupView **/
> > >    private void rollDice(){
> > >        if (mMode==IN_PROGRESS){
> > >                // create a new intent for the roll dice view
> > >                Intent i = new Intent(t

[android-developers] Re: How to make a ListView adapt to dynamic element sizes?

2009-04-01 Thread Streets Of Boston

If your list-view uses a (list-)adapter (or a subclass of this), did
you try to call notifyDataSetInvalidated() on the adapter?
This will cause your adapter's getView(int position, View convertView,
ViewGroup parent) to be called again and you can handle your changed
list-item in there.

On Apr 1, 5:24 am, matthias  wrote:
> Well, I found a really ugly workaround. That workaround is based on my
> observation that the problem described does only occur if the
> ListView's layout height is set to WRAP_CONTENT. So, since I use a
> custom list adapter, I now call listView.getLayoutParams().height =
> LayoutParams.FILL_PARENT whenever a text view is about to be
> expanded... the reason I do not statically set its height to
> FILL_PARENT is because then it will draw line separators below the
> last element, which looks ugly if it doesn't expand to the bottom of
> the screen.
>
> It works... but, yuck!
--~--~-~--~~~---~--~~
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: photo picker Uri issue

2009-04-01 Thread Streets Of Boston

I can't tell.

Debug your code and see which statement throws an exception and see
what exception is thrown and note the values of the variables (are
some set to null when they shouldn't, for example).

On Apr 1, 9:35 am, Bobbie  wrote:
> I tried this code, and every time it force closes.  The Uri object
> gives me the Uri, but I can't see why it's failing... Please help!!!
>
> Uri photoUri = intent.getData();
> Cursor cursor = getContentResolver().query(photoUri, new String[]
> {MediaStore.Images.ImageColumns.DATA}, null, null, null);
> String absoluteFilePath = cursor.getString(0);
>
> On Mar 26, 8:57 am, beachy  wrote:
>
>
>
> > cheers, did not know that about Drawables will use Bitmaps then.
>
> > Thanks,
> > Greg.
>
> > On Mar 25, 3:23 pm, Streets Of Boston  wrote:
>
> > > This Uri is the logical (not physical) path used by theimagecontent
> > > provider.
> > > If you want to get the physical path to the actual file on the SD-
> > > card, query this Uri:
>
> > >   Cursor cursor = query(photoUri, new String[]
> > > {MediaStore.Images.ImageColumns.DATA}, null, null, null);
> > >   String absoluteFilePath = cursor.getString(0);
>
> > > Now, absoluteFilePath is the physical path to yourimage, which you
> > > can use in Drawable.createFromPath
>
> > > Question: Why don't you create a Bitmap instead?
>
> > >    ...
> > >    InputStream is = getContentResolver().openInputStream(photoUri);
> > >    Bitmap bm = BitmapFactory.decodeStream(is);
> > >    ...
> > >    is.close();
>
> > > I ask this, because it is safer to cache Bitmaps instead of Drawables.
> > > If you cache Drawables, you run the risk of memory leaks. Drawables
> > > have handles to your activity and when your activity gets destroyed
> > > while your Drawables are still cached, your activiy will never be
> > > garbage collected --> memory leak.
> > > Bitmaps don't have this problem. They are basically byte-arrays with
> > > some behavior :).
>
> > > On Mar 25, 3:15 am, beachy  wrote:
>
> > > > In some code I call this;
> > > >                                         Intent photoPickerIntent = new 
> > > > Intent
> > > > (Intent.ACTION_PICK);
> > > >                                     
> > > > photoPickerIntent.setType("image/*");
> > > >                                     
> > > > startActivityForResult(photoPickerIntent,
> > > > 1);
>
> > > > then implement this method
>
> > > > protected void onActivityResult(int requestCode, int resultCode,
> > > > Intent intent)
> > > >         {
> > > >              super.onActivityResult(requestCode, resultCode, intent);
>
> > > >              if (resultCode == RESULT_OK)
> > > >              {
> > > >                      Uri photoUri = intent.getData();
> > > >                      Log.d(TAG, "should be adding a photo");
> > > >                      if (photoUri != null)
> > > >                      {
>
> > > >                              Log.d(TAG, "photo uri is not blank");
> > > >                                  // do something with the content Uri
> > > >                              //TODO figure out why this does not work!!
> > > >                              Log.d(TAG, "the photo URI is " + 
> > > > photoUri.getPath());
> > > >                          Drawable thePic = Drawable.createFromPath
> > > > (photoUri.getPath());
> > > >                          //thePic is Null
> > > >                                      if(thePic != null){
> > > >                              Log.d(TAG, "the pic has loaded");
> > > >                                  myRecipe.addPic(thePic);
> > > >                                  ((RecipeAdapter)myListView.getAdapter
> > > > ()).notifyDataSetChanged();
>
> > > >                          }
> > > >                      }
> > > >              }
> > > >         }
>
> > > > trying to get aimageand load it in to a drawable object. The Uri
> > > > that is returned seems logical
>
> > > > 03-25 08:12:58.554: DEBUG/ConvertScaleScreen(174): the photo URI is /
> > > > external/images/media/1
>
> > > > but when i start up a shell with adb the file location or even the
> > > > root drive does not exitst, am I missing something here? should the be
> > > > a symbolic link on the file system?- 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: Android Physics Engine

2009-04-01 Thread Streets Of Boston
so, Phys2D will not run worth a damn on Android.  I tried it and I
> > > > even went through some heavy performance tuning.  Garbage collection
> > > > is the major issue even after all I did.  I seriously doubt JBox2D
> > > > will run well either.  I'll stick to what I said earlier, a ground-up
> > > > solution by someone smarter than me is probably required.
>
> > > > On Mar 31, 9:49 am, "admin.androidsl...@googlemail.com"
>
> > > >  wrote:
> > > > > Not tried but if you can provide us with some example source code or
> > > > > put something on the market, I'm sure we could take a look.
>
> > > > > G1 performance is significantly faster than emulator, but there are
> > > > > limitations.
>
> > > > > Particularly with garbage collection and memory allocation on code
> > > > > that gets run continuously in loops, so I don't know how optimised
> > > > > these physics engines are for this purpose.
>
> > > > > Would be interesting to find out though.
>
> > > > > On Mar 31, 12:52 pm, mscwd01  wrote:
>
> > > > > > Oh I forgot to re-ask...
>
> > > > > > "Has anyone tested Phys2D or JBox2D on an actual device to see if 
> > > > > > they
> > > > > > run better than on the emulator?
>
> > > > > > I have a feeling the performance will better on a G1 than the 
> > > > > > emulator
> > > > > > for some reason!
>
> > > > > > On Mar 31, 12:51 pm, mscwd01  wrote:
>
> > > > > > > I did take a look at Simpull, however the demo application failed 
> > > > > > > to
> > > > > > > run as it relied on some library which wasn't supplied or 
> > > > > > > referenced
> > > > > > > to - I just got annoyed after spending two days failing to get 
> > > > > > > Phys2D
> > > > > > > and JBox2D to work in Android and didn't bother trying to work 
> > > > > > > out the
> > > > > > > problems!
>
> > > > > > > I might give it another look though...
>
> > > > > > > On Mar 30, 10:41 pm, Streets Of Boston 
> > > > > > > wrote:
>
> > > > > > > > I wonder how well this one works on Android:
>
> > > > > > > >  http://code.google.com/p/simpull/
>
> > > > > > > > -- Anton Spaans
>
> > > > > > > > On Mar 30, 4:58 pm, Anton  wrote:
>
> > > > > > > > >     I have a simple 2D physics engine written and running.  
> > > > > > > > > It uses
> > > > > > > > > the now famous Jacobson physics tricks (Verlet integration 
> > > > > > > > > and hard
> > > > > > > > > constraints).  I can manage 40 balls on the screen, with fill 
> > > > > > > > > n^2
> > > > > > > > > interaction between balls.  I am working on spatial data 
> > > > > > > > > structure
> > > > > > > > > optimizations now to improve the computational complexity of 
> > > > > > > > > the
> > > > > > > > > collision detection code.  I run the constraint update loop 
> > > > > > > > > five times
> > > > > > > > > per frame and get 30 frames per second.  Once the engine is 
> > > > > > > > > up and
> > > > > > > > > running there are no memory allocations done in my program.  
> > > > > > > > > And once
> > > > > > > > > the system settles down from the app launch there are very 
> > > > > > > > > few GC
> > > > > > > > > events from other programs.  Though they do still happen.  
> > > > > > > > > Viewing
> > > > > > > > > LogCat I see a GC every 10 or 20 seconds because of some 
> > > > > > > > > background
> > > > > > > > > application.  But between those events I get a consistent 
> > > > > > > > > frame rate.
> > > > > > > > > I am using OpenGL for my rendering.
>
> > > > > > > > >     -Anton
>
> > > > > > > > > On Mar 30, 1:14 pm, mscwd01  wrote:
>
> > > > > > > > > > Does anyone know of, or have implemented, a physics engine 
> > > > > > > > > > which runs
> > > > > > > > > > smoothly in Android?
>
> > > > > > > > > > I have spent the last couple of days trying Phys2D and 
> > > > > > > > > > JBox2D, however
> > > > > > > > > > both perform very poorly - I am struggling to get even a 
> > > > > > > > > > few objects
> > > > > > > > > > to simulate smoothly as frequent garbage collection spoils 
> > > > > > > > > > it.
>
> > > > > > > > > > One question I do have is will these run smoother on an 
> > > > > > > > > > actual G1
> > > > > > > > > > device or is the performance of the emulator accurate?
>
> > > > > > > > > > Thanks- 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: Troubles with SurfaceView's surfaceCreated/Destroyed

2009-04-01 Thread Streets Of Boston

Do *not* use volatile variables. They are not guaranteed to be atomic.
It's just a compiler hint.

Instead, use synchronized blocks:

class MyThread extends Thread {
  boolean mPaused;
  boolean mStopped;

  public void run() {
...
...
mStopped = false;
mPaused = true or false, depends on your application.
while (!mStopped) {
  if (waitForResume())
break;

  // do your thing.
  ...
}
  }

  public void stopThread() {
syncrhonized(this) {
  mPaused = false;
  mStopped = true;
  this.notify();
}
// optionally, code an extra 'join()' statement if the caller
needs
// to wait until the thread has completely finished.
  }

  public void pauseThread() {
syncrhonized(this) {
  mPaused = true;
  this.notify();
}
  }

  public void resumeThread() {
syncrhonized(this) {
  mPaused = false;
  this.notify();
}
  }

  private boolean waitForResume() {
synchronized(this) {
  if (mStopped)
return false;

  while (mPaused) {
this.wait();
  }

  if (mStopped)
return false;
}
  }
  ...
  ...
}


Then code that needs to control your thread, just call
myThread.pauseThread() or myThread.resumeThread() and stops the thread
entirely by calling myThread.stopThread();

Note: you could replace 'this' with another object to use for
synchronization.

On Apr 1, 10:06 am, Tom  wrote:
> Try this:
>
> Create a set of volatile variables (toPause, isPaused, toStop,
> isStopped).
>
> Outside the thread, in the methods mentioned previously, set or clear
> the appropriate variables.
> Inside the thread, be checking the appropriate variables to determine
> if the thread needs to be paused or stopped.
>
> Put the use of the variable within synchronized blocks.
> Use wait and notify to avoid busy polling.
--~--~-~--~~~---~--~~
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: Scroll and drag a TileView widget around by finger / touch

2009-04-01 Thread Streets Of Boston

What about using a ScrollView as your container view?:

LinearLayout
  |-->ScrollView
|--> SkyView


On Apr 1, 11:49 am, acrosser  wrote:
> Surely this hasn't stumped the group of brilliant Android
> developers! :-) Is there any tutorial or reference page someone can
> point me to?
>
> On Mar 31, 9:10 am, acrosser  wrote:
>
>
>
> > In the Android API examples there is a Snake game. This game uses a
> > class
> > called SnakeView, which inherits from TileView.
>
> > I am doing something very similar to this. I am inheriting from
> > TileView to create a class (SkyView), which will become a square board
> > for a board game (similar to the board for Checkers).
>
> > However, I would like for my game board to be 400x400 pixels in size,
> > which will be bigger than the screens of some Android devices (such as
> > the G1). And I would like for the user to be able to freely scroll and
> > drag the board around with their finger (both horizontal and vertical
> > scrolling/dragging).
>
> > Can someone please point me in the correct direction for implementing
> > this? The board must be no smaller than 400x400px in size. And however
> > much of the board that can be displayed at once on the screen, should
> > be displayed
> > at once.
>
> > Should I wrap my SkyView widget in an AbsoluteLayout and use
> > Scrollbars? If so, what Scrollbar properties to I need to use? I
> > played around with Scrollbars in both directions but couldn't get it
> > to work. Is there another view layout I should put it inside? Code
> > examples would be nice! Thanks for the help. I am at a loss with this
> > one.- 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: Static Variable Instantiation

2009-04-01 Thread Streets Of Boston

Short answer:
Don't use static variables :-)

Somewhat longer answer:
If sub-activities need to access some data held by my main activity, i
usually do create one static variable:

public MyActivity extends Activity {
  >> public static final MyActivity ACTIVE_INSTANCE; <<

  protected void onCreate(Bundle b) {
super.onCreate(b);
ACTIVE_INSTANCE = this;
...
...
  }

  protected void onDestroy() {
...
...
ACTIVE_INSTANCE = null;
super.onDestroy();
  }
  ...
  ...
}

Then sub-activities (and other classes) can access MyActivity's
instance variables/methods through MyActivity.ACTIVE_INSTANCE.

Still, though, try to avoid statics (unless they're final) as much as
possible. Use parameters/Intents to pass data.

On Apr 1, 1:37 am, wacamoe  wrote:
> Hello all,
>   I have noticed in my application(s) that after a call to
> Activity.finish() that the static variables that I declared in my
> classes still hold the values that they were changed to during the
> activity's life cycle. Upon the re-launch of the activity, the program
> does not re-instantiate the variables as declared or set them to the
> default java behavior. Is there something that I can do to cause this
> to happen, other than re-setting every static variable in my
> application?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Some of the strange JAVA syntax - android specifics?

2009-04-01 Thread Streets Of Boston

@Override is a so-called annotation.
It does not generate any byte-code/runnable-code.
It just tells the compiler that the method below it is an override of
its super-class' method.
If your super-class changes its signature of onDraw, your compiler
will warn you about the fact that your method (in this case onDraw) no
longer overloads the super-class version of onDraw.

Try it your self: change 'protected void onDraw(Canvas canvas)' into
'protected boolean onDraw(Canvas canvas)' and do a 'return true;' at
the bottom of this method. You'll get a compiler error.

You can leave @Override out. It's just a safeguard.

synchronized:
I'd suggest your starting reading about Java Synchronization.
'synchronized' blocks prevent multiple threads from executing the same
block of code at the same time. They are used to synchronize access to
methods and instance-variables and avoid race-conditions. Careless use
of 'synchronized' block, however, could cause dead-locks.


E.g.
public synchronized boolean isPaused() {
  return mPaused;
}

public synchronized void pause() {
  mPaused = true;
}

This makes sure that mPaused is always read and/or updated by one
thread at a time. If thread-1 is inside isPaused() and thread-2 is
trying to call isPaused() or pause(), thread-2 waits until thread-1
exits isPaused().

A thread entering a synchronized block, obtains a lock on the object
specified (in above example, the object is 'this'). Any other thread
trying to do the same has to wait.
A thread exiting a synchronized block, releases the lock on the
object. Any waiting thread will now wake up and try to obtain the
lock.

BTW:
public synchronized void someMethod() {
  ...
}

is the same as
public synchronized void someMethod() {
  synchronized(this) {
...
  }
}

and
public static synchronized void someStaticMethod() {
  ...
}

is the same as
public static synchronized void someStaticMethod() {
  synchronized(MyClass.class) {
...
  }
}

On Apr 1, 3:29 am, Bin Chen  wrote:
> I am a C programmer before, and I am looking into android source code
> right now, some JAVA syntax is confusing, I am not sure whether or not
> it's android related, see:
>
>         @Override
>         protected void onDraw(Canvas canvas) {
>             synchronized (this) {
>                 if (mBitmap != null) {
>                     final Paint paint = mPaint;
>                     final Path path = mPath;
>                     final int outer = 0xFFC0C0C0;
>                     final int inner = 0xFFff7010;
>
> 1) What's the meaning of Override? Is it ommitable?
> 2) What does the "synchronized" mean?
>
> Thanks.
> Bin
--~--~-~--~~~---~--~~
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: photo picker Uri issue

2009-04-01 Thread Streets Of Boston

You have to call moveToNext or moveToPosition first before you can use
the cursor.

On Apr 1, 2:13 pm, Bobbie  wrote:
> The exception is:
>
> 04-01 14:09:30.274: ERROR/AndroidRuntime(719):
> java.lang.RuntimeException: Failure delivering result ResultInfo
> {who=null, request=1, result=-1, data=Intent { data=content://media/
> external/images/media/7 }} to activity {com.app.name/
> com.app.name.activity}:
> android.database.CursorIndexOutOfBoundsException: Index -1 requested,
> with a size of 1
>
> What does that mean?
>
> On Apr 1, 9:44 am, Streets Of Boston  wrote:
>
>
>
> > I can't tell.
>
> > Debug your code and see which statement throws an exception and see
> > what exception is thrown and note the values of the variables (are
> > some set to null when they shouldn't, for example).
>
> > On Apr 1, 9:35 am, Bobbie  wrote:
>
> > > I tried this code, and every time it force closes.  The Uri object
> > > gives me the Uri, but I can't see why it's failing... Please help!!!
>
> > > Uri photoUri = intent.getData();
> > > Cursor cursor = getContentResolver().query(photoUri, new String[]
> > > {MediaStore.Images.ImageColumns.DATA}, null, null, null);
> > > String absoluteFilePath = cursor.getString(0);
>
> > > On Mar 26, 8:57 am, beachy  wrote:
>
> > > > cheers, did not know that about Drawables will use Bitmaps then.
>
> > > > Thanks,
> > > > Greg.
>
> > > > On Mar 25, 3:23 pm, Streets Of Boston  wrote:
>
> > > > > This Uri is the logical (not physical) path used by theimagecontent
> > > > > provider.
> > > > > If you want to get the physical path to the actual file on the SD-
> > > > > card, query this Uri:
>
> > > > >   Cursor cursor = query(photoUri, new String[]
> > > > > {MediaStore.Images.ImageColumns.DATA}, null, null, null);
> > > > >   String absoluteFilePath = cursor.getString(0);
>
> > > > > Now, absoluteFilePath is the physical path to yourimage, which you
> > > > > can use in Drawable.createFromPath
>
> > > > > Question: Why don't you create a Bitmap instead?
>
> > > > >    ...
> > > > >    InputStream is = getContentResolver().openInputStream(photoUri);
> > > > >    Bitmap bm = BitmapFactory.decodeStream(is);
> > > > >    ...
> > > > >    is.close();
>
> > > > > I ask this, because it is safer to cache Bitmaps instead of Drawables.
> > > > > If you cache Drawables, you run the risk of memory leaks. Drawables
> > > > > have handles to your activity and when your activity gets destroyed
> > > > > while your Drawables are still cached, your activiy will never be
> > > > > garbage collected --> memory leak.
> > > > > Bitmaps don't have this problem. They are basically byte-arrays with
> > > > > some behavior :).
>
> > > > > On Mar 25, 3:15 am, beachy  wrote:
>
> > > > > > In some code I call this;
> > > > > >                                         Intent photoPickerIntent = 
> > > > > > new Intent
> > > > > > (Intent.ACTION_PICK);
> > > > > >                                     
> > > > > > photoPickerIntent.setType("image/*");
> > > > > >                                     
> > > > > > startActivityForResult(photoPickerIntent,
> > > > > > 1);
>
> > > > > > then implement this method
>
> > > > > > protected void onActivityResult(int requestCode, int resultCode,
> > > > > > Intent intent)
> > > > > >         {
> > > > > >              super.onActivityResult(requestCode, resultCode, 
> > > > > > intent);
>
> > > > > >              if (resultCode == RESULT_OK)
> > > > > >              {
> > > > > >                      Uri photoUri = intent.getData();
> > > > > >                      Log.d(TAG, "should be adding a photo");
> > > > > >                      if (photoUri != null)
> > > > > >                      {
>
> > > > > >                              Log.d(TAG, "photo uri is not blank");
> > > > > >                                  // do something with the content 
> > > > > > Uri
> > > > > >        

  1   2   3   4   5   6   7   8   9   10   >