[android-developers] Re: How many threads can be created or how to avoid thread leak
This almost sounds like it should be a Service. The thread will only run when you're Activity is running (basically) and isn't guaranteed to be kept around once the Activity is cleaned up. You may want a Service running that can handle this and then you'll have much more control over it. Will you be handing incoming messages the same way? http://code.google.com/android/reference/android/app/Service.html On Oct 3, 4:03 am, hackbod <[EMAIL PROTECTED]> wrote: > Just use HandlerThread to have a single thread sitting there > processing messages that you send to it. Even better, create the > thread in onStart() and quit it in onStop(). > > On Oct 2, 9:49 pm, Jo <[EMAIL PROTECTED]> wrote: > > > HI, > > > I am developing a chat application. Everytime a user clicks a button a > > thread needs to handle it as text message needs to be sent over > > network. so, I am creating a new thread each time when the user clicks > > on button. I wish only 1 thread handles all the messages to be sent. > > But, resume/suspend/stop are all deprecated. > > > is there a way to do it. > > > currently, I am doing it like the following. > > > > > View.OnClickListener showChat = new View.OnClickListener() { > > @Override > > public void onClick(View v) { > > > t_send = new Thread() { > > public void run() { > > recv = false; > > m_mychat = > > doExpensiveSend(); > > > > > mHandler2.post(mUpdateResults2); > > } > > }; > > t_send.start(); > > > } > > }; > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: save image in Database
I handled this by saving the image to the ContentProvider android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI and then saving the created URI to the database along with my item. An example of how to do this can be found here: http://code.google.com/p/apps-for-android/source/browse/trunk/Photostream/src/com/google/android/photostream/ViewPhotoActivity.java On Oct 2, 11:59 am, "Jake Maui" <[EMAIL PROTECTED]> wrote: > Try smaller files. I've been able to read/write to my sdcard but have run > into a 250 K limit. > The emulator gives me an EOF -1 for bigger files for some reason. > > On Thu, Oct 2, 2008 at 10:28 AM, Nemat <[EMAIL PROTECTED]> wrote: > > > ok.I have tried to save image in a file.But I couldnt do > > that.I have to do it for SDK-1.0. > > So plz give me any link to work on file connection. > > > On Oct 2, 6:41 am, "Andrew Stadler" <[EMAIL PROTECTED]> wrote: > > > Are you sure that you really want to do this? > > > > It might make more sense tosaveeachimageas a file. If necessary, > > > you could use adatabaseto storeimagemetadata (depending on the > > > needs of your application). > > > > On Tue, Sep 30, 2008 at 7:02 AM, Nemat <[EMAIL PROTECTED]> wrote: > > > > > Hi Frnds. > > > > > I have tosaveanimageindatabase.How can it be possible in > > > > SDK-1.0?? > > > > > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: ImageButton caching images when using Uri
Sorry to talk t myself on this thread, but in case anyone else runs into this problem in 1.0R1, the current workaround is to set the ImageURI to null and then back to the URI after saving the image. http://code.google.com/p/android/issues/detail?id=925 On Oct 1, 1:02 pm, Joe Erickson <[EMAIL PROTECTED]> wrote: > Found the link to the bug tracker. So, nevermind. It was on the > front page. :) > > On Oct 1, 12:16 pm, Joe Erickson <[EMAIL PROTECTED]> wrote: > > > No one else has seen anything like this? Is there a way to enter this > > as a bug against the Android codebase? I haven't actually seen the > > open source part of this yet (I'd actually try and fix it if it was > > out there already). > > > On Sep 29, 11:09 am, Joe Erickson <[EMAIL PROTECTED]> wrote: > > > > I'm seeing some caching problems when using anImageButtonwith a Uri > > > and I'm not sure if there's a flag that needs set somewhere or not. > > > > I'm using the button to add an icon to an item in one of my > > > applications, exactly like it's being used for the Contact application > > > (which I don't think the source is available for). I'm using the CROP > > > trick seen in this > > > application:http://code.google.com/p/apps-for-android/source/browse/trunk/Photost... > > > > Specifically, I'm calling the image picker and then the crop like so: > > > > protected OnClickListener cmdIconListener = new OnClickListener() { > > > // @Override > > > public void onClick(View arg0) { > > > Intent i = new > > > Intent("android.intent.action.GET_CONTENT"); > > > i.setType("image/*"); > > > startActivityForResult(i, AddTea.ADD_ICON); > > > } > > > > }; > > > > protected void onActivityResult(int requestCode, int resultCode, > > > Intent data){ > > > // See which child activity is calling us back. > > > switch (requestCode) { > > > case AddTea.ADD_ICON: > > > // This is the standard resultCode that is sent back if the > > > // activity crashed or didn't doesn't supply an explicit > > > result. > > > if (resultCode != RESULT_CANCELED){ > > > Intent i = new Intent("com.android.camera.action.CROP"); > > > i.setClassName("com.android.camera", > > > "com.android.camera.CropImage"); > > > i.setData(data.getData()); > > > Log.d(TAG, "path: " + data.getData().getPath()); > > > i.putExtra("noFaceDetection", true); > > > i.putExtra("outputX", iconWidth); > > > i.putExtra("outputY", iconHeight); > > > i.putExtra("aspectX", iconWidth); > > > i.putExtra("aspectY", iconHeight); > > > i.putExtra("scale", true); > > > > if(iconUri == null){ > > > ContentValues values = new ContentValues(); > > > > values.put(android.provider.MediaStore.Images.Media.TITLE, name + " > > > Icon"); > > > > values.put(android.provider.MediaStore.Images.Media.BUCKET_ID, > > > "STeaP_Tea_Timer_Icons"); > > > > values.put(android.provider.MediaStore.Images.Media.BUCKET_DISPLAY_NAME, > > > "STeaP Tea Timer Icons"); > > > iconUri = > > > getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, > > > values).toString(); > > > } > > > i.putExtra("output", Uri.parse(iconUri)); > > > startActivityForResult(i, CROP_ICON); > > > } > > > break; > > > case AddTea.CROP_ICON: > > > if (resultCode != RESULT_CANCELED){ > > > Log.d(TAG, "Data String: " + iconUri); > > > showIconButton(iconUri); > > > } > > > default: > > > break; > > > } > > > > } > > > > protected void showIconButton(String iconUri){ > > > if(iconUri != null){ > > > ImageButtoniconField = (ImageButton) > > > findViewById(R.id.iconButton); > > > Log.d(TAG, "iconUri: " + iconUri); > > > iconField.setImageURI(Uri.parse(iconUri)); > > > iconField.inv
[android-developers] Re: ImageButton caching images when using Uri
Found the link to the bug tracker. So, nevermind. It was on the front page. :) On Oct 1, 12:16 pm, Joe Erickson <[EMAIL PROTECTED]> wrote: > No one else has seen anything like this? Is there a way to enter this > as a bug against the Android codebase? I haven't actually seen the > open source part of this yet (I'd actually try and fix it if it was > out there already). > > On Sep 29, 11:09 am, Joe Erickson <[EMAIL PROTECTED]> wrote: > > > I'm seeing some caching problems when using anImageButtonwith a Uri > > and I'm not sure if there's a flag that needs set somewhere or not. > > > I'm using the button to add an icon to an item in one of my > > applications, exactly like it's being used for the Contact application > > (which I don't think the source is available for). I'm using the CROP > > trick seen in this > > application:http://code.google.com/p/apps-for-android/source/browse/trunk/Photost... > > > Specifically, I'm calling the image picker and then the crop like so: > > > protected OnClickListener cmdIconListener = new OnClickListener() { > > // @Override > > public void onClick(View arg0) { > > Intent i = new > > Intent("android.intent.action.GET_CONTENT"); > > i.setType("image/*"); > > startActivityForResult(i, AddTea.ADD_ICON); > > } > > > }; > > > protected void onActivityResult(int requestCode, int resultCode, > > Intent data){ > > // See which child activity is calling us back. > > switch (requestCode) { > > case AddTea.ADD_ICON: > > // This is the standard resultCode that is sent back if the > > // activity crashed or didn't doesn't supply an explicit > > result. > > if (resultCode != RESULT_CANCELED){ > > Intent i = new Intent("com.android.camera.action.CROP"); > > i.setClassName("com.android.camera", > > "com.android.camera.CropImage"); > > i.setData(data.getData()); > > Log.d(TAG, "path: " + data.getData().getPath()); > > i.putExtra("noFaceDetection", true); > > i.putExtra("outputX", iconWidth); > > i.putExtra("outputY", iconHeight); > > i.putExtra("aspectX", iconWidth); > > i.putExtra("aspectY", iconHeight); > > i.putExtra("scale", true); > > > if(iconUri == null){ > > ContentValues values = new ContentValues(); > > > values.put(android.provider.MediaStore.Images.Media.TITLE, name + " > > Icon"); > > > values.put(android.provider.MediaStore.Images.Media.BUCKET_ID, > > "STeaP_Tea_Timer_Icons"); > > > values.put(android.provider.MediaStore.Images.Media.BUCKET_DISPLAY_NAME, > > "STeaP Tea Timer Icons"); > > iconUri = > > getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, > > values).toString(); > > } > > i.putExtra("output", Uri.parse(iconUri)); > > startActivityForResult(i, CROP_ICON); > > } > > break; > > case AddTea.CROP_ICON: > > if (resultCode != RESULT_CANCELED){ > > Log.d(TAG, "Data String: " + iconUri); > > showIconButton(iconUri); > > } > > default: > > break; > > } > > > } > > > protected void showIconButton(String iconUri){ > > if(iconUri != null){ > > ImageButtoniconField = (ImageButton) > > findViewById(R.id.iconButton); > > Log.d(TAG, "iconUri: " + iconUri); > > iconField.setImageURI(Uri.parse(iconUri)); > > iconField.invalidate(); > > } > > > } > > > So if the item doesn't have an icon, set one in the ContentProvider > > and save the iconUri. If it does, just overwrite it with the new > > cropped image. > > > This works fine if the item never had an icon. It shows in > > theImageButtonwhen the Activity returns. However, if the item already > > had an icon, my Activity still shows the old icon, even though it was > > overwritten. It seems that if theImageButtongets the same Uri back, > > even if I wrote a new image to it, it doesn't redraw, even if I tell > > it to invalidate(). If I relaunch my Activity, the new image shows u
[android-developers] Re: ImageButton caching images when using Uri
No one else has seen anything like this? Is there a way to enter this as a bug against the Android codebase? I haven't actually seen the open source part of this yet (I'd actually try and fix it if it was out there already). On Sep 29, 11:09 am, Joe Erickson <[EMAIL PROTECTED]> wrote: > I'm seeing some caching problems when using anImageButtonwith a Uri > and I'm not sure if there's a flag that needs set somewhere or not. > > I'm using the button to add an icon to an item in one of my > applications, exactly like it's being used for the Contact application > (which I don't think the source is available for). I'm using the CROP > trick seen in this > application:http://code.google.com/p/apps-for-android/source/browse/trunk/Photost... > > Specifically, I'm calling the image picker and then the crop like so: > > protected OnClickListener cmdIconListener = new OnClickListener() { > // @Override > public void onClick(View arg0) { > Intent i = new > Intent("android.intent.action.GET_CONTENT"); > i.setType("image/*"); > startActivityForResult(i, AddTea.ADD_ICON); > } > > }; > > protected void onActivityResult(int requestCode, int resultCode, > Intent data){ > // See which child activity is calling us back. > switch (requestCode) { > case AddTea.ADD_ICON: > // This is the standard resultCode that is sent back if the > // activity crashed or didn't doesn't supply an explicit > result. > if (resultCode != RESULT_CANCELED){ > Intent i = new Intent("com.android.camera.action.CROP"); > i.setClassName("com.android.camera", > "com.android.camera.CropImage"); > i.setData(data.getData()); > Log.d(TAG, "path: " + data.getData().getPath()); > i.putExtra("noFaceDetection", true); > i.putExtra("outputX", iconWidth); > i.putExtra("outputY", iconHeight); > i.putExtra("aspectX", iconWidth); > i.putExtra("aspectY", iconHeight); > i.putExtra("scale", true); > > if(iconUri == null){ > ContentValues values = new ContentValues(); > > values.put(android.provider.MediaStore.Images.Media.TITLE, name + " > Icon"); > > values.put(android.provider.MediaStore.Images.Media.BUCKET_ID, > "STeaP_Tea_Timer_Icons"); > > values.put(android.provider.MediaStore.Images.Media.BUCKET_DISPLAY_NAME, > "STeaP Tea Timer Icons"); > iconUri = > getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, > values).toString(); > } > i.putExtra("output", Uri.parse(iconUri)); > startActivityForResult(i, CROP_ICON); > } > break; > case AddTea.CROP_ICON: > if (resultCode != RESULT_CANCELED){ > Log.d(TAG, "Data String: " + iconUri); > showIconButton(iconUri); > } > default: > break; > } > > } > > protected void showIconButton(String iconUri){ > if(iconUri != null){ > ImageButtoniconField = (ImageButton) > findViewById(R.id.iconButton); > Log.d(TAG, "iconUri: " + iconUri); > iconField.setImageURI(Uri.parse(iconUri)); > iconField.invalidate(); > } > > } > > So if the item doesn't have an icon, set one in the ContentProvider > and save the iconUri. If it does, just overwrite it with the new > cropped image. > > This works fine if the item never had an icon. It shows in > theImageButtonwhen the Activity returns. However, if the item already > had an icon, my Activity still shows the old icon, even though it was > overwritten. It seems that if theImageButtongets the same Uri back, > even if I wrote a new image to it, it doesn't redraw, even if I tell > it to invalidate(). If I relaunch my Activity, the new image shows up > just like I expected. Funny enough, the Pictures application doesn't > see any images I created until I restart the emulator, which also > doesn't seem ideal! > > So, is there anyway to handle this caching of the Uri? I seems like > the ContentProvider should be doing this when I write a new image to > it, but it doesn't seem to be. Also, before anyone suggests, I tried > deleteing the entry in the ContentProvider and making a new one and > that seems to partially work. It partilly works because, if the Uri > we get ba
[android-developers] ImageButton caching images when using Uri
I'm seeing some caching problems when using an ImageButton with a Uri and I'm not sure if there's a flag that needs set somewhere or not. I'm using the button to add an icon to an item in one of my applications, exactly like it's being used for the Contact application (which I don't think the source is available for). I'm using the CROP trick seen in this application: http://code.google.com/p/apps-for-android/source/browse/trunk/Photostream/src/com/google/android/photostream/ViewPhotoActivity.java Specifically, I'm calling the image picker and then the crop like so: protected OnClickListener cmdIconListener = new OnClickListener() { // @Override public void onClick(View arg0) { Intent i = new Intent("android.intent.action.GET_CONTENT"); i.setType("image/*"); startActivityForResult(i, AddTea.ADD_ICON); } }; protected void onActivityResult(int requestCode, int resultCode, Intent data){ // See which child activity is calling us back. switch (requestCode) { case AddTea.ADD_ICON: // This is the standard resultCode that is sent back if the // activity crashed or didn't doesn't supply an explicit result. if (resultCode != RESULT_CANCELED){ Intent i = new Intent("com.android.camera.action.CROP"); i.setClassName("com.android.camera", "com.android.camera.CropImage"); i.setData(data.getData()); Log.d(TAG, "path: " + data.getData().getPath()); i.putExtra("noFaceDetection", true); i.putExtra("outputX", iconWidth); i.putExtra("outputY", iconHeight); i.putExtra("aspectX", iconWidth); i.putExtra("aspectY", iconHeight); i.putExtra("scale", true); if(iconUri == null){ ContentValues values = new ContentValues(); values.put(android.provider.MediaStore.Images.Media.TITLE, name + " Icon"); values.put(android.provider.MediaStore.Images.Media.BUCKET_ID, "STeaP_Tea_Timer_Icons"); values.put(android.provider.MediaStore.Images.Media.BUCKET_DISPLAY_NAME, "STeaP Tea Timer Icons"); iconUri = getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values).toString(); } i.putExtra("output", Uri.parse(iconUri)); startActivityForResult(i, CROP_ICON); } break; case AddTea.CROP_ICON: if (resultCode != RESULT_CANCELED){ Log.d(TAG, "Data String: " + iconUri); showIconButton(iconUri); } default: break; } } protected void showIconButton(String iconUri){ if(iconUri != null){ ImageButton iconField = (ImageButton) findViewById(R.id.iconButton); Log.d(TAG, "iconUri: " + iconUri); iconField.setImageURI(Uri.parse(iconUri)); iconField.invalidate(); } } So if the item doesn't have an icon, set one in the ContentProvider and save the iconUri. If it does, just overwrite it with the new cropped image. This works fine if the item never had an icon. It shows in the ImageButton when the Activity returns. However, if the item already had an icon, my Activity still shows the old icon, even though it was overwritten. It seems that if the ImageButton gets the same Uri back, even if I wrote a new image to it, it doesn't redraw, even if I tell it to invalidate(). If I relaunch my Activity, the new image shows up just like I expected. Funny enough, the Pictures application doesn't see any images I created until I restart the emulator, which also doesn't seem ideal! So, is there anyway to handle this caching of the Uri? I seems like the ContentProvider should be doing this when I write a new image to it, but it doesn't seem to be. Also, before anyone suggests, I tried deleteing the entry in the ContentProvider and making a new one and that seems to partially work. It partilly works because, if the Uri we get back it new, the view does refresh with this new Uri. However, if the icon was the last picture to be saved to the ContentProvider, say item 10, then the ContentProvider will delete item 10 and the reuses 10 as the next id! So I'm back where I started and the ImageButton shows the old icon. Any help in kicking the ContentProvider of ImageButton into shape would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Market Place
They also seemed to imply during the presentation that the App Market would only accept free apps at first. Any idea on when they'll start allowing for pay apps? How the Market charge the user? (Charge on the cell bill or via Google Checkout?) On Sep 23, 7:05 pm, "Mark Murphy" <[EMAIL PROTECTED]> wrote: > > how do you get your app uploaded to the MarketPalce > > The App Market is not yet available. The beta of the Market is supposed to > be available at the time the T-Mobile G1 ships in October. Whether > developers will have an opportunity to put their apps in the Market before > then is unclear at this time, based on the public statements I have seen. > > -- > Mark Murphy (a Commons Guy)http://commonsware.com > _The Busy Coder's Guide to Android Development_ Version 1.2 Published! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Test Location Providers in 1.0
That looks to be the case. It never made sense to me that we would have TestProvider code all through the app anyway. To test Location aware apps now, don't do anything special in your code (code it like you would for a real production application), but in Eclipse, open the Emulator Control view to send GPS lat and long. The docs say you can use a 'geo' app in the tools folder in the SDK, but it doesn't seem to exist yet. http://code.google.com/android/toolbox/apis/lbs.html On Sep 24, 5:21 am, Guillaume Perrot <[EMAIL PROTECTED]> wrote: > I was wondering too, I had to disable this function from my > application... > It seems we can only use DDMS or telnet to simulate location now. > > On 24 sep, 08:34, Reto Meier <[EMAIL PROTECTED]> wrote: > > > The ability to create and configure mock location providers that was > > added in Beta 0.9 doesn't seem available in 1.0. > > > Has this functionality been moved / renamed or has it been dropped > > entirely for version 1? If the latter, how do we now mock the status > > and availability of Location Providers? > > > Cheers > > Reto --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---