[android-developers] Re: Screen rotation and ProgressDialog
I'm still unable to do it. I'm fairly new to Android Dev. Could you please write me a snippet on how to do this in AsyncTasks. Thankyou for your help. -- 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: Screen rotation with App Widgets loses onClick connection
Hi ! I seem to have the same problem but the solution I've found everywhere on the web and in this thread does not work for me :( I posted my onUpdate method below, in which I perform a full initialisation of a new RemoteViews object. Then I pass it to the AppWidgetManager. This kind of operation (init + call to updateAppWidget) is done only in one place in whole my application : in this onUpdate method. Thus, I never send an incomplete RemoteViews object. This is why I don't understand why I suffer from the same screen orientation change problem :'( I tried to call the onUpdate method from the onReceive method, and it works fine, but I think this solution is dirty, especially because I make this additional call to onUpdate on every call to onReceive (I cannot filter on some kind of on screen orientation changed message). Here is the onUpdate method : @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); // Mise à jour de l'image dans les widgets updateClockinImage(context,appWidgetIds, getCheckingCount(context)); // Build the intent to call the service final Intent intent = new Intent(context.getApplicationContext(), AddCheckingService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds); // Pour réagir à un clic il faut utiliser une pending intent car le onClickListener // est exécuté par l'application Home final PendingIntent pendingIntent = PendingIntent.getService(context.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.btn_checkin, pendingIntent); // Mise à jour des widgets avec le nouvel intent appWidgetManager.updateAppWidget(appWidgetIds, remoteViews); super.onUpdate(context, appWidgetManager, appWidgetIds); } Thanks in advance !!! Le vendredi 14 janvier 2011 06:26:43 UTC+1, John Gaby a écrit : I have an App Widget on the Home screen which works fine until the screen is auto-rotated. At that point, the onClick connection (set up via a call to setOnClickPendingIntent) is lost. The only way I seem to be able to get it back is to delete the Widget from the Home screen and then add it back. Is there some kind of message that tells me that the screen has rotated that I need to respond to (and reestablish the connection)? 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: Screen rotation clears TextView
sorry if this is redundant--I've been trying to post a reply to this thread---Can anyone please supply a full coding example for resolving this issue. I want users to be able to rotate the device and not loose the the data that is displayed in the textView. Example: Gold score card app that records strokes for each hole. score is displayed in textView like this: hole#: 4 hole#: 5 hole#: 6 when the device is rotated, this info disappears. Help! 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
Re: [android-developers] Re: Screen rotation with App Widgets loses onClick connection
Each and every update you push to the wigdget with RemoteViews has to have complete widget state, including all images, text, and pending intents. There is no onUpdate on configuration changes. The home screen recreates your widget, then takes the most recent RemoteViews and applies it to the widget. If your codes tries to update the widget incrementally, piece-by-piece, with one RemoteViews specifying the intent, and another, repeated, update setting some changing information, then you end up with the most recent RemoteViews only having your changing text, but no PendingIntent. This is very much unlike how Activities work, where the entire view hierarchy is kept in memory for as long as the activity is on the screen (and maybe longer). -- Kostya 2011/1/14 Anbu anbu.ezhi...@gmail.com It is because, the widget becomes unresponsive when the display mode is changed from portrait to landscape. I had the same issue and I what I had done is for every RemoteView update I had send all the pendingintent to make it work On Jan 14, 4:26 pm, John Gaby jg...@gabysoft.com wrote: I have an App Widget on the Home screen which works fine until the screen is auto-rotated. At that point, the onClick connection (set up via a call to setOnClickPendingIntent) is lost. The only way I seem to be able to get it back is to delete the Widget from the Home screen and then add it back. Is there some kind of message that tells me that the screen has rotated that I need to respond to (and reestablish the connection)? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@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: Screen rotation with App Widgets loses onClick connection
There is no onUpdate on configuration changes. The home screen recreates your widget, then takes the most recent RemoteViews and applies it to the widget. I figured that it was recreating the Widget on rotation. The problem is, I don't seem to be getting any messages to that effect, and have no way (that I can see) of re-establishing the connection. How can I determine that a rotate has happened and set up a new onClick connection? Thanks On Jan 14, 1:28 am, Kostya Vasilyev kmans...@gmail.com wrote: Each and every update you push to the wigdget with RemoteViews has to have complete widget state, including all images, text, and pending intents. There is no onUpdate on configuration changes. The home screen recreates your widget, then takes the most recent RemoteViews and applies it to the widget. If your codes tries to update the widget incrementally, piece-by-piece, with one RemoteViews specifying the intent, and another, repeated, update setting some changing information, then you end up with the most recent RemoteViews only having your changing text, but no PendingIntent. This is very much unlike how Activities work, where the entire view hierarchy is kept in memory for as long as the activity is on the screen (and maybe longer). -- Kostya 2011/1/14 Anbu anbu.ezhi...@gmail.com It is because, the widget becomes unresponsive when the display mode is changed from portrait to landscape. I had the same issue and I what I had done is for every RemoteView update I had send all the pendingintent to make it work On Jan 14, 4:26 pm, John Gaby jg...@gabysoft.com wrote: I have an App Widget on the Home screen which works fine until the screen is auto-rotated. At that point, the onClick connection (set up via a call to setOnClickPendingIntent) is lost. The only way I seem to be able to get it back is to delete the Widget from the Home screen and then add it back. Is there some kind of message that tells me that the screen has rotated that I need to respond to (and reestablish the connection)? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@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: Screen rotation with App Widgets loses onClick connection
[see below] 2011/1/14 John Gaby jg...@gabysoft.com There is no onUpdate on configuration changes. The home screen recreates your widget, then takes the most recent RemoteViews and applies it to the widget. I figured that it was recreating the Widget on rotation. The problem is, I don't seem to be getting any messages to that effect, and have no way (that I can see) of re-establishing the connection. How can I determine that a rotate has happened and set up a new onClick connection? Like I said, you don't (determine or respond to an orientation change). What you do, is make sure that every time your code pushes a RemoteViews object into the home application for your widget, it's complete in all respects: - Has image resource ids; - Has text stings; - Has pending intents. Don't do incremental widget updates, like you would do with a regular activity - don't set the intents first, then the images, then the text reflecting current information. The home app runs as a separate process, and its state can get out-of-step with your widget receiver. When it does, the only thing it has for re-creating your widget is your most recent RemoteViews object. If it's complete, and has all the parts, everything will work just fine. If it only has the most recent text or image change, the earlier updates which had the intents will be lost. http://kmansoft.wordpress.com/2010/05/23/widgets-and-orientation-changes/ -- Kostya Thanks On Jan 14, 1:28 am, Kostya Vasilyev kmans...@gmail.com wrote: Each and every update you push to the wigdget with RemoteViews has to have complete widget state, including all images, text, and pending intents. There is no onUpdate on configuration changes. The home screen recreates your widget, then takes the most recent RemoteViews and applies it to the widget. If your codes tries to update the widget incrementally, piece-by-piece, with one RemoteViews specifying the intent, and another, repeated, update setting some changing information, then you end up with the most recent RemoteViews only having your changing text, but no PendingIntent. This is very much unlike how Activities work, where the entire view hierarchy is kept in memory for as long as the activity is on the screen (and maybe longer). -- Kostya 2011/1/14 Anbu anbu.ezhi...@gmail.com It is because, the widget becomes unresponsive when the display mode is changed from portrait to landscape. I had the same issue and I what I had done is for every RemoteView update I had send all the pendingintent to make it work On Jan 14, 4:26 pm, John Gaby jg...@gabysoft.com wrote: I have an App Widget on the Home screen which works fine until the screen is auto-rotated. At that point, the onClick connection (set up via a call to setOnClickPendingIntent) is lost. The only way I seem to be able to get it back is to delete the Widget from the Home screen and then add it back. Is there some kind of message that tells me that the screen has rotated that I need to respond to (and reestablish the connection)? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@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.comandroid-developers%2bunsubscr...@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: Screen rotation with App Widgets loses onClick connection
Got it, thanks! On Jan 14, 8:27 am, Kostya Vasilyev kmans...@gmail.com wrote: [see below] 2011/1/14 John Gaby jg...@gabysoft.com There is no onUpdate on configuration changes. The home screen recreates your widget, then takes the most recent RemoteViews and applies it to the widget. I figured that it was recreating the Widget on rotation. The problem is, I don't seem to be getting any messages to that effect, and have no way (that I can see) of re-establishing the connection. How can I determine that a rotate has happened and set up a new onClick connection? Like I said, you don't (determine or respond to an orientation change). What you do, is make sure that every time your code pushes a RemoteViews object into the home application for your widget, it's complete in all respects: - Has image resource ids; - Has text stings; - Has pending intents. Don't do incremental widget updates, like you would do with a regular activity - don't set the intents first, then the images, then the text reflecting current information. The home app runs as a separate process, and its state can get out-of-step with your widget receiver. When it does, the only thing it has for re-creating your widget is your most recent RemoteViews object. If it's complete, and has all the parts, everything will work just fine. If it only has the most recent text or image change, the earlier updates which had the intents will be lost. http://kmansoft.wordpress.com/2010/05/23/widgets-and-orientation-chan... -- Kostya Thanks On Jan 14, 1:28 am, Kostya Vasilyev kmans...@gmail.com wrote: Each and every update you push to the wigdget with RemoteViews has to have complete widget state, including all images, text, and pending intents. There is no onUpdate on configuration changes. The home screen recreates your widget, then takes the most recent RemoteViews and applies it to the widget. If your codes tries to update the widget incrementally, piece-by-piece, with one RemoteViews specifying the intent, and another, repeated, update setting some changing information, then you end up with the most recent RemoteViews only having your changing text, but no PendingIntent. This is very much unlike how Activities work, where the entire view hierarchy is kept in memory for as long as the activity is on the screen (and maybe longer). -- Kostya 2011/1/14 Anbu anbu.ezhi...@gmail.com It is because, the widget becomes unresponsive when the display mode is changed from portrait to landscape. I had the same issue and I what I had done is for every RemoteView update I had send all the pendingintent to make it work On Jan 14, 4:26 pm, John Gaby jg...@gabysoft.com wrote: I have an App Widget on the Home screen which works fine until the screen is auto-rotated. At that point, the onClick connection (set up via a call to setOnClickPendingIntent) is lost. The only way I seem to be able to get it back is to delete the Widget from the Home screen and then add it back. Is there some kind of message that tells me that the screen has rotated that I need to respond to (and reestablish the connection)? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@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.comandroid-developers%2bunsubscr...@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: Screen rotation with App Widgets loses onClick connection
It is because, the widget becomes unresponsive when the display mode is changed from portrait to landscape. I had the same issue and I what I had done is for every RemoteView update I had send all the pendingintent to make it work On Jan 14, 4:26 pm, John Gaby jg...@gabysoft.com wrote: I have an App Widget on the Home screen which works fine until the screen is auto-rotated. At that point, the onClick connection (set up via a call to setOnClickPendingIntent) is lost. The only way I seem to be able to get it back is to delete the Widget from the Home screen and then add it back. Is there some kind of message that tells me that the screen has rotated that I need to respond to (and reestablish the connection)? 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: Screen Rotation
if what you posted in the original msg is a cut/paste, then the problem is likely a typo - the right before your android:configChanges line should be moved to AFTER activity android:name=.ReunionPlanner android:label=@string/app_name android:configChanges=orientation|keyboardHidden On Dec 31 2010, 2:21 pm, Robert rcope...@gmail.com wrote: Yes, I agree and even said in my original post that I was working to understand how to make that work correctly. Still would be interested to know why the manifest entry doesn't seem to be working as documented. -- 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: Screen Rotation
I am not sure, if you just want to stop your app to change orientation on rotating. But if thats the case, along with the line you mentioned android:configChanges=orientation|keyboardHidden which tells the system that app will be handling the orientation change, you need to add the following line to in manifest.xml android:screenOrientation=portrait or landscape, depending upon your choice. Hope it helps !! Cheers, Prateek On Jan 1, 1:21 am, Robert rcope...@gmail.com wrote: Yes, I agree and even said in my original post that I was working to understand how to make that work correctly. Still would be interested to know why the manifest entry doesn't seem to be working as documented. On Dec 31, 12:55 pm, TreKing treking...@gmail.com wrote: On Fri, Dec 31, 2010 at 11:48 AM, Robert rcope...@gmail.com wrote: The reason I want to do this is that the app is accessing a webserver via an AsyncTask and I'd like to stop the restart until I can figure out how to link the background task to the new pid that is created. I've read some pages on it but not yet clear how to do that. Quoting the docs for that property: *Note:* Using this attribute should be avoided and used only as a last-resort. Please read Handling Runtime Changeshttp://developer.android.com/guide/topics/resources/runtime-changes.html for more information about how to properly handle a restart due to a configuration change. I highly recommend you spend the time figuring out how to do this correctly then wasting time on a hack that will cause other problems. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered 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: Screen Rotation
http://stackoverflow.com/questions/2730855/prevent-screen-rotation-android -- 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: Screen Rotation
Yes, I agree and even said in my original post that I was working to understand how to make that work correctly. Still would be interested to know why the manifest entry doesn't seem to be working as documented. On Dec 31, 12:55 pm, TreKing treking...@gmail.com wrote: On Fri, Dec 31, 2010 at 11:48 AM, Robert rcope...@gmail.com wrote: The reason I want to do this is that the app is accessing a webserver via an AsyncTask and I'd like to stop the restart until I can figure out how to link the background task to the new pid that is created. I've read some pages on it but not yet clear how to do that. Quoting the docs for that property: *Note:* Using this attribute should be avoided and used only as a last-resort. Please read Handling Runtime Changeshttp://developer.android.com/guide/topics/resources/runtime-changes.html for more information about how to properly handle a restart due to a configuration change. I highly recommend you spend the time figuring out how to do this correctly then wasting time on a hack that will cause other problems. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered 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: Screen rotation and ProgressDialog
But showDialog takes a resource ID and I'm creating my progress dialog on the fly. Perhaps it's a better idea to create it statically? On Sep 20, 12:07 pm, TreKing treking...@gmail.com wrote: On Mon, Sep 20, 2010 at 2:01 PM, Bret Foremanbegin_of_the_skype_highlighting end_of_the_skype_highlightingbret.fore...@gmail.comwrote: How should I handle an active ProgressDialog when the screen is rotated? If you use showDialog(), it gets managed for you. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered 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
Re: [android-developers] Re: Screen rotation and ProgressDialog
On Mon, Sep 20, 2010 at 2:18 PM, Bret Foreman bret.fore...@gmail.comwrote: But showDialog takes a resource ID It's not a resource ID. That id is to ID the dialog itself. It can be whatever you need it to be to ID that particular dialog. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered 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: Screen rotation and ProgressDialog
But a ProgressDialog object does not have a setId method. So how would I identify the dialog? On Sep 20, 12:27 pm, TreKing treking...@gmail.com wrote: On Mon, Sep 20, 2010 at 2:18 PM, Bret Foremanbegin_of_the_skype_highlighting end_of_the_skype_highlightingbret.fore...@gmail.comwrote: But showDialog takes a resource ID It's not a resource ID. That id is to ID the dialog itself. It can be whatever you need it to be to ID that particular dialog. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered 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
Re: [android-developers] Re: Screen rotation and ProgressDialog
On Mon, Sep 20, 2010 at 2:37 PM, Bret Foreman bret.fore...@gmail.comwrote: But a ProgressDialog object does not have a setId method. So how would I identify the dialog? I think you should review this: http://developer.android.com/guide/topics/ui/dialogs.html - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered 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: Screen rotation and ProgressDialog
Yeah, I read this first but was pretty confused. Now I've read it again after the discussion here and it makes more sense. I've got it working now. On Sep 20, 1:05 pm, TreKing treking...@gmail.com wrote: On Mon, Sep 20, 2010 at 2:37 PM, Bret Foremanbegin_of_the_skype_highlighting end_of_the_skype_highlightingbret.fore...@gmail.comwrote: But a ProgressDialog object does not have a setId method. So how would I identify the dialog? I think you should review this:http://developer.android.com/guide/topics/ui/dialogs.html - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered 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
Re: [android-developers] Re: Screen Rotation
On Sat, Jul 17, 2010 at 9:40 AM, nation-x shawn.payme...@gmail.com wrote: there is an example of one way to save an array object to a file and to read it back in. Note that the OP's problem was trying to retain data on screen rotation, not persist across application restarts. In general, saving data to a file and reading it back in for a configuration change is not the ideal solution as it takes longer than necessary to reload the data compared to using the Activity Lifecycle methods. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered 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: Screen Rotation
If you look at this tutorial I created at http://androidworkz.com/2010/07/06/source-code-imageview-flipper-sd-card-scanner/ there is an example of one way to save an array object to a file and to read it back in. I tried using SharedPreferences, etc as described in the docs and gave up because I couldn't get it to work and this solution I came up with works perfectly. This is essentially the basis of the method. It is simple to use... there are 2 functions. public void saveArray(String filename, String[] output_field) { try { FileOutputStream fos = new FileOutputStream(filename); GZIPOutputStream gzos = new GZIPOutputStream(fos); ObjectOutputStream out = new ObjectOutputStream(gzos); out.writeObject(output_field); out.flush(); out.close(); } catch (IOException e) { e.getStackTrace(); } } @SuppressWarnings(unchecked) public String[] loadArray(String filename) { try { FileInputStream fis = new FileInputStream(filename); GZIPInputStream gzis = new GZIPInputStream(fis); ObjectInputStream in = new ObjectInputStream(gzis); String[] read_field = (String[])in.readObject(); in.close(); return read_field; } catch (Exception e) { e.getStackTrace(); } return null; } You just call them like this. Save Array: saveArray(/sdcard/.mydata/data.dat, MyArray); Load Array: String[] MyArray = loadArray(/sdcard/.mydata/data.dat); If you want to use a different type such as a ListArray or whatever, you can just change the functions to use that type. I have found it works with any object that is Serializeable. Shawn McAllister On Jul 16, 12:09 am, 7H3LaughingMan austin.brk...@gmail.com wrote: I was working on implementing a more advanced list view then the standard one they teach you in basic tutorials, and I did find a great tutorial explaining how to create your own Adapter and such not.http://www.softwarepassion.com/android-series-custom-listview-items-a... I do have a working version of the tutorial and I am currently in the process of changing the list to suit my needs, but there are a few issues I am stumped on. If your run the tutorial code it creates a little progress dialog saying that it is retrieving data. In my application it is going to be fetching data from the internet and storing it in an ArrayList of custom objects. However if I where to rotate the screen the progress dialog pops up again, I have no clue on how to set it up so that when it rotates that it doesn't recreate everything and re-fetch the data and process it again. Any help is greatly 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 android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Screen rotation
Hi Kabir, if you mean how do you catch these events and change the layout this could help: http://www.devx.com/wireless/Article/40792/1954 On Sun, Aug 23, 2009 at 1:27 AM, kabir kab...@gmail.com wrote: Hi, I have an activity which I have defined to keep in portrait position. However I would still like to change things (slightly) when the screen is rotated, what is the best way of doing this? I notice onConfigurationChanged is still called, but this still reports portrait mode. I want to keep the notification bar etc in the same position if possible. Cheers Kabir -- Yaron Spektor --~--~-~--~~~---~--~~ 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: Screen rotation
Thanks On Aug 22, 11:27 pm, kabir kab...@gmail.com wrote: Hi, I have an activity which I have defined to keep in portrait position. However I would still like to change things (slightly) when the screen is rotated, what is the best way of doing this? I notice onConfigurationChanged is still called, but this still reports portrait mode. I want to keep the notification bar etc in the same position if possible. Cheers Kabir --~--~-~--~~~---~--~~ 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: Screen rotation
All you can do is monitor the accelerometer yourself and decide for yourself when you consider the screen to be rotated. On Sat, Aug 22, 2009 at 3:27 PM, kabir kab...@gmail.com wrote: Hi, I have an activity which I have defined to keep in portrait position. However I would still like to change things (slightly) when the screen is rotated, what is the best way of doing this? I notice onConfigurationChanged is still called, but this still reports portrait mode. I want to keep the notification bar etc in the same position if possible. Cheers Kabir -- 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 -~--~~~~--~~--~--~---