[android-developers] Re: AppWidget Update on Orientation Change
your post helped me find what I was looking for. In case anyone else is googling the topic, here is what I found: http://groups.google.com/group/android-developers/browse_thread/thread/a640da2a01bdfde5 So, the id's are the same, but you just need a separate folder for landscape layouts. On Dec 29 2009, 8:46 pm, Guru wrote: > there is a thread whch explains how to do this.I could'nt google it easily. > > You need to specify a different id for each of the layout.that is for > example: > > sample.xml > http://schemas.android.com/apk/res/android"; > android:orientation="vertical" *android:id="landscape" * > android:layout_width="fill_parent" > android:layout_height="fill_parent" > >. > > sample.xml > http://schemas.android.com/apk/res/android"; > android:orientation="vertical" *android:id="portrait" * > android:layout_width="fill_parent" > android:layout_height="fill_parent" > >. > > > > > > On Wed, Dec 30, 2009 at 8:59 AM, Ryan wrote: > > I am developing a photo frame widget, all works except on an > > orientation change to landscape mode my appwidget doesn't display > > correctly as I have it set to portrait dimensions and it is too large > > for the display. I would like to run some code to resize the image so > > that everything displays correctly and it uses all the space that I > > allot. > > What is the correct way to do this? > > I can think of 2 methods however both seem inefficient. The first > > would be to register a broadcast reciever to take orientation changes, > > however I don't want to redo my appwidget everytime the phone is > > turned on its side as the majority of the time the homescreen is not > > showing when the orientation is changed (ie other apps are used, and I > > don't need my code running in the background). I only need it to run > > when the home screen is shown. > > The second would be to setup a service to manage my appwidget but that > > also seems inefficient to be always running in the background. > > > What is correct method to do this? > > > Thanks, > > > - Ryan > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To 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 > > -- > Thanks and Regards > Gurudutt P.S. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: AppWidget Update on Orientation Change
Jeff, what did you do as a workaround? I think am going to always process 2 photos one for portrait size and one for landscape. But I feel like that is double the work needed. I should only have to process this when needed (ie on orientation change on the homescreen), this method will only slow down my app. - Ryan On Dec 30, 11:57 am, Jeffrey Blattman wrote: > I asked the same question some time back and the answer I received was that > there is no way to detect if your widget is visible, or currently shown on > the home screen. > > On Dec 29, 2009 7:29 PM, "Ryan" wrote: > > I am developing a photo frame widget, all works except on an > orientation change to landscape mode my appwidget doesn't display > correctly as I have it set to portrait dimensions and it is too large > for the display. I would like to run some code to resize the image so > that everything displays correctly and it uses all the space that I > allot. > What is the correct way to do this? > I can think of 2 methods however both seem inefficient. The first > would be to register a broadcast reciever to take orientation changes, > however I don't want to redo my appwidget everytime the phone is > turned on its side as the majority of the time the homescreen is not > showing when the orientation is changed (ie other apps are used, and I > don't need my code running in the background). I only need it to run > when the home screen is shown. > The second would be to setup a service to manage my appwidget but that > also seems inefficient to be always running in the background. > > What is correct method to do this? > > Thanks, > > - Ryan > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To 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 > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: AppWidget Update on Orientation Change
I would suggest then, store both images on the SD card, using the WidgetID as a key (use widget as folder name and store the two images in it, or just use the widget id with the orientation appended). As for the ImageView, point it to the correct file either in Activity.onCreate() (which should get called when the orientation changes) or when you receive an orientation change notification. On Tue, Dec 29, 2009 at 11:39 PM, Ryan wrote: > Frank I can see this working. However as my code is now, I use an > imageView in the xml layout files to display my photo, however I don't > point the xml file to the photo. I process the user selected photo, > then save it to the SD card and then in code point the imageView to > the file I just made. I save the photo file on the SD card using the > widgetID in the name so that I know what photo belongs to what widget > if there are multiple instances of the widget running. This prevents > me from pointing the xml layout file to the photo as I don't know what > it will be named until I get the widgetID at runtime. Any ideas? > > - Ryan > > On Dec 29, 10:53 pm, Frank Weiss wrote: > > Clearly, you need two images, one or both scaled and cropped from the > > original. I think your question may be when is the best time to do that. > > That would depend on how you are storing the images, in res, on the file > > system, DB, where? > > > > > > > > On Tue, Dec 29, 2009 at 7:54 PM, Ryan wrote: > > > Thanks, but I don't want a different layout. I want to use the same > > > layout. I just want to change the picture size that i use in the > > > imageview in the layout. I need to scale/crop the image so that it > > > fills the correct size in the screen, going from portrait to landscape > > > should make the image change aspect ratio, however I can only do that > > > by running my code again, but I am just trying to find the best way to > > > call my code. > > > > > - Ryan > > > > > On Dec 29, 9:46 pm, Guru wrote: > > > > there is a thread whch explains how to do this.I could'nt google it > > > easily. > > > > > > You need to specify a different id for each of the layout.that is for > > > > example: > > > > > > sample.xml > > > > http://schemas.android.com/apk/res/android"; > > > > android:orientation="vertical" *android:id="landscape"* > > > > android:layout_width="fill_parent" > > > > android:layout_height="fill_parent" > > > > >. > > > > > > sample.xml > > > > http://schemas.android.com/apk/res/android"; > > > > android:orientation="vertical" *android:id="portrait"* > > > > android:layout_width="fill_parent" > > > > android:layout_height="fill_parent" > > > > >. > > > > > > On Wed, Dec 30, 2009 at 8:59 AM, Ryan wrote: > > > > > I am developing a photo frame widget, all works except on an > > > > > orientation change to landscape mode my appwidget doesn't display > > > > > correctly as I have it set to portrait dimensions and it is too > large > > > > > for the display. I would like to run some code to resize the image > so > > > > > that everything displays correctly and it uses all the space that I > > > > > allot. > > > > > What is the correct way to do this? > > > > > I can think of 2 methods however both seem inefficient. The first > > > > > would be to register a broadcast reciever to take orientation > changes, > > > > > however I don't want to redo my appwidget everytime the phone is > > > > > turned on its side as the majority of the time the homescreen is > not > > > > > showing when the orientation is changed (ie other apps are used, > and I > > > > > don't need my code running in the background). I only need it to > run > > > > > when the home screen is shown. > > > > > The second would be to setup a service to manage my appwidget but > that > > > > > also seems inefficient to be always running in the background. > > > > > > > What is correct method to do this? > > > > > > > Thanks, > > > > > > > - Ryan > > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > > > Groups "Android Developers" group. > > > > > To 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> > > cr...@googlegroups.com> > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/android-developers?hl=en > > > > > > -- > > > > Thanks and Regards > > > > Gurudutt P.S. > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to > android-developers@googlegroups.com > > > To unsubscribe from this group, send email to > > > android-developers+unsubscr...@googlegroups.com cr...@googlegroups.com> > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > -- > You recei
[android-developers] Re: AppWidget Update on Orientation Change
Frank I can see this working. However as my code is now, I use an imageView in the xml layout files to display my photo, however I don't point the xml file to the photo. I process the user selected photo, then save it to the SD card and then in code point the imageView to the file I just made. I save the photo file on the SD card using the widgetID in the name so that I know what photo belongs to what widget if there are multiple instances of the widget running. This prevents me from pointing the xml layout file to the photo as I don't know what it will be named until I get the widgetID at runtime. Any ideas? - Ryan On Dec 29, 10:53 pm, Frank Weiss wrote: > Clearly, you need two images, one or both scaled and cropped from the > original. I think your question may be when is the best time to do that. > That would depend on how you are storing the images, in res, on the file > system, DB, where? > > > > On Tue, Dec 29, 2009 at 7:54 PM, Ryan wrote: > > Thanks, but I don't want a different layout. I want to use the same > > layout. I just want to change the picture size that i use in the > > imageview in the layout. I need to scale/crop the image so that it > > fills the correct size in the screen, going from portrait to landscape > > should make the image change aspect ratio, however I can only do that > > by running my code again, but I am just trying to find the best way to > > call my code. > > > - Ryan > > > On Dec 29, 9:46 pm, Guru wrote: > > > there is a thread whch explains how to do this.I could'nt google it > > easily. > > > > You need to specify a different id for each of the layout.that is for > > > example: > > > > sample.xml > > > http://schemas.android.com/apk/res/android"; > > > android:orientation="vertical" *android:id="landscape" * > > > android:layout_width="fill_parent" > > > android:layout_height="fill_parent" > > > >. > > > > sample.xml > > > http://schemas.android.com/apk/res/android"; > > > android:orientation="vertical" *android:id="portrait" * > > > android:layout_width="fill_parent" > > > android:layout_height="fill_parent" > > > >. > > > > On Wed, Dec 30, 2009 at 8:59 AM, Ryan wrote: > > > > I am developing a photo frame widget, all works except on an > > > > orientation change to landscape mode my appwidget doesn't display > > > > correctly as I have it set to portrait dimensions and it is too large > > > > for the display. I would like to run some code to resize the image so > > > > that everything displays correctly and it uses all the space that I > > > > allot. > > > > What is the correct way to do this? > > > > I can think of 2 methods however both seem inefficient. The first > > > > would be to register a broadcast reciever to take orientation changes, > > > > however I don't want to redo my appwidget everytime the phone is > > > > turned on its side as the majority of the time the homescreen is not > > > > showing when the orientation is changed (ie other apps are used, and I > > > > don't need my code running in the background). I only need it to run > > > > when the home screen is shown. > > > > The second would be to setup a service to manage my appwidget but that > > > > also seems inefficient to be always running in the background. > > > > > What is correct method to do this? > > > > > Thanks, > > > > > - Ryan > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups "Android Developers" group. > > > > To 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> > cr...@googlegroups.com> > > > > For more options, visit this group at > > > >http://groups.google.com/group/android-developers?hl=en > > > > -- > > > Thanks and Regards > > > Gurudutt P.S. > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com > cr...@googlegroups.com> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: AppWidget Update on Orientation Change
You can just check the orientation in the widgets call back method.But this would not be an immediate change. On Wed, Dec 30, 2009 at 10:23 AM, Frank Weiss wrote: > Clearly, you need two images, one or both scaled and cropped from the > original. I think your question may be when is the best time to do that. > That would depend on how you are storing the images, in res, on the file > system, DB, where? > > > On Tue, Dec 29, 2009 at 7:54 PM, Ryan wrote: > >> Thanks, but I don't want a different layout. I want to use the same >> layout. I just want to change the picture size that i use in the >> imageview in the layout. I need to scale/crop the image so that it >> fills the correct size in the screen, going from portrait to landscape >> should make the image change aspect ratio, however I can only do that >> by running my code again, but I am just trying to find the best way to >> call my code. >> >> - Ryan >> >> On Dec 29, 9:46 pm, Guru wrote: >> > there is a thread whch explains how to do this.I could'nt google it >> easily. >> > >> > You need to specify a different id for each of the layout.that is for >> > example: >> > >> > sample.xml >> > http://schemas.android.com/apk/res/android >> " >> > android:orientation="vertical" *android:id="landscape"* >> > android:layout_width="fill_parent" >> > android:layout_height="fill_parent" >> > >. >> > >> > sample.xml >> > http://schemas.android.com/apk/res/android >> " >> > android:orientation="vertical" *android:id="portrait"* >> > android:layout_width="fill_parent" >> > android:layout_height="fill_parent" >> > >. >> > >> > >> > >> > >> > >> > On Wed, Dec 30, 2009 at 8:59 AM, Ryan wrote: >> > > I am developing a photo frame widget, all works except on an >> > > orientation change to landscape mode my appwidget doesn't display >> > > correctly as I have it set to portrait dimensions and it is too large >> > > for the display. I would like to run some code to resize the image so >> > > that everything displays correctly and it uses all the space that I >> > > allot. >> > > What is the correct way to do this? >> > > I can think of 2 methods however both seem inefficient. The first >> > > would be to register a broadcast reciever to take orientation changes, >> > > however I don't want to redo my appwidget everytime the phone is >> > > turned on its side as the majority of the time the homescreen is not >> > > showing when the orientation is changed (ie other apps are used, and I >> > > don't need my code running in the background). I only need it to run >> > > when the home screen is shown. >> > > The second would be to setup a service to manage my appwidget but that >> > > also seems inefficient to be always running in the background. >> > >> > > What is correct method to do this? >> > >> > > Thanks, >> > >> > > - Ryan >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> > > Groups "Android Developers" group. >> > > To 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 >> > >> > -- >> > Thanks and Regards >> > Gurudutt P.S. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Thanks and Regards Gurudutt P.S. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: AppWidget Update on Orientation Change
Clearly, you need two images, one or both scaled and cropped from the original. I think your question may be when is the best time to do that. That would depend on how you are storing the images, in res, on the file system, DB, where? On Tue, Dec 29, 2009 at 7:54 PM, Ryan wrote: > Thanks, but I don't want a different layout. I want to use the same > layout. I just want to change the picture size that i use in the > imageview in the layout. I need to scale/crop the image so that it > fills the correct size in the screen, going from portrait to landscape > should make the image change aspect ratio, however I can only do that > by running my code again, but I am just trying to find the best way to > call my code. > > - Ryan > > On Dec 29, 9:46 pm, Guru wrote: > > there is a thread whch explains how to do this.I could'nt google it > easily. > > > > You need to specify a different id for each of the layout.that is for > > example: > > > > sample.xml > > http://schemas.android.com/apk/res/android"; > > android:orientation="vertical" *android:id="landscape"* > > android:layout_width="fill_parent" > > android:layout_height="fill_parent" > > >. > > > > sample.xml > > http://schemas.android.com/apk/res/android"; > > android:orientation="vertical" *android:id="portrait"* > > android:layout_width="fill_parent" > > android:layout_height="fill_parent" > > >. > > > > > > > > > > > > On Wed, Dec 30, 2009 at 8:59 AM, Ryan wrote: > > > I am developing a photo frame widget, all works except on an > > > orientation change to landscape mode my appwidget doesn't display > > > correctly as I have it set to portrait dimensions and it is too large > > > for the display. I would like to run some code to resize the image so > > > that everything displays correctly and it uses all the space that I > > > allot. > > > What is the correct way to do this? > > > I can think of 2 methods however both seem inefficient. The first > > > would be to register a broadcast reciever to take orientation changes, > > > however I don't want to redo my appwidget everytime the phone is > > > turned on its side as the majority of the time the homescreen is not > > > showing when the orientation is changed (ie other apps are used, and I > > > don't need my code running in the background). I only need it to run > > > when the home screen is shown. > > > The second would be to setup a service to manage my appwidget but that > > > also seems inefficient to be always running in the background. > > > > > What is correct method to do this? > > > > > Thanks, > > > > > - Ryan > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To 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 > > > > -- > > Thanks and Regards > > Gurudutt P.S. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: AppWidget Update on Orientation Change
Thanks, but I don't want a different layout. I want to use the same layout. I just want to change the picture size that i use in the imageview in the layout. I need to scale/crop the image so that it fills the correct size in the screen, going from portrait to landscape should make the image change aspect ratio, however I can only do that by running my code again, but I am just trying to find the best way to call my code. - Ryan On Dec 29, 9:46 pm, Guru wrote: > there is a thread whch explains how to do this.I could'nt google it easily. > > You need to specify a different id for each of the layout.that is for > example: > > sample.xml > http://schemas.android.com/apk/res/android"; > android:orientation="vertical" *android:id="landscape" * > android:layout_width="fill_parent" > android:layout_height="fill_parent" > >. > > sample.xml > http://schemas.android.com/apk/res/android"; > android:orientation="vertical" *android:id="portrait" * > android:layout_width="fill_parent" > android:layout_height="fill_parent" > >. > > > > > > On Wed, Dec 30, 2009 at 8:59 AM, Ryan wrote: > > I am developing a photo frame widget, all works except on an > > orientation change to landscape mode my appwidget doesn't display > > correctly as I have it set to portrait dimensions and it is too large > > for the display. I would like to run some code to resize the image so > > that everything displays correctly and it uses all the space that I > > allot. > > What is the correct way to do this? > > I can think of 2 methods however both seem inefficient. The first > > would be to register a broadcast reciever to take orientation changes, > > however I don't want to redo my appwidget everytime the phone is > > turned on its side as the majority of the time the homescreen is not > > showing when the orientation is changed (ie other apps are used, and I > > don't need my code running in the background). I only need it to run > > when the home screen is shown. > > The second would be to setup a service to manage my appwidget but that > > also seems inefficient to be always running in the background. > > > What is correct method to do this? > > > Thanks, > > > - Ryan > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To 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 > > -- > Thanks and Regards > Gurudutt P.S. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en