[android-developers] Bluetooth pairing request although it was previously paired
In the Samsung galaxy note 3, I have paired a bluetooth device. It is paired sucessfully. In my app I simply run this code in a thread to look for the bluetooth device I am interested in and connect automatically to it. Usually everything works well. But occasionally I will get an unwanted Bluetooth Pairing request dialog popup. When this happened, I went to the bluetooth settings and I can see the state is "pairing". My question is why does an already paired device go into pairing again? And what can I do to stop this from happening or get rid of that dialog? I don't want the user to have to confirm to anything. private void open() throws IOException { >close(); >try { > if (android.os.Build.VERSION.SDK_INT >= > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) { >mSocket = mDevice.createInsecureRfcommSocketToServiceRecord( > SPP_UUID); > } else { >mSocket = mDevice.createRfcommSocketToServiceRecord(SPP_UUID); > } > mSocket.connect(); > mIn = new DataInputStream(mSocket.getInputStream()); > mOut = new DataOutputStream(mSocket.getOutputStream()); >} catch (IOException ex) { > close(); > throw ex; >} > } public void run() { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); int sleepDelay; while(mFlag) { sleepDelay = BLUETOOTH_RETRY_DISCOVERY_TIME; Log.e(TAG, "discovering scanner"); if(adapter.isEnabled()) { Set pairedDevices = adapter.getBondedDevices(); if (pairedDevices.size() > 0) { for (BluetoothDevice device : pairedDevices) { if(device.getName().startsWith("MY")) { mPairedDevice = device.getName(); sleepDelay = BLUETOOTH_RETRY_CONNECTION_TIME ; mDevice = device; if(adapter.isDiscovering()) { adapter.cancelDiscovery(); } try { open(); Log.e(TAG, "found bluetooth device and connected ok"); // make sure this is the last thing to be done no more scanner interaction after this synchronized(mConnectThread) { mConnectThread = null; } return; } catch (Exception e) { notifyUIIfNecessary(getContext().getResources().getString(R.string. bluetoothscanner_turnon2)); closeConnection(); } } } } else { mPairedDevice = ""; notifyUIIfNecessary(getContext().getResources().getString(R.string. bluetoothscanner_notpaired)); } } else { notifyUIIfNecessary(getContext().getResources().getString(R.string. bluetoothscanner_adapterdisabled)); } try { sleep(sleepDelay); } catch (InterruptedException e) { } } } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at http://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/7cc14962-3c92-4f9b-b2f3-fd5fab9aaa6d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] detecting http client request abort
In the Android client I call public void abortCurrentRequest() { if(mCurrentRequest != null) { mCurrentRequest.abort(); } } where mCurrentRequest is of type HttpPost. However my PHP REST script still continues to run even though the request was aborted. I have not turned on ignore_user_abort() in PHP and I have also tried to connection_aborted() to detect if the request was aborted without any success. I have also tried changing the Android client to do this mHttpClient.getConnectionManager().shutdown(); Once again the PHP REST script carries on. I need to be able to detect that the current REST API was aborted. The API can take about 30 seconds to run and if the user aborted it on the client, I want my PHP script to know about it. I am using Android 4.2.2 and PHP 5.4.12. Any ideas? I do not want to introduce a new REST API to detect that the user is cancelling. That seems very messy. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[android-developers] AbstractThreadedSyncAdapter and Google Drive API
I'm very confused with this. I'm trying to sync some files and folders in google drive with Android. I came across a Google IO presentation but there was no code attached to it. Using parts of it and what I can google around (there is lots of confusing thoughts about AbstractThreadedSyncAdapter on the net). i.e needs content provider for it to work others say it doesn't etc. I have implemented it by piecing all the information I have worked out. My application makes use of Google play services to call GoogleAuthUtil.getToken() which displays an activity the first time asking the user to confirm permissions to the application. I have a dummy content provider with no functions implemented. However my application does not appear in the Accounts Sync android settings and the onPerformSync() is not called. Can anyone point me to a working example of hopefully using Google drive to sync OR an example of AbstractThreadedSyncAdapter with a custom provider where the sync is working correctly? -- 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: AbstractThreadedSyncAdapter and Google Drive API
android:name=android.content.SyncAdapter / /intent-filter meta-data android:name=android.content.SyncAdapter android:resource=@xml/syncadapter / /service provider android:name=.DummyContentProvider android:syncable=true android:authorities=com.test.testapp.dummy /provider /application /manifest syncadapter.xml : ?xml version=1.0 encoding=utf-8? sync-adapter xmlns:android=http://schemas.android.com/apk/res/android; android:contentAuthority=com.test.testapp android:accountType=com.google / On Tuesday, December 11, 2012 1:58:38 PM UTC+11, rukiman wrote: I'm very confused with this. I'm trying to sync some files and folders in google drive with Android. I came across a Google IO presentation but there was no code attached to it. Using parts of it and what I can google around (there is lots of confusing thoughts about AbstractThreadedSyncAdapter on the net). i.e needs content provider for it to work others say it doesn't etc. I have implemented it by piecing all the information I have worked out. My application makes use of Google play services to call GoogleAuthUtil.getToken() which displays an activity the first time asking the user to confirm permissions to the application. I have a dummy content provider with no functions implemented. However my application does not appear in the Accounts Sync android settings and the onPerformSync() is not called. Can anyone point me to a working example of hopefully using Google drive to sync OR an example of AbstractThreadedSyncAdapter with a custom provider where the sync is working correctly? -- 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] navigation bar in icrecream emulator
How come the hw.mainKeys setting has no effect in the AVD for WVGA800 ? Is there any way to force the navigation bar to appear? -- 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] honeycomb and toasts not showing
If I run my app in honeycomb all the toasts I use do not show. Is there an issue with honeycomb and toasts or is just that the emulator is so slow it doesn't show it but a real device would? -- 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: honeycomb and toasts not showing
Thanks for confirmation On Sep 26, 9:33 pm, Rafael Maas rafaelm...@gmail.com wrote: Slow emulator problem. 2011/9/26 rukiman ruksh...@optushome.com.au: If I run my app in honeycomb all the toasts I use do not show. Is there an issue with honeycomb and toasts or is just that the emulator is so slow it doesn't show it but a real device would? -- 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] knowing when garbage collection occurs on a real device
Hi, I noticed on the real device the garbage collection logs do not appear in logcat. Any way of knowing when a garbage collection occurred and how long it took? I am looking at animation performance and using the emulator isn't really an option and plus I'm guessing just cos a garbage collection occurs on an emulator at a certain point doesn't mean the device will behave the same way. -- 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] view.draw on scrollview not working as expected
Why is it that if I do a view.draw(mycanvas) on scrollview it draws everything as if the user had not scrolled? It seems to ignore the scrollY position of scrollview. -- 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: weird behaviour while overriding FrameLayout.dispatchDraw() on a view that contains a scrollview
Do you know why calling view.draw() on a scrollview draws the screen disregarding the current scrollY and assumes the scrollview is at the beginning always? On Jun 24, 10:14 am, Romain Guy romain...@android.com wrote: The drawing cache is per view, so if you need to capture several views (sibling, and not a subtree like you are doing in your example) if would be better to allocate a single bitmap. This works of course only if all the views have the same size. On Thu, Jun 23, 2011 at 5:06 PM,rukimanruksh...@optushome.com.au wrote: I am suspecting using the view cache system causes the view system to allocate memory for the view. Now lets say I can to capture 3 views, does that mean memory is allocated for 3 views worth of caches if I don't destroy the cache? Also I noticed through profiling that this code runs around 100ms view.setDrawingCacheEnabled(true); view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); view.setDrawingCacheBackgroundColor(Color.BLACK); Bitmap bitmap = view.getDrawingCache(); Bitmap retVal = bitmap == null ? null : bitmap.copy(bitmap.getConfig(), false); view.destroyDrawingCache(); view.setDrawingCacheEnabled(false); return retVal; while this runs at around 60ms mCanvas.setBitmap(mBitmapCapture); view.draw(mCanvas); Bitmap retVal = mBitmapCapture; I have to capture a few views and trying to speed them as quick as possible and at the same time not use much memory. I guess the slight speed difference is in enabling and destroying the view drawing cache? What is the effect of not destroying it? Does that mean it will suffer from my approach above that is double the workload on each frame as well? Going back to my approach my code is just as I pasted it, should I be saving the canvas and restoring it in the dispatchDraw? Any help is appreciated. Thanks. On Jun 24, 9:47 am, Romain Guy romain...@android.com wrote: It's either because you don't properly save/restore the state of your offline Canvas or maybe because of the bitmap config (although it should work just fine in 565.) What I don't understand however is why you refuse to use the drawing cache API that already exists for this purpose? Using this API will not necessarily force another redraw of the view. With the drawing cache, the cache is automatically redrawn whenever the view changes. Your approach however doubles the workload on *every* frame. On Thu, Jun 23, 2011 at 4:23 PM,rukimanruksh...@optushome.com.au wrote: I am trying to understand which this code which works perfectly for capturing almost any view except if there is a ScrollView in the framelayout, in this case there is a slight issue with the top and bottom areas where scrollview fades its contents. There is some corruption occurring. public class FrameLayoutWithOfflineBitmap extends FrameLayout { private Bitmap mOfflineBitmap; private Canvas mOfflineCanvas; public FrameLayoutWithOfflineBitmap(Context context) { super(context); } @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { // just in case we already had the bitmap allocated before if(mOfflineBitmap != null) { mOfflineBitmap.recycle(); } mOfflineBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); mOfflineCanvas = new Canvas(); mOfflineCanvas.setBitmap(mOfflineBitmap); } @Override public void dispatchDraw(Canvas canvas) { // draw to our offline bitmap super.dispatchDraw(mOfflineCanvas); // now draw our offline bitmap to the system canvas canvas.drawBitmap(mOfflineBitmap, 0, 0, null); } public Bitmap getScreenSnapshot() { return mOfflineBitmap; } } I understand there are other ways to capture the view such as using the View's drawing cache, but I am not interested in this method. Can someone explain to me what is going on here and if there is way to address this issue? Basically I am trying to get access to a snapshot of a view as quick as possible. My idea is that the view is already drawn onto the screen, we should be able to get access to this without having to force another redundant redraw of the view. I am also very keen to understand the flaw with the above code in terms of the scrollview. 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
[android-developers] weird behaviour while overriding FrameLayout.dispatchDraw() on a view that contains a scrollview
I am trying to understand which this code which works perfectly for capturing almost any view except if there is a ScrollView in the framelayout, in this case there is a slight issue with the top and bottom areas where scrollview fades its contents. There is some corruption occurring. public class FrameLayoutWithOfflineBitmap extends FrameLayout { private Bitmap mOfflineBitmap; private Canvas mOfflineCanvas; public FrameLayoutWithOfflineBitmap(Context context) { super(context); } @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { // just in case we already had the bitmap allocated before if(mOfflineBitmap != null) { mOfflineBitmap.recycle(); } mOfflineBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); mOfflineCanvas = new Canvas(); mOfflineCanvas.setBitmap(mOfflineBitmap); } @Override public void dispatchDraw(Canvas canvas) { // draw to our offline bitmap super.dispatchDraw(mOfflineCanvas); // now draw our offline bitmap to the system canvas canvas.drawBitmap(mOfflineBitmap, 0, 0, null); } public Bitmap getScreenSnapshot() { return mOfflineBitmap; } } I understand there are other ways to capture the view such as using the View's drawing cache, but I am not interested in this method. Can someone explain to me what is going on here and if there is way to address this issue? Basically I am trying to get access to a snapshot of a view as quick as possible. My idea is that the view is already drawn onto the screen, we should be able to get access to this without having to force another redundant redraw of the view. I am also very keen to understand the flaw with the above code in terms of the scrollview. 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: weird behaviour while overriding FrameLayout.dispatchDraw() on a view that contains a scrollview
I am suspecting using the view cache system causes the view system to allocate memory for the view. Now lets say I can to capture 3 views, does that mean memory is allocated for 3 views worth of caches if I don't destroy the cache? Also I noticed through profiling that this code runs around 100ms view.setDrawingCacheEnabled(true); view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); view.setDrawingCacheBackgroundColor(Color.BLACK); Bitmap bitmap = view.getDrawingCache(); Bitmap retVal = bitmap == null ? null : bitmap.copy(bitmap.getConfig(), false); view.destroyDrawingCache(); view.setDrawingCacheEnabled(false); return retVal; while this runs at around 60ms mCanvas.setBitmap(mBitmapCapture); view.draw(mCanvas); Bitmap retVal = mBitmapCapture; I have to capture a few views and trying to speed them as quick as possible and at the same time not use much memory. I guess the slight speed difference is in enabling and destroying the view drawing cache? What is the effect of not destroying it? Does that mean it will suffer from my approach above that is double the workload on each frame as well? Going back to my approach my code is just as I pasted it, should I be saving the canvas and restoring it in the dispatchDraw? Any help is appreciated. Thanks. On Jun 24, 9:47 am, Romain Guy romain...@android.com wrote: It's either because you don't properly save/restore the state of your offline Canvas or maybe because of the bitmap config (although it should work just fine in 565.) What I don't understand however is why you refuse to use the drawing cache API that already exists for this purpose? Using this API will not necessarily force another redraw of the view. With the drawing cache, the cache is automatically redrawn whenever the view changes. Your approach however doubles the workload on *every* frame. On Thu, Jun 23, 2011 at 4:23 PM, rukiman ruksh...@optushome.com.au wrote: I am trying to understand which this code which works perfectly for capturing almost any view except if there is a ScrollView in the framelayout, in this case there is a slight issue with the top and bottom areas where scrollview fades its contents. There is some corruption occurring. public class FrameLayoutWithOfflineBitmap extends FrameLayout { private Bitmap mOfflineBitmap; private Canvas mOfflineCanvas; public FrameLayoutWithOfflineBitmap(Context context) { super(context); } @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { // just in case we already had the bitmap allocated before if(mOfflineBitmap != null) { mOfflineBitmap.recycle(); } mOfflineBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); mOfflineCanvas = new Canvas(); mOfflineCanvas.setBitmap(mOfflineBitmap); } @Override public void dispatchDraw(Canvas canvas) { // draw to our offline bitmap super.dispatchDraw(mOfflineCanvas); // now draw our offline bitmap to the system canvas canvas.drawBitmap(mOfflineBitmap, 0, 0, null); } public Bitmap getScreenSnapshot() { return mOfflineBitmap; } } I understand there are other ways to capture the view such as using the View's drawing cache, but I am not interested in this method. Can someone explain to me what is going on here and if there is way to address this issue? Basically I am trying to get access to a snapshot of a view as quick as possible. My idea is that the view is already drawn onto the screen, we should be able to get access to this without having to force another redundant redraw of the view. I am also very keen to understand the flaw with the above code in terms of the scrollview. 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 -- 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 -- 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
[android-developers] Re: weird behaviour while overriding FrameLayout.dispatchDraw() on a view that contains a scrollview
Also its not technically double the work load, as I suspect the children views take much longer to render themselves compared to simply drawing a bitmap out to the screen. On Jun 24, 9:47 am, Romain Guy romain...@android.com wrote: It's either because you don't properly save/restore the state of your offline Canvas or maybe because of the bitmap config (although it should work just fine in 565.) What I don't understand however is why you refuse to use the drawing cache API that already exists for this purpose? Using this API will not necessarily force another redraw of the view. With the drawing cache, the cache is automatically redrawn whenever the view changes. Your approach however doubles the workload on *every* frame. On Thu, Jun 23, 2011 at 4:23 PM, rukiman ruksh...@optushome.com.au wrote: I am trying to understand which this code which works perfectly for capturing almost any view except if there is a ScrollView in the framelayout, in this case there is a slight issue with the top and bottom areas where scrollview fades its contents. There is some corruption occurring. public class FrameLayoutWithOfflineBitmap extends FrameLayout { private Bitmap mOfflineBitmap; private Canvas mOfflineCanvas; public FrameLayoutWithOfflineBitmap(Context context) { super(context); } @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { // just in case we already had the bitmap allocated before if(mOfflineBitmap != null) { mOfflineBitmap.recycle(); } mOfflineBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); mOfflineCanvas = new Canvas(); mOfflineCanvas.setBitmap(mOfflineBitmap); } @Override public void dispatchDraw(Canvas canvas) { // draw to our offline bitmap super.dispatchDraw(mOfflineCanvas); // now draw our offline bitmap to the system canvas canvas.drawBitmap(mOfflineBitmap, 0, 0, null); } public Bitmap getScreenSnapshot() { return mOfflineBitmap; } } I understand there are other ways to capture the view such as using the View's drawing cache, but I am not interested in this method. Can someone explain to me what is going on here and if there is way to address this issue? Basically I am trying to get access to a snapshot of a view as quick as possible. My idea is that the view is already drawn onto the screen, we should be able to get access to this without having to force another redundant redraw of the view. I am also very keen to understand the flaw with the above code in terms of the scrollview. 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 -- 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 -- 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: weird behaviour while overriding FrameLayout.dispatchDraw() on a view that contains a scrollview
Found the issue is because I have to clear the bitmap first before rendering the view onto it, the edges are transparent and its showing through to what was drawn before. Question is how would I know what color to clear the bitmap with? On Jun 24, 10:14 am, Romain Guy romain...@android.com wrote: The drawing cache is per view, so if you need to capture several views (sibling, and not a subtree like you are doing in your example) if would be better to allocate a single bitmap. This works of course only if all the views have the same size. On Thu, Jun 23, 2011 at 5:06 PM, rukiman ruksh...@optushome.com.au wrote: I am suspecting using the view cache system causes the view system to allocate memory for the view. Now lets say I can to capture 3 views, does that mean memory is allocated for 3 views worth of caches if I don't destroy the cache? Also I noticed through profiling that this code runs around 100ms view.setDrawingCacheEnabled(true); view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); view.setDrawingCacheBackgroundColor(Color.BLACK); Bitmap bitmap = view.getDrawingCache(); Bitmap retVal = bitmap == null ? null : bitmap.copy(bitmap.getConfig(), false); view.destroyDrawingCache(); view.setDrawingCacheEnabled(false); return retVal; while this runs at around 60ms mCanvas.setBitmap(mBitmapCapture); view.draw(mCanvas); Bitmap retVal = mBitmapCapture; I have to capture a few views and trying to speed them as quick as possible and at the same time not use much memory. I guess the slight speed difference is in enabling and destroying the view drawing cache? What is the effect of not destroying it? Does that mean it will suffer from my approach above that is double the workload on each frame as well? Going back to my approach my code is just as I pasted it, should I be saving the canvas and restoring it in the dispatchDraw? Any help is appreciated. Thanks. On Jun 24, 9:47 am, Romain Guy romain...@android.com wrote: It's either because you don't properly save/restore the state of your offline Canvas or maybe because of the bitmap config (although it should work just fine in 565.) What I don't understand however is why you refuse to use the drawing cache API that already exists for this purpose? Using this API will not necessarily force another redraw of the view. With the drawing cache, the cache is automatically redrawn whenever the view changes. Your approach however doubles the workload on *every* frame. On Thu, Jun 23, 2011 at 4:23 PM, rukiman ruksh...@optushome.com.au wrote: I am trying to understand which this code which works perfectly for capturing almost any view except if there is a ScrollView in the framelayout, in this case there is a slight issue with the top and bottom areas where scrollview fades its contents. There is some corruption occurring. public class FrameLayoutWithOfflineBitmap extends FrameLayout { private Bitmap mOfflineBitmap; private Canvas mOfflineCanvas; public FrameLayoutWithOfflineBitmap(Context context) { super(context); } @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { // just in case we already had the bitmap allocated before if(mOfflineBitmap != null) { mOfflineBitmap.recycle(); } mOfflineBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); mOfflineCanvas = new Canvas(); mOfflineCanvas.setBitmap(mOfflineBitmap); } @Override public void dispatchDraw(Canvas canvas) { // draw to our offline bitmap super.dispatchDraw(mOfflineCanvas); // now draw our offline bitmap to the system canvas canvas.drawBitmap(mOfflineBitmap, 0, 0, null); } public Bitmap getScreenSnapshot() { return mOfflineBitmap; } } I understand there are other ways to capture the view such as using the View's drawing cache, but I am not interested in this method. Can someone explain to me what is going on here and if there is way to address this issue? Basically I am trying to get access to a snapshot of a view as quick as possible. My idea is that the view is already drawn onto the screen, we should be able to get access to this without having to force another redundant redraw of the view. I am also very keen to understand the flaw with the above code in terms of the scrollview. 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
[android-developers] Re: weird behaviour while overriding FrameLayout.dispatchDraw() on a view that contains a scrollview
Btw forgot to say thanks Romain for your help. I have another question (see forum) which I'm sure you are very capable of answering :D On Jun 24, 10:56 am, rukiman ruksh...@optushome.com.au wrote: Found the issue is because I have to clear the bitmap first before rendering the view onto it, the edges are transparent and its showing through to what was drawn before. Question is how would I know what color to clear the bitmap with? On Jun 24, 10:14 am, Romain Guy romain...@android.com wrote: The drawing cache is per view, so if you need to capture several views (sibling, and not a subtree like you are doing in your example) if would be better to allocate a single bitmap. This works of course only if all the views have the same size. On Thu, Jun 23, 2011 at 5:06 PM, rukiman ruksh...@optushome.com.au wrote: I am suspecting using the view cache system causes the view system to allocate memory for the view. Now lets say I can to capture 3 views, does that mean memory is allocated for 3 views worth of caches if I don't destroy the cache? Also I noticed through profiling that this code runs around 100ms view.setDrawingCacheEnabled(true); view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); view.setDrawingCacheBackgroundColor(Color.BLACK); Bitmap bitmap = view.getDrawingCache(); Bitmap retVal = bitmap == null ? null : bitmap.copy(bitmap.getConfig(), false); view.destroyDrawingCache(); view.setDrawingCacheEnabled(false); return retVal; while this runs at around 60ms mCanvas.setBitmap(mBitmapCapture); view.draw(mCanvas); Bitmap retVal = mBitmapCapture; I have to capture a few views and trying to speed them as quick as possible and at the same time not use much memory. I guess the slight speed difference is in enabling and destroying the view drawing cache? What is the effect of not destroying it? Does that mean it will suffer from my approach above that is double the workload on each frame as well? Going back to my approach my code is just as I pasted it, should I be saving the canvas and restoring it in the dispatchDraw? Any help is appreciated. Thanks. On Jun 24, 9:47 am, Romain Guy romain...@android.com wrote: It's either because you don't properly save/restore the state of your offline Canvas or maybe because of the bitmap config (although it should work just fine in 565.) What I don't understand however is why you refuse to use the drawing cache API that already exists for this purpose? Using this API will not necessarily force another redraw of the view. With the drawing cache, the cache is automatically redrawn whenever the view changes. Your approach however doubles the workload on *every* frame. On Thu, Jun 23, 2011 at 4:23 PM, rukiman ruksh...@optushome.com.au wrote: I am trying to understand which this code which works perfectly for capturing almost any view except if there is a ScrollView in the framelayout, in this case there is a slight issue with the top and bottom areas where scrollview fades its contents. There is some corruption occurring. public class FrameLayoutWithOfflineBitmap extends FrameLayout { private Bitmap mOfflineBitmap; private Canvas mOfflineCanvas; public FrameLayoutWithOfflineBitmap(Context context) { super(context); } @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { // just in case we already had the bitmap allocated before if(mOfflineBitmap != null) { mOfflineBitmap.recycle(); } mOfflineBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); mOfflineCanvas = new Canvas(); mOfflineCanvas.setBitmap(mOfflineBitmap); } @Override public void dispatchDraw(Canvas canvas) { // draw to our offline bitmap super.dispatchDraw(mOfflineCanvas); // now draw our offline bitmap to the system canvas canvas.drawBitmap(mOfflineBitmap, 0, 0, null); } public Bitmap getScreenSnapshot() { return mOfflineBitmap; } } I understand there are other ways to capture the view such as using the View's drawing cache, but I am not interested in this method. Can someone explain to me what is going on here and if there is way to address this issue? Basically I am trying to get access to a snapshot of a view as quick as possible. My idea is that the view is already drawn onto the screen, we should be able to get access to this without having to force another redundant redraw of the view. I am also very keen to understand the flaw
[android-developers] best way to implement a thread requring a result from a function that must be run on the UI thread
I am in a thread that I did not create, its part of a library and I need to generate a result which can only be done in the UI thread. Any good tutorial on the best way to achieve this? I know I will have to post a handler to the UI thread, but whats the best way for the UI thread to return the result? And I have to make the other thread wait for the result. A good code snipped would 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
[android-developers] Re: weird behaviour while overriding FrameLayout.dispatchDraw() on a view that contains a scrollview
For anyone interested this is the fixed code: class FrameLayoutWithOfflineBitmap extends FrameLayout { private Bitmap mOfflineBitmap; private Canvas mOfflineCanvas; private Paint paint; public FrameLayoutWithOfflineBitmap(Context context) { super(context); paint = new Paint(); paint.setColor(Color.BLACK); } @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { // just in case we already had the bitmap allocated before if(mOfflineBitmap != null) { mOfflineBitmap.recycle(); } mOfflineBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); mOfflineCanvas = new Canvas(); mOfflineCanvas.setBitmap(mOfflineBitmap); } @Override public void dispatchDraw(Canvas canvas) { // draw to our offline bitmap mOfflineCanvas.drawRect(0, 0, mOfflineBitmap.getWidth(), mOfflineBitmap.getHeight(), paint); super.dispatchDraw(mOfflineCanvas); // now draw our offline bitmap to the system canvas canvas.drawBitmap(mOfflineBitmap, 0, 0, null); } public Bitmap getScreenSnapshot() { return mOfflineBitmap; } } On Jun 24, 12:00 pm, rukiman ruksh...@optushome.com.au wrote: Btw forgot to say thanks Romain for your help. I have another question (see forum) which I'm sure you are very capable of answering :D On Jun 24, 10:56 am, rukiman ruksh...@optushome.com.au wrote: Found the issue is because I have to clear the bitmap first before rendering the view onto it, the edges are transparent and its showing through to what was drawn before. Question is how would I know what color to clear the bitmap with? On Jun 24, 10:14 am, Romain Guy romain...@android.com wrote: The drawing cache is per view, so if you need to capture several views (sibling, and not a subtree like you are doing in your example) if would be better to allocate a single bitmap. This works of course only if all the views have the same size. On Thu, Jun 23, 2011 at 5:06 PM, rukiman ruksh...@optushome.com.au wrote: I am suspecting using the view cache system causes the view system to allocate memory for the view. Now lets say I can to capture 3 views, does that mean memory is allocated for 3 views worth of caches if I don't destroy the cache? Also I noticed through profiling that this code runs around 100ms view.setDrawingCacheEnabled(true); view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); view.setDrawingCacheBackgroundColor(Color.BLACK); Bitmap bitmap = view.getDrawingCache(); Bitmap retVal = bitmap == null ? null : bitmap.copy(bitmap.getConfig(), false); view.destroyDrawingCache(); view.setDrawingCacheEnabled(false); return retVal; while this runs at around 60ms mCanvas.setBitmap(mBitmapCapture); view.draw(mCanvas); Bitmap retVal = mBitmapCapture; I have to capture a few views and trying to speed them as quick as possible and at the same time not use much memory. I guess the slight speed difference is in enabling and destroying the view drawing cache? What is the effect of not destroying it? Does that mean it will suffer from my approach above that is double the workload on each frame as well? Going back to my approach my code is just as I pasted it, should I be saving the canvas and restoring it in the dispatchDraw? Any help is appreciated. Thanks. On Jun 24, 9:47 am, Romain Guy romain...@android.com wrote: It's either because you don't properly save/restore the state of your offline Canvas or maybe because of the bitmap config (although it should work just fine in 565.) What I don't understand however is why you refuse to use the drawing cache API that already exists for this purpose? Using this API will not necessarily force another redraw of the view. With the drawing cache, the cache is automatically redrawn whenever the view changes. Your approach however doubles the workload on *every* frame. On Thu, Jun 23, 2011 at 4:23 PM, rukiman ruksh...@optushome.com.au wrote: I am trying to understand which this code which works perfectly for capturing almost any view except if there is a ScrollView in the framelayout, in this case there is a slight issue with the top and bottom areas where scrollview fades its contents. There is some corruption occurring. public class FrameLayoutWithOfflineBitmap extends FrameLayout { private Bitmap mOfflineBitmap; private Canvas mOfflineCanvas; public FrameLayoutWithOfflineBitmap(Context context) { super
[android-developers] Re: best way to implement a thread requring a result from a function that must be run on the UI thread
To be more precise the thread which requires a result from the UI thread is the SurfaceView thread. I do not want to pre generate the result from the UI thread to minimize the memory footprint. On Jun 24, 12:03 pm, rukiman ruksh...@optushome.com.au wrote: I am in a thread that I did not create, its part of a library and I need to generate a result which can only be done in the UI thread. Any good tutorial on the best way to achieve this? I know I will have to post a handler to the UI thread, but whats the best way for the UI thread to return the result? And I have to make the other thread wait for the result. A good code snipped would 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
[android-developers] scale whole view
I wrote a game using absolute positions for a specific device. I want to target other resolutions however I want to minimize work. I just want to scale the whole view down and maintain aspect ratio. I can see in 3.0 there is a setScale function added that will do the job however I want to target 1.5 onwards. I wrote this class that works ok visually however the events are not working 100% i.e if you press dead in the center of the button it will work if you touch a bit up it presses the button on top even. Also it does draw the image button pressed states correctly. However visually it is just what I want. public class ScaledLinearLayout extends LinearLayout { private static final float OPTIMUM_HEIGHT = 1024; private static final float OPTIMUM_WIDTH = 768; private float offsetX; private float offsetY; private float scale = 1.0f; private Context context; private Display display; public ScaledLinearLayout(Context cxt, AttributeSet attrs) { super(cxt, attrs); this.context = cxt; WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); display = wm.getDefaultDisplay(); float scaleX = display.getWidth() / OPTIMUM_WIDTH; float scaleY = display.getHeight() / OPTIMUM_HEIGHT; scale = Math.min( scaleX, scaleY ); offsetX = (display.getWidth() - (scale * OPTIMUM_WIDTH)) / 2; offsetY = (display.getHeight() - (scale * OPTIMUM_HEIGHT)) / 2; } @Override public boolean dispatchTouchEvent(MotionEvent event) { float newX = (event.getX() - offsetX) / scale; float newY = (event.getY() - offsetY) / scale; event.setLocation(newX, newY); return super.dispatchTouchEvent(event); } @Override public void dispatchDraw(Canvas canvas) { canvas.save(); canvas.scale(scale, scale); canvas.translate(offsetX, offsetY); super.dispatchDraw(canvas); canvas.restore(); } } I make ScaledLinearLayout the parent viewgroup of my view and it will then scale the views such that it best fits the screen and centers the game on the screen. Only issue is the events are a bit whack. Any ideas or a better way to do what I'm trying to achieve? Rewriting the layouts are out of the question. -- 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: scale whole view
I meant to say it doesn't draw the image button pressed states correctly. On Apr 9, 10:58 am, rukiman ruksh...@optushome.com.au wrote: I wrote a game using absolute positions for a specific device. I want to target other resolutions however I want to minimize work. I just want to scale the whole view down and maintain aspect ratio. I can see in 3.0 there is a setScale function added that will do the job however I want to target 1.5 onwards. I wrote this class that works ok visually however the events are not working 100% i.e if you press dead in the center of the button it will work if you touch a bit up it presses the button on top even. Also it does draw the image button pressed states correctly. However visually it is just what I want. public class ScaledLinearLayout extends LinearLayout { private static final float OPTIMUM_HEIGHT = 1024; private static final float OPTIMUM_WIDTH = 768; private float offsetX; private float offsetY; private float scale = 1.0f; private Context context; private Display display; public ScaledLinearLayout(Context cxt, AttributeSet attrs) { super(cxt, attrs); this.context = cxt; WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); display = wm.getDefaultDisplay(); float scaleX = display.getWidth() / OPTIMUM_WIDTH; float scaleY = display.getHeight() / OPTIMUM_HEIGHT; scale = Math.min( scaleX, scaleY ); offsetX = (display.getWidth() - (scale * OPTIMUM_WIDTH)) / 2; offsetY = (display.getHeight() - (scale * OPTIMUM_HEIGHT)) / 2; } @Override public boolean dispatchTouchEvent(MotionEvent event) { float newX = (event.getX() - offsetX) / scale; float newY = (event.getY() - offsetY) / scale; event.setLocation(newX, newY); return super.dispatchTouchEvent(event); } @Override public void dispatchDraw(Canvas canvas) { canvas.save(); canvas.scale(scale, scale); canvas.translate(offsetX, offsetY); super.dispatchDraw(canvas); canvas.restore(); } } I make ScaledLinearLayout the parent viewgroup of my view and it will then scale the views such that it best fits the screen and centers the game on the screen. Only issue is the events are a bit whack. Any ideas or a better way to do what I'm trying to achieve? Rewriting the layouts are out of the question. -- 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: Can we delay the ANR dialog
I would say no! You should do any long process in a thread and not on the main UI thread. On Dec 22, 4:18 pm, ankit ankit.ag...@gmail.com wrote: Hi, Is there any way by which we can increase the response waiting time in the source code so that the ANR dialog get delayed for more than 5 seconds... Immediate help would be very helpful regards, Ankit Aggarwal -- 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] detection twist using orientation sensor
At the moment I can detect rotation along the x-axis and also y-axis. However imagine the user holding their phone looking at the screen, I want to detect and measure how much the user has rotated their phone to the left or right such that the screen is always vertical. I thought this would correspond to the z-axis rotation but from my logging it seems like there is also dramatic rotation on the other axis. So my question is how can I detect the user rotating their phone in a twisting motion such that the screen is always facing the user? I want to be able to detect this motion and also measure the amount of twist the user has applied. -- 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: rotate screen180 degress
anyone? On Sep 19, 9:29 pm, rukiman ruksh...@optushome.com.au wrote: I came across another post to help me. But when I use FlipLayout in my view all I get it a black screen. However if I change the rotation from 180 to 0 all is drawn ok. But I want my screen upside down. Whats going on here? import android.content.Context; import android.graphics.Canvas; import android.graphics.Matrix; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.LinearLayout; public class FlipLayout extends LinearLayout { private Matrix mMatrix = new Matrix(); private float[] mTemp = new float[2]; public FlipLayout(Context context, AttributeSet attr) { super(context, attr); mMatrix.postRotate(180); } @Override protected void dispatchDraw(Canvas canvas) { int sc = canvas.save(); canvas.setMatrix(mMatrix); super.dispatchDraw(canvas); canvas.restoreToCount(sc); } @Override public boolean dispatchTouchEvent(MotionEvent event) { final float[] temp = mTemp; temp[0] = event.getX(); temp[1] = event.getY(); mMatrix.mapPoints(temp); event.setLocation(temp[0], temp[1]); return super.dispatchTouchEvent(event); } } On Sep 19, 3:13 pm, rukiman ruksh...@optushome.com.au wrote: I have a need to rotate the views in my activities by 180 degrees. Any good suggestions on how to do this? Taking into account touch inputs still working. My activity is made up of several views in a linearlayout and also makes use of toasts.- 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: rotate screen180 degress
I came across another post to help me. But when I use FlipLayout in my view all I get it a black screen. However if I change the rotation from 180 to 0 all is drawn ok. But I want my screen upside down. Whats going on here? import android.content.Context; import android.graphics.Canvas; import android.graphics.Matrix; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.LinearLayout; public class FlipLayout extends LinearLayout { private Matrix mMatrix = new Matrix(); private float[] mTemp = new float[2]; public FlipLayout(Context context, AttributeSet attr) { super(context, attr); mMatrix.postRotate(180); } @Override protected void dispatchDraw(Canvas canvas) { int sc = canvas.save(); canvas.setMatrix(mMatrix); super.dispatchDraw(canvas); canvas.restoreToCount(sc); } @Override public boolean dispatchTouchEvent(MotionEvent event) { final float[] temp = mTemp; temp[0] = event.getX(); temp[1] = event.getY(); mMatrix.mapPoints(temp); event.setLocation(temp[0], temp[1]); return super.dispatchTouchEvent(event); } } On Sep 19, 3:13 pm, rukiman ruksh...@optushome.com.au wrote: I have a need to rotate the views in my activities by 180 degrees. Any good suggestions on how to do this? Taking into account touch inputs still working. My activity is made up of several views in a linearlayout and also makes use of toasts. -- 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] rotate screen180 degress
I have a need to rotate the views in my activities by 180 degrees. Any good suggestions on how to do this? Taking into account touch inputs still working. My activity is made up of several views in a linearlayout and also makes use of toasts. -- 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] object graphs
Is there any tool to show you visually how your objects reference each other? I want to areas where there are cyclic references in my 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] multiple mapviews
I know I cannot create two MapViews in a MapActivity. And I cannot create two MapActivities in a process. Is there a work around that will enable me to display two mapviews side by side? -- 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: multiple mapviews
I want a mapview which shows the map scaled down and another mapview which shows the map scaled up. Any way I can implement this? On Jul 13, 2:51 pm, prachi prachi.tya...@wipro.com wrote: hiii could u please throw some light on your problem??? On Jul 13, 7:37 am, rukiman ruksh...@optushome.com.au wrote: I know I cannot create two MapViews in a MapActivity. And I cannot create two MapActivities in a process. Is there a work around that will enable me to display two mapviews side by side? -- 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] cannot see my own paid app on the market place?
I have uploaded my paid app Legion and I can see that I am making sales but why is this app not visible on my phone? I can see other paid and free apps. The android platform of my Samsung Galaxy phone is 1.5 and here is part of my manifest: uses-sdk android:minSdkVersion=3 android:targetSdkVersion=4 / supports-screen anyDensity=true android:smallScreens=false android:normalScreens=true android:largeScreens=true / uses-permission android:name=android.permission.INTERNET / uses-permission android:name=android.permission.READ_PHONE_STATE / the app was built against the android 1.6 target as described on the android developer's website. The app must be visible on some phones as I am getting some sales. I also asked a friend in the US who has an android phone and same deal, he cannot find it on the android market app. -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[android-developers] disable activity transitions
Is it possible to disabled activity transitions altogether and still maintain compatible with 1.5 ? -- 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: growing assest allocations
anyone? On Feb 27, 2:41 pm, rukiman ruksh...@optushome.com.au wrote: I did a dumpsys meminfo of my app and each time I go in and out of my activity the asset allocations grows i.e Asset Allocations zip:/data/app/com.home.Test.apk:/assets/fonts/TEST.TTF: 118K zip:/data/app/com.home.Test.apk:/assets/fonts/TEST.TTF: 118K zip:/data/app/com.home.Test.apk:/assets/fonts/TEST.TTF: 118K Is this a concern? What can I do to avoid this? I have a feeling this is the reason for the growing memory usage. -- 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] how to turn off activity transitions
How can I turn off activity transitions? It looks a bit odd on my game. Will the mechanism be safe for 1.5? I am in the process of making my 1.5 game support multiple resolutions. -- 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] layout_width as a % of layout_height
What I am trying to do is make my game center in any screen with the best fit to screen and maintain ratio. Is there a good way to do this? This is my current xml. I have an outer linearlayout to center the middle one, all good in most resolutions but doesn't work well in WQVGA400. If I could make the layout_width a percentage of layout_height I think I could solve my issue as I can make layout_width = fill_parent, and then make make layout_height use a % of layout_width which should maintain aspect ratio. Actually I don't even understand why the below concept doesnt work on a WQVGA400 screen?? LinearLayout android:id=@+id/outerlayout android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent xmlns:android=http:// schemas.android.com/apk/res/android android:gravity=center LinearLayout android:layout_width=320dip android:layout_height=480dip xmlns:android=http:// schemas.android.com/apk/res/android android:focusable=true android:focusableInTouchMode=true android:background=@drawable/menu_background android:id=@+id/ main_menu LinearLayout android:orientation=vertical android:layout_centerInParent=false android:focusable=true android:focusableInTouchMode=true android:layout_alignParentTop=false android:layout_alignParentBottom=false android:layout_alignParentLeft=false android:layout_centerHorizontal=false android:layout_centerVertical=false android:layout_alignParentRight=false android:layout_marginLeft=170dip android:layout_height=wrap_content android:layout_width=wrap_content android:background=@drawable/scroll_7buttons android:layout_marginTop=150dip android:id=@+id/mainMenuLayout /LinearLayout /LinearLayout /LinearLayout -- 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: layout_width as a % of layout_height
I should mention that my AndroidManifest.xml is uses-sdk android:minSdkVersion=3 android:targetSdkVersion=4 / supports-screen anyDensity=false android:smallScreens=false android:normalScreens=true android:largeScreens=true / On Feb 28, 11:42 pm, rukiman ruksh...@optushome.com.au wrote: What I am trying to do is make my game center in any screen with the best fit to screen and maintain ratio. Is there a good way to do this? This is my current xml. I have an outer linearlayout to center the middle one, all good in most resolutions but doesn't work well in WQVGA400. If I could make the layout_width a percentage of layout_height I think I could solve my issue as I can make layout_width = fill_parent, and then make make layout_height use a % of layout_width which should maintain aspect ratio. Actually I don't even understand why the below concept doesnt work on a WQVGA400 screen?? LinearLayout android:id=@+id/outerlayout android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent xmlns:android=http:// schemas.android.com/apk/res/android android:gravity=center LinearLayout android:layout_width=320dip android:layout_height=480dip xmlns:android=http:// schemas.android.com/apk/res/android android:focusable=true android:focusableInTouchMode=true android:background=@drawable/menu_background android:id=@+id/ main_menu LinearLayout android:orientation=vertical android:layout_centerInParent=false android:focusable=true android:focusableInTouchMode=true android:layout_alignParentTop=false android:layout_alignParentBottom=false android:layout_alignParentLeft=false android:layout_centerHorizontal=false android:layout_centerVertical=false android:layout_alignParentRight=false android:layout_marginLeft=170dip android:layout_height=wrap_content android:layout_width=wrap_content android:background=@drawable/scroll_7buttons android:layout_marginTop=150dip android:id=@+id/mainMenuLayout /LinearLayout /LinearLayout /LinearLayout -- 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: anyDensity - bitmap not resized
OK turns out it was scaling ok. Not sure what happened. On Feb 28, 12:20 am, rukiman ruksh...@optushome.com.au wrote: How can I make that inner linearlayout scale correctly? On Feb 27, 6:25 pm, James Wang jameswangc...@gmail.com wrote: Pre-scale resource should be depend on density of screen, not resolution. -- 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: anyDensity - bitmap not resized
Now I'm having a problem with aspect ratio. How does one handle for this? Getting the framework to rescale everything by density is not good enough, there are some resolutions where the aspect ratio seems to crop the game screen such as WQVGA400. What can I do? On Mar 1, 10:09 am, rukiman ruksh...@optushome.com.au wrote: OK turns out it was scaling ok. Not sure what happened. On Feb 28, 12:20 am, rukiman ruksh...@optushome.com.au wrote: How can I make that inner linearlayout scale correctly? On Feb 27, 6:25 pm, James Wang jameswangc...@gmail.com wrote: Pre-scale resource should be depend on density of screen, not resolution. -- 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: anyDensity - bitmap not resized
How can I make that inner linearlayout scale correctly? On Feb 27, 6:25 pm, James Wang jameswangc...@gmail.com wrote: Pre-scale resource should be depend on density of screen, not resolution. -- 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] growing assest allocations
I did a dumpsys meminfo of my app and each time I go in and out of my activity the asset allocations grows i.e Asset Allocations zip:/data/app/com.home.Test.apk:/assets/fonts/TEST.TTF: 118K zip:/data/app/com.home.Test.apk:/assets/fonts/TEST.TTF: 118K zip:/data/app/com.home.Test.apk:/assets/fonts/TEST.TTF: 118K Is this a concern? What can I do to avoid this? I have a feeling this is the reason for the growing memory usage. -- 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] anyDensity - bitmap not resized
Hi I am trying to convert my game to support multiple resolutions. I have this in my manifest. uses-sdk android:minSdkVersion=3 android:targetSdkVersion=4 / supports-screen anyDensity=false / The splash screen and main menu background all scaled up correctly, so far so good. However in my main menu I have a inner linearlayout which I use to put another bitmap so it is the background of where the menu items go. This bitmap did not get scaled. Why is this so? I have other issues but trying to understand whats happenning here will help me fix the other issues I think. Here is my xml for the main menu. LinearLayout android:layout_width=fill_parent android:layout_height=fill_parent xmlns:android=http:// schemas.android.com/apk/res/android android:focusable=true android:focusableInTouchMode=true android:background=@drawable/legion_menu_background android:id=@ +id/main_menu LinearLayout android:orientation=vertical android:layout_centerInParent=false android:focusable=true android:focusableInTouchMode=true android:layout_alignParentTop=false android:layout_alignParentBottom=false android:layout_alignParentLeft=false android:layout_centerHorizontal=false android:layout_centerVertical=false android:layout_alignParentRight=false android:layout_marginLeft=170dip android:layout_height=wrap_content android:layout_width=wrap_content android:background=@drawable/scroll_7buttons android:layout_marginTop=150dip android:id=@+id/mainMenuLayout ImageButton android:layout_width=wrap_content android:layout_height=wrap_content android:id=@+id/Start android:clickable=true android:layout_gravity=center_horizontal android:src=@layout/start_game_selected_button android:background=@drawable/transparent_background android:padding=17dip android:layout_marginTop=33dip/ ImageButton ImageButton android:layout_width=wrap_content android:layout_height=wrap_content android:id=@+id/help android:clickable=true android:layout_gravity=center_horizontal android:src=@layout/help_selected_button android:background=@drawable/transparent_background android:padding=17dip/ImageButton ImageButton android:layout_width=wrap_content android:layout_height=wrap_content android:clickable=true android:layout_gravity=center_horizontal android:id=@+id/more android:src=@layout/more_selected_button android:background=@drawable/transparent_background android:padding=17dip/ImageButton /LinearLayout /LinearLayout -- 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] MMS receiving/sending
Is there an API to send and receive MMS from an application? Similar to that of SMS? In SMS one can send SMSs by using SMSManager.sendTextMessage() and receive them by registering for the broadcast message. -- 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] cannot see video when using MediaPlayer
Attached is my code, I cannot see the video while playing a MPG file. What am I doing wrong here? Thanks. public class VideoTest extends Activity implements SurfaceHolder.Callback{ private ArrayListMediaPlayer mMediaVideoPlayers = new ArrayListMediaPlayer(); private SurfaceView videoSurface[] = new SurfaceView[4]; private SurfaceHolder videoSurfaceHolder[] = new SurfaceHolder[4]; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); videoSurface[0] = (SurfaceView)findViewById(R.id.video1); videoSurfaceHolder[0] = videoSurface[0].getHolder(); videoSurfaceHolder[0].addCallback(this); videoSurfaceHolder[0].setType (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } private void playVideo(int res, SurfaceHolder holder) { MediaPlayer mediaplayer = new MediaPlayer(); AssetFileDescriptor afd = getResources().openRawResourceFd (res); try { mediaplayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); mediaplayer.setDisplay(holder); mediaplayer.prepare(); mediaplayer.start(); mMediaVideoPlayers.add(mediaplayer); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } public void surfaceCreated(SurfaceHolder holder) { playVideo(R.raw.video2, holder); } public void surfaceDestroyed(SurfaceHolder holder) { } } -- 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: cannot see video when using MediaPlayer
That was how I had it originally, I tried again but still doesn't work On Jan 21, 2:18 pm, kavitha sunil kavithasuni...@gmail.com wrote: try using mediaplayer.setDisplay(videoSurfaceHolder[0]); On Thu, Jan 21, 2010 at 8:39 AM, rukiman ruksh...@optushome.com.au wrote: Attached is my code, I cannot see the video while playing a MPG file. What am I doing wrong here? Thanks. public class VideoTest extends Activity implements SurfaceHolder.Callback{ private ArrayListMediaPlayer mMediaVideoPlayers = new ArrayListMediaPlayer(); private SurfaceView videoSurface[] = new SurfaceView[4]; private SurfaceHolder videoSurfaceHolder[] = new SurfaceHolder[4]; �...@override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); videoSurface[0] = (SurfaceView)findViewById(R.id.video1); videoSurfaceHolder[0] = videoSurface[0].getHolder(); videoSurfaceHolder[0].addCallback(this); videoSurfaceHolder[0].setType (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } private void playVideo(int res, SurfaceHolder holder) { MediaPlayer mediaplayer = new MediaPlayer(); AssetFileDescriptor afd = getResources().openRawResourceFd (res); try { mediaplayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); mediaplayer.setDisplay(holder); mediaplayer.prepare(); mediaplayer.start(); mMediaVideoPlayers.add(mediaplayer); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } public void surfaceCreated(SurfaceHolder holder) { playVideo(R.raw.video2, holder); } public void surfaceDestroyed(SurfaceHolder holder) { } } -- 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: cannot see video when using MediaPlayer
Why is it that if I change playVideo to this instead: private void playVideo(int res, SurfaceHolder holder) { MediaPlayer mediaplayer = new MediaPlayer(); AssetFileDescriptor afd = null; try { afd = this.getAssets().openFd(video1.mpg); } catch (IOException e1) { e1.printStackTrace(); } try { mediaplayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); mediaplayer.setDisplay(holder); mediaplayer.prepare(); mediaplayer.start(); // mMediaVideoPlayers.add(mediaplayer); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } I get the following exception W/System.err( 1694): java.io.IOException: Prepare failed.: status=0x1 W/PlayerDriver( 554): PVMFInfoErrorHandlingComplete However if I change this line mediaplayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset (), afd.getLength()); to mediaplayer.setDataSource(afd); I get no exception but still no video. On Jan 21, 2:33 pm, rukiman ruksh...@optushome.com.au wrote: That was how I had it originally, I tried again but still doesn't work On Jan 21, 2:18 pm, kavitha sunil kavithasuni...@gmail.com wrote: try using mediaplayer.setDisplay(videoSurfaceHolder[0]); On Thu, Jan 21, 2010 at 8:39 AM, rukiman ruksh...@optushome.com.au wrote: Attached is my code, I cannot see the video while playing a MPG file. What am I doing wrong here? Thanks. public class VideoTest extends Activity implements SurfaceHolder.Callback{ private ArrayListMediaPlayer mMediaVideoPlayers = new ArrayListMediaPlayer(); private SurfaceView videoSurface[] = new SurfaceView[4]; private SurfaceHolder videoSurfaceHolder[] = new SurfaceHolder[4]; �...@override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); videoSurface[0] = (SurfaceView)findViewById(R.id.video1); videoSurfaceHolder[0] = videoSurface[0].getHolder(); videoSurfaceHolder[0].addCallback(this); videoSurfaceHolder[0].setType (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } private void playVideo(int res, SurfaceHolder holder) { MediaPlayer mediaplayer = new MediaPlayer(); AssetFileDescriptor afd = getResources().openRawResourceFd (res); try { mediaplayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); mediaplayer.setDisplay(holder); mediaplayer.prepare(); mediaplayer.start(); mMediaVideoPlayers.add(mediaplayer); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } public void surfaceCreated(SurfaceHolder holder) { playVideo(R.raw.video2, holder); } public void surfaceDestroyed(SurfaceHolder holder) { } } -- 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: cannot see video when using MediaPlayer
ok i thought I would try the ApiDemo that comes with android. what path should I put in here? Is /sdcard/video2.mpg correct as that is where I have placed video2.mpg. However even ApiDemo doesn't play the video it comes up with the same error. W/MediaPlayer( 750): info/warning (1, 26) E/PlayerDriver( 31): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported E/MediaPlayer( 750): error (1, -4) E/MediaPlayerDemo( 750): error: Prepare failed.: status=0x1 E/MediaPlayerDemo( 750): java.io.IOException: Prepare failed.: status=0x1 E/MediaPlayerDemo( 750): at android.media.MediaPlayer.prepare(Native Method) E/MediaPlayerDemo( 750): at com.example.android.apis.media.MediaPlayerDemo_Video.playVideo (MediaPlayerDemo_Video.java:125) E/MediaPlayerDemo( 750): at com.example.android.apis.media.MediaPlayerDemo_Video.surfaceCreated (MediaPlayerDemo_Video.java:181) E/MediaPlayerDemo( 750): at android.view.SurfaceView.updateWindow (SurfaceView.java:454) E/MediaPlayerDemo( 750): at android.view.SurfaceView.dispatchDraw (SurfaceView.java:287) E/MediaPlayerDemo( 750): at android.view.ViewGroup.drawChild (ViewGroup.java:1524) E/MediaPlayerDemo( 750): at android.view.ViewGroup.dispatchDraw (ViewGroup.java:1256) /* * TODO: Set the path variable to a local media file path. */ path = /sdcard/video2.mpg; if (path == ) { // Tell the user to provide a media file URL. Toast .makeText( MediaPlayerDemo_Video.this, Please edit MediaPlayerDemo_Video Activity, + and set the path variable to your media file path. + Your media file must be stored on sdcard., Toast.LENGTH_LONG).show(); } On Jan 21, 3:20 pm, kavitha sunil kavithasuni...@gmail.com wrote: Try printing your argument to data source and see if it is proper. Also you can first try playing a 3gp/mp4 file present on the sdcard to see if some video is being played or not. On Thu, Jan 21, 2010 at 9:03 AM, rukiman ruksh...@optushome.com.au wrote: That was how I had it originally, I tried again but still doesn't work On Jan 21, 2:18 pm, kavitha sunil kavithasuni...@gmail.com wrote: try using mediaplayer.setDisplay(videoSurfaceHolder[0]); On Thu, Jan 21, 2010 at 8:39 AM, rukiman ruksh...@optushome.com.au wrote: Attached is my code, I cannot see the video while playing a MPG file. What am I doing wrong here? Thanks. public class VideoTest extends Activity implements SurfaceHolder.Callback{ private ArrayListMediaPlayer mMediaVideoPlayers = new ArrayListMediaPlayer(); private SurfaceView videoSurface[] = new SurfaceView[4]; private SurfaceHolder videoSurfaceHolder[] = new SurfaceHolder[4]; �...@override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); videoSurface[0] = (SurfaceView)findViewById(R.id.video1); videoSurfaceHolder[0] = videoSurface[0].getHolder(); videoSurfaceHolder[0].addCallback(this); videoSurfaceHolder[0].setType (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } private void playVideo(int res, SurfaceHolder holder) { MediaPlayer mediaplayer = new MediaPlayer(); AssetFileDescriptor afd = getResources().openRawResourceFd (res); try { mediaplayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); mediaplayer.setDisplay(holder); mediaplayer.prepare(); mediaplayer.start(); mMediaVideoPlayers.add(mediaplayer); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } public void surfaceCreated(SurfaceHolder holder) { playVideo(R.raw.video2, holder); } public void surfaceDestroyed(SurfaceHolder holder) { } } -- 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
[android-developers] instances of MediaPlayer
Is it possible to have two instances of MediaPlayer to play sounds/ video? How many instances are actually allowed? I can see from the Javadocs that there is a limited amount of instances of MediaPlayer allowed. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: using soundPool but sound plays after a delay, sound is lagging
Ok turns out that this is only an issue on the emulator. On the hardware everything sounds ok. Another reason to test on the hardware :) On Dec 20 2009, 7:41 pm, rukiman ruksh...@optushome.com.au wrote: Is there any difference insoundPoolbetween OGGs and MP3s? On Dec 19, 8:12 pm, rukiman ruksh...@optushome.com.au wrote: Some feedback. I have noticed thesoundis pretty instant and great when there isn't anothersoundeffect being played, otherwise the delay is pretty bad. So say if I select a piece then thesoundeffect is instant, however if I quickly select another piece as thesoundis being played, there is a very big noticeable delay before thesound effect is heard. On Dec 19, 7:57 pm, rukiman ruksh...@optushome.com.au wrote: seems like I was wrong. Profiling shows 60% is spent on getting the audio service and setting up the volume. Only 40% is spent on the actual play function. So would seem like I setting up the volume before hand is the way to go. I'll try that out and see how things go. On Dec 19, 7:46 pm, rukiman ruksh...@optushome.com.au wrote: I cannot quatify it but it is very noticeable and feels wrong when playing my game. for example I play asoundwhen a piece is selected however due to the lag thesoundfeel a bit out of place. I will try to profile whats going on here. But I thought perhaps someone may have had experienced this issue and come up with a solution or workaround. I will try Matts idea of calculating the volume before hand etc so I have to simply callsoundPool.play(). Only issue is that creates extra work i.e thesoundvolume might have changed by the user meanwhile and also I'm very doubtful if it will improve the lag. On Dec 19, 6:37 am, Robert Green rbgrn@gmail.com wrote: Can you quantify the lag? How much is it lagging? Lately I've been seeing my footstep sounds, which are individually triggered right and left steps, take 2-50ms to trigger for some reason. I'm not sure if it has something to do with the way the OGG is encoded, but I feel like it could. Perhaps theSoundPoolauthor would like to chime in and give us some hints? On Dec 18, 3:45 am, rukiman ruksh...@optushome.com.au wrote: I am using theSoundPoolas follows: Caching my sounds: // loadsoundeffects soundPool= newSoundPool(2, AudioManager.STREAM_MUSIC, 0); soundPoolMap = new HashMapInteger, Integer(); AssetFileDescriptor afd; try { afd = context.getAssets().openFd(sounds/piecemove.ogg); soundPoolMap.put(SOUND_PIECEMOVE,soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/piecestop.ogg); soundPoolMap.put(SOUND_PIECESTOP,soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceattack.ogg); soundPoolMap.put(SOUND_PIECEATTACK,soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceselect.ogg); soundPoolMap.put(SOUND_PIECESELECT,soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/selection.ogg); soundPoolMap.put(SOUND_MENUSELECTION,soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pageturn.ogg); soundPoolMap.put(SOUND_PAGETURN,soundPool.load(afd, 1)); } catch (IOException e) { e.printStackTrace(); } Function to play sounds: public static int playSound(Context context, intsound) { AudioManager mgr = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); float streamVolumeCurrent = mgr .getStreamVolume(AudioManager.STREAM_MUSIC); float streamVolumeMax = mgr .getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = streamVolumeCurrent / streamVolumeMax; /* Play thesoundwith the correct volume */ returnsoundPool .play(soundPoolMap.get(sound), volume, volume, 1, 0, 1f); } Playing asoundeffect i.e when button is clicked: Resources.playSound(context
[android-developers] gapless music loops in mp3 - how to?
Does anyone know how to make a music loop in mp3? I have the loop in OGG and it plays perfectly, when I convert it to MP3 there is some silence at the end of the loop before it starts again. I understand MP3 does not natively support gapless playback however I know there are some hacks to make it happen. i.e http://www.compuphase.com/mp3/mp3loops.htm However the utility in the above website didn't work for me. Basically I am trying to convert my music into a format supported by both iphone and android. iphone does not play OGGs unfortunately. Any ideas how to get the mp3 gapless? Or alternatively is there another music format that is gapless and supported by both iphone and android? 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: gapless music loops in mp3 - how to?
I read somewhere that opencore which is used by android does not support gapless loop play which is what is used to play MP3s however OGG are not played using opencore and can support gapless loop play. Is that still valid? On Jan 11, 12:45 pm, OldSkoolMark m...@sublimeslime.com wrote: Could be the program you used to convert the OGG to MP3. I've had similar issues with both Cubase and Audacity padding my clips with silence. I had good luck with Wavosaur (free). On Jan 10, 4:23 pm, rukiman ruksh...@optushome.com.au wrote: Does anyone know how to make a music loop in mp3? I have the loop in OGG and it plays perfectly, when I convert it to MP3 there is some silence at the end of the loop before it starts again. I understand MP3 does not natively support gapless playback however I know there are some hacks to make it happen. i.ehttp://www.compuphase.com/mp3/mp3loops.htm However the utility in the above website didn't work for me. Basically I am trying to convert my music into a format supported by both iphone and android. iphone does not play OGGs unfortunately. Any ideas how to get the mp3 gapless? Or alternatively is there another music format that is gapless and supported by both iphone and android? Thanks. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: using soundPool but sound plays after a delay, sound is lagging
Is there any difference in soundPool between OGGs and MP3s? On Dec 19, 8:12 pm, rukiman ruksh...@optushome.com.au wrote: Some feedback. I have noticed thesoundis pretty instant and great when there isn't anothersoundeffect being played, otherwise the delay is pretty bad. So say if I select a piece then thesoundeffect is instant, however if I quickly select another piece as thesoundis being played, there is a very big noticeable delay before thesound effect is heard. On Dec 19, 7:57 pm, rukiman ruksh...@optushome.com.au wrote: seems like I was wrong. Profiling shows 60% is spent on getting the audio service and setting up the volume. Only 40% is spent on the actual play function. So would seem like I setting up the volume before hand is the way to go. I'll try that out and see how things go. On Dec 19, 7:46 pm, rukiman ruksh...@optushome.com.au wrote: I cannot quatify it but it is very noticeable and feels wrong when playing my game. for example I play asoundwhen a piece is selected however due to the lag thesoundfeel a bit out of place. I will try to profile whats going on here. But I thought perhaps someone may have had experienced this issue and come up with a solution or workaround. I will try Matts idea of calculating the volume before hand etc so I have to simply call soundPool.play(). Only issue is that creates extra work i.e thesoundvolume might have changed by the user meanwhile and also I'm very doubtful if it will improve the lag. On Dec 19, 6:37 am, Robert Green rbgrn@gmail.com wrote: Can you quantify the lag? How much is it lagging? Lately I've been seeing my footstep sounds, which are individually triggered right and left steps, take 2-50ms to trigger for some reason. I'm not sure if it has something to do with the way the OGG is encoded, but I feel like it could. Perhaps the SoundPool author would like to chime in and give us some hints? On Dec 18, 3:45 am, rukiman ruksh...@optushome.com.au wrote: I am using the SoundPool as follows: Caching my sounds: // loadsoundeffects soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); soundPoolMap = new HashMapInteger, Integer(); AssetFileDescriptor afd; try { afd = context.getAssets().openFd(sounds/piecemove.ogg); soundPoolMap.put(SOUND_PIECEMOVE, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/piecestop.ogg); soundPoolMap.put(SOUND_PIECESTOP, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceattack.ogg); soundPoolMap.put(SOUND_PIECEATTACK, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceselect.ogg); soundPoolMap.put(SOUND_PIECESELECT, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/selection.ogg); soundPoolMap.put(SOUND_MENUSELECTION, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pageturn.ogg); soundPoolMap.put(SOUND_PAGETURN, soundPool.load(afd, 1)); } catch (IOException e) { e.printStackTrace(); } Function to play sounds: public static int playSound(Context context, intsound) { AudioManager mgr = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); float streamVolumeCurrent = mgr .getStreamVolume(AudioManager.STREAM_MUSIC); float streamVolumeMax = mgr .getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = streamVolumeCurrent / streamVolumeMax; /* Play thesoundwith the correct volume */ return soundPool .play(soundPoolMap.get(sound), volume, volume, 1, 0, 1f); } Playing asoundeffect i.e when button is clicked: Resources.playSound(context, Resources.SOUND_PIECESELECT); However as I said thesoundis lagging. What can I do to improve this? All my sounds are OGG file format. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email
[android-developers] Re: using soundPool but sound plays after a delay, sound is lagging
I cannot quatify it but it is very noticeable and feels wrong when playing my game. for example I play a sound when a piece is selected however due to the lag the sound feel a bit out of place. I will try to profile whats going on here. But I thought perhaps someone may have had experienced this issue and come up with a solution or workaround. I will try Matts idea of calculating the volume before hand etc so I have to simply call soundPool.play(). Only issue is that creates extra work i.e the sound volume might have changed by the user meanwhile and also I'm very doubtful if it will improve the lag. On Dec 19, 6:37 am, Robert Green rbgrn@gmail.com wrote: Can you quantify the lag? How much is it lagging? Lately I've been seeing my footstep sounds, which are individually triggered right and left steps, take 2-50ms to trigger for some reason. I'm not sure if it has something to do with the way the OGG is encoded, but I feel like it could. Perhaps the SoundPool author would like to chime in and give us some hints? On Dec 18, 3:45 am, rukiman ruksh...@optushome.com.au wrote: I am using the SoundPool as follows: Caching my sounds: // loadsoundeffects soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); soundPoolMap = new HashMapInteger, Integer(); AssetFileDescriptor afd; try { afd = context.getAssets().openFd(sounds/piecemove.ogg); soundPoolMap.put(SOUND_PIECEMOVE, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/piecestop.ogg); soundPoolMap.put(SOUND_PIECESTOP, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceattack.ogg); soundPoolMap.put(SOUND_PIECEATTACK, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceselect.ogg); soundPoolMap.put(SOUND_PIECESELECT, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/selection.ogg); soundPoolMap.put(SOUND_MENUSELECTION, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pageturn.ogg); soundPoolMap.put(SOUND_PAGETURN, soundPool.load(afd, 1)); } catch (IOException e) { e.printStackTrace(); } Function to play sounds: public static int playSound(Context context, intsound) { AudioManager mgr = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); float streamVolumeCurrent = mgr .getStreamVolume(AudioManager.STREAM_MUSIC); float streamVolumeMax = mgr .getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = streamVolumeCurrent / streamVolumeMax; /* Play thesoundwith the correct volume */ return soundPool .play(soundPoolMap.get(sound), volume, volume, 1, 0, 1f); } Playing asoundeffect i.e when button is clicked: Resources.playSound(context, Resources.SOUND_PIECESELECT); However as I said thesoundis lagging. What can I do to improve this? All my sounds are OGG file format. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: using soundPool but sound plays after a delay, sound is lagging
seems like I was wrong. Profiling shows 60% is spent on getting the audio service and setting up the volume. Only 40% is spent on the actual play function. So would seem like I setting up the volume before hand is the way to go. I'll try that out and see how things go. On Dec 19, 7:46 pm, rukiman ruksh...@optushome.com.au wrote: I cannot quatify it but it is very noticeable and feels wrong when playing my game. for example I play a sound when a piece is selected however due to the lag the sound feel a bit out of place. I will try to profile whats going on here. But I thought perhaps someone may have had experienced this issue and come up with a solution or workaround. I will try Matts idea of calculating the volume before hand etc so I have to simply call soundPool.play(). Only issue is that creates extra work i.e the sound volume might have changed by the user meanwhile and also I'm very doubtful if it will improve the lag. On Dec 19, 6:37 am, Robert Green rbgrn@gmail.com wrote: Can you quantify the lag? How much is it lagging? Lately I've been seeing my footstep sounds, which are individually triggered right and left steps, take 2-50ms to trigger for some reason. I'm not sure if it has something to do with the way the OGG is encoded, but I feel like it could. Perhaps the SoundPool author would like to chime in and give us some hints? On Dec 18, 3:45 am, rukiman ruksh...@optushome.com.au wrote: I am using the SoundPool as follows: Caching my sounds: // loadsoundeffects soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); soundPoolMap = new HashMapInteger, Integer(); AssetFileDescriptor afd; try { afd = context.getAssets().openFd(sounds/piecemove.ogg); soundPoolMap.put(SOUND_PIECEMOVE, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/piecestop.ogg); soundPoolMap.put(SOUND_PIECESTOP, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceattack.ogg); soundPoolMap.put(SOUND_PIECEATTACK, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceselect.ogg); soundPoolMap.put(SOUND_PIECESELECT, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/selection.ogg); soundPoolMap.put(SOUND_MENUSELECTION, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pageturn.ogg); soundPoolMap.put(SOUND_PAGETURN, soundPool.load(afd, 1)); } catch (IOException e) { e.printStackTrace(); } Function to play sounds: public static int playSound(Context context, intsound) { AudioManager mgr = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); float streamVolumeCurrent = mgr .getStreamVolume(AudioManager.STREAM_MUSIC); float streamVolumeMax = mgr .getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = streamVolumeCurrent / streamVolumeMax; /* Play thesoundwith the correct volume */ return soundPool .play(soundPoolMap.get(sound), volume, volume, 1, 0, 1f); } Playing asoundeffect i.e when button is clicked: Resources.playSound(context, Resources.SOUND_PIECESELECT); However as I said thesoundis lagging. What can I do to improve this? All my sounds are OGG file format. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: using soundPool but sound plays after a delay, sound is lagging
ok i take it back, doesnt seem to make a difference. I think the lag is in soundPool.play() itself. Anyone got a workaround? On Dec 19, 7:57 pm, rukiman ruksh...@optushome.com.au wrote: seems like I was wrong. Profiling shows 60% is spent on getting the audio service and setting up the volume. Only 40% is spent on the actual play function. So would seem like I setting up the volume before hand is the way to go. I'll try that out and see how things go. On Dec 19, 7:46 pm, rukiman ruksh...@optushome.com.au wrote: I cannot quatify it but it is very noticeable and feels wrong when playing my game. for example I play a sound when a piece is selected however due to the lag the sound feel a bit out of place. I will try to profile whats going on here. But I thought perhaps someone may have had experienced this issue and come up with a solution or workaround. I will try Matts idea of calculating the volume before hand etc so I have to simply call soundPool.play(). Only issue is that creates extra work i.e the sound volume might have changed by the user meanwhile and also I'm very doubtful if it will improve the lag. On Dec 19, 6:37 am, Robert Green rbgrn@gmail.com wrote: Can you quantify the lag? How much is it lagging? Lately I've been seeing my footstep sounds, which are individually triggered right and left steps, take 2-50ms to trigger for some reason. I'm not sure if it has something to do with the way the OGG is encoded, but I feel like it could. Perhaps the SoundPool author would like to chime in and give us some hints? On Dec 18, 3:45 am, rukiman ruksh...@optushome.com.au wrote: I am using the SoundPool as follows: Caching my sounds: // loadsoundeffects soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); soundPoolMap = new HashMapInteger, Integer(); AssetFileDescriptor afd; try { afd = context.getAssets().openFd(sounds/piecemove.ogg); soundPoolMap.put(SOUND_PIECEMOVE, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/piecestop.ogg); soundPoolMap.put(SOUND_PIECESTOP, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceattack.ogg); soundPoolMap.put(SOUND_PIECEATTACK, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceselect.ogg); soundPoolMap.put(SOUND_PIECESELECT, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/selection.ogg); soundPoolMap.put(SOUND_MENUSELECTION, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pageturn.ogg); soundPoolMap.put(SOUND_PAGETURN, soundPool.load(afd, 1)); } catch (IOException e) { e.printStackTrace(); } Function to play sounds: public static int playSound(Context context, intsound) { AudioManager mgr = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); float streamVolumeCurrent = mgr .getStreamVolume(AudioManager.STREAM_MUSIC); float streamVolumeMax = mgr .getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = streamVolumeCurrent / streamVolumeMax; /* Play thesoundwith the correct volume */ return soundPool .play(soundPoolMap.get(sound), volume, volume, 1, 0, 1f); } Playing asoundeffect i.e when button is clicked: Resources.playSound(context, Resources.SOUND_PIECESELECT); However as I said thesoundis lagging. What can I do to improve this? All my sounds are OGG file format. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: using soundPool but sound plays after a delay, sound is lagging
Some feedback. I have noticed the sound is pretty instant and great when there isn't another sound effect being played, otherwise the delay is pretty bad. So say if I select a piece then the sound effect is instant, however if I quickly select another piece as the sound is being played, there is a very big noticeable delay before the sound effect is heard. On Dec 19, 7:57 pm, rukiman ruksh...@optushome.com.au wrote: seems like I was wrong. Profiling shows 60% is spent on getting the audio service and setting up the volume. Only 40% is spent on the actual play function. So would seem like I setting up the volume before hand is the way to go. I'll try that out and see how things go. On Dec 19, 7:46 pm, rukiman ruksh...@optushome.com.au wrote: I cannot quatify it but it is very noticeable and feels wrong when playing my game. for example I play a sound when a piece is selected however due to the lag the sound feel a bit out of place. I will try to profile whats going on here. But I thought perhaps someone may have had experienced this issue and come up with a solution or workaround. I will try Matts idea of calculating the volume before hand etc so I have to simply call soundPool.play(). Only issue is that creates extra work i.e the sound volume might have changed by the user meanwhile and also I'm very doubtful if it will improve the lag. On Dec 19, 6:37 am, Robert Green rbgrn@gmail.com wrote: Can you quantify the lag? How much is it lagging? Lately I've been seeing my footstep sounds, which are individually triggered right and left steps, take 2-50ms to trigger for some reason. I'm not sure if it has something to do with the way the OGG is encoded, but I feel like it could. Perhaps the SoundPool author would like to chime in and give us some hints? On Dec 18, 3:45 am, rukiman ruksh...@optushome.com.au wrote: I am using the SoundPool as follows: Caching my sounds: // loadsoundeffects soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); soundPoolMap = new HashMapInteger, Integer(); AssetFileDescriptor afd; try { afd = context.getAssets().openFd(sounds/piecemove.ogg); soundPoolMap.put(SOUND_PIECEMOVE, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/piecestop.ogg); soundPoolMap.put(SOUND_PIECESTOP, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceattack.ogg); soundPoolMap.put(SOUND_PIECEATTACK, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceselect.ogg); soundPoolMap.put(SOUND_PIECESELECT, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/selection.ogg); soundPoolMap.put(SOUND_MENUSELECTION, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pageturn.ogg); soundPoolMap.put(SOUND_PAGETURN, soundPool.load(afd, 1)); } catch (IOException e) { e.printStackTrace(); } Function to play sounds: public static int playSound(Context context, intsound) { AudioManager mgr = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); float streamVolumeCurrent = mgr .getStreamVolume(AudioManager.STREAM_MUSIC); float streamVolumeMax = mgr .getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = streamVolumeCurrent / streamVolumeMax; /* Play thesoundwith the correct volume */ return soundPool .play(soundPoolMap.get(sound), volume, volume, 1, 0, 1f); } Playing asoundeffect i.e when button is clicked: Resources.playSound(context, Resources.SOUND_PIECESELECT); However as I said thesoundis lagging. What can I do to improve this? All my sounds are OGG file format. -- 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] using soundPool but sound plays after a delay, sound is lagging
I am using the SoundPool as follows: Caching my sounds: // load sound effects soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); soundPoolMap = new HashMapInteger, Integer(); AssetFileDescriptor afd; try { afd = context.getAssets().openFd(sounds/piecemove.ogg); soundPoolMap.put(SOUND_PIECEMOVE, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/piecestop.ogg); soundPoolMap.put(SOUND_PIECESTOP, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceattack.ogg); soundPoolMap.put(SOUND_PIECEATTACK, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pieceselect.ogg); soundPoolMap.put(SOUND_PIECESELECT, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/selection.ogg); soundPoolMap.put(SOUND_MENUSELECTION, soundPool.load(afd, 1)); afd = context.getAssets().openFd(sounds/pageturn.ogg); soundPoolMap.put(SOUND_PAGETURN, soundPool.load(afd, 1)); } catch (IOException e) { e.printStackTrace(); } Function to play sounds: public static int playSound(Context context, int sound) { AudioManager mgr = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); float streamVolumeCurrent = mgr .getStreamVolume(AudioManager.STREAM_MUSIC); float streamVolumeMax = mgr .getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = streamVolumeCurrent / streamVolumeMax; /* Play the sound with the correct volume */ return soundPool .play(soundPoolMap.get(sound), volume, volume, 1, 0, 1f); } Playing a sound effect i.e when button is clicked: Resources.playSound(context, Resources.SOUND_PIECESELECT); However as I said the sound is lagging. What can I do to improve this? All my sounds are OGG file format. -- 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] how to stop screen from dimming
In my game because it is a board game, I do not want the screen to timout which the user is playing my game. Any idea on how to do this? -- 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] configChanges and orientation - unexpected behaviour
I wrote a simple test app which specifies android:configChanges=orientation also android:screenOrientation=portrait and in my activity I logged whenever onDestroy() and onConfigurationChanged() gets called. Now according to the docs, I was expecting onConfigurationChanged() to get called whenever I press CTRL-F11 to change the emulator orientation. However this is not the case instead onDestroy() gets called. Why is this so? When pressing CTRL-F11 I can see my activity is in portrait mode regardless of orientation as I expected. But why is it still getting destroyed? -- 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: splash screen and low memory
I guess there's no choice but for each activity in my game to check if resources are loaded if not load them with a splash screen? On Nov 30, 11:35 am, rukiman ruksh...@optushome.com.au wrote: In my game asplashscreenis shown which preloads all the sound/ bitmap resources to be used by the game. The game consists of other activities that all depend on resources i.e menu activities, game activity etc. However when simulating low memory conditions in the emulator, I noticed that our game process was being killed and when pressing the back key the last activity that was onscreenof the game is loaded, however it crashes as the resources are not in memory. Does that mean every activity in my game needs to check is the resources are loaded and if not show up thesplashscreenactivity and load the resources before returning to the activity? Is there a nicer way of doing this? Can't I just make the system follow the normal pattern of starting my game i.esplashscreenand then display the menu and then the user can choose to resume the game themselves. Is this possible? -- 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] splash screen and low memory
In my game a splash screen is shown which preloads all the sound/ bitmap resources to be used by the game. The game consists of other activities that all depend on resources i.e menu activities, game activity etc. However when simulating low memory conditions in the emulator, I noticed that our game process was being killed and when pressing the back key the last activity that was on screen of the game is loaded, however it crashes as the resources are not in memory. Does that mean every activity in my game needs to check is the resources are loaded and if not show up the splash screen activity and load the resources before returning to the activity? Is there a nicer way of doing this? Can't I just make the system follow the normal pattern of starting my game i.e splash screen and then display the menu and then the user can choose to resume the game themselves. Is this possible? -- 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] force browser into portrait mode
is it possible to start the browser activity from my game but force it to be portrait regardless of orientation so that it matches the orientation of my game which is always in portrait regardless. -- 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 compatibility not quite right
Thanks for the info. OK I figured out instead of using fill_parent in width and height of my main LinearLayouts, I instead hardcode the HVGA size of 320 x 480px the aspect ratio is ok. The game is looking much better in compatible mode. Except seems like in compatible mode gravity of center_vertically is not working correctly? The container of the textview I am trying to center vertically is in a LinearLayout with height = 480px however it is still centering within the WVGA screen height. What can I do to fix this? I have to rely on compatible mode unfortunately as there is too many graphics to redraw for different resolutions and no money to pay the designer :D On Nov 22, 7:16 pm, Dianne Hackborn hack...@android.com wrote: On Sat, Nov 21, 2009 at 4:26 PM, Mark Murphy mmur...@commonsware.comwrote: DROID has been optimized to display wide-screen multimedia (movie) content at its native aspect ratio of 16/9. This is different from the HVGA aspect ratio of 3/2, which is the traditional computer screen format. What this means is that when content is scaled up to full screen, the horizontal (X*1.5) and vertical (Y*1.77) scaling factors are different. As a result, when displaying the same bitmap as a full screen background, round circles can appear as ovals, and squares are elongated to rectangles. http://developer.motorola.com/docstools/library/Support_for_Multiple_... I have no reason to believe this is DROID-specific, but rather is how Android scales things in WVGA800/WVGA854, when you do not supply your own pre-scaled resources. I think what they are trying to say is correct, but probably misleading. First, scaling is only done based on density, and does NOT change aspect ratio. If you are on a high density device, and your assets are medium density, they will be scaled by 1.5 in both width and height, period, end of story. What this Motorola doc is describing is what I would consider a special case. If you make a layout that is fill parent for both width and height, then on a WVGA of course it will be taller than on HVGA because the screen you are filling is taller. Now if you set a drawable as its background, the View class draws its background by simply stretching the drawable to fill its contents, so your bitmap will be stretched to fill whatever aspect ratio your layout has ended up being. This is just a matter of accounting for the screen being different sizes and designing your layout to adjust accordingly. You cannot control the aspect ratio, as that is dictated by the physical parameters of the screen. AFAIK, there is no Android equivalent of letterbox that would put black bars on either side of your app and give you a smaller virtual screen with 3/2 aspect ratio. We actually do a postage stamp for apps on large screens, since we found that a significant number of them broke when given so much extra space. However, the vast majority of existing apps work reasonably well when presented with a WVGA screen, so rather than cause all of the existing ones to not be able to use that space, we decided to not provide compatibility for that and live with the small handful that did have significant problems. But for someone writing an app today, this is fairly irrelevant, because if your app really can't use anything more than an HVGA screen then you really just need to design your layout to center or whatever you want your content in whatever screen you are running on. Also in my layout I am positioning some items using pixel positions. Should I convert these to dpi? If you mean dip (density-independent pixels), perhaps. It depends on what the pixels represent. There is no hard-and-fast rule. But the vast majority of time, yes, you do want to use dpis. However! The original post showed that the app was actually saying it can't deal with densities. This means the system will emulate a medium density screen on whatever density the device is, so 1 px == 1 dip. However, you really should not be saying that you don't support densities -- there are artifacts that can happen when doing this, such as font metrics not being quite right. If you are writing an app today, you really want to not put yourself in compatibility mode, and just write the app correctly. -- 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
[android-developers] Re: screen compatibility not quite right
Compatibility mode does not hide the fact that the screen is WVGA. The screen you see is still that tall, so any layout you do will be within that screen. But in here http://developer.android.com/reference/android/view/Gravity.html it says CENTER_VERTICAL = Place object in the vertical center of its container, not changing its size. So the parent of the textview is the LinearLayout (is this not its containter?). And if the LinearLayout is hardcoded to 480px height shouldn't that textview be centered within it instead of screen height centered? -- 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] screen compatibility not quite right
Ok I have put this in my manifest supports-screens android:anyDensity=false android:largeScreens=false android:normalScreens=true android:smallScreens=false android:resizeable=false/supports- screens first of all what is the resizeable attribute? It does not seem to be documented. This is working almost 90% for my game except when testing in WVGA screen resolution, all my images are scaled incorrectly, it is longer vertically than horizontally. I was expecting the screen compatibility to maintain aspect ratios as that of HVGA. Also in my layout I have a scrollview and it is designed in such a way that in HVGA when it is not scrolled down, the items are hidden away, however now in WVGA those things are shown. If the aspect ratio of HVGA is maintained I won't have this issue. How can I make sure the aspect ratio is maintained? Also in my layout I am positioning some items using pixel positions. Should I convert these to dpi? How do I calculate what dpi they should be? -- 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 compatibility not quite right
I thought I'd create my own specialized LinearLayout so that I can calculate the aspect ratio and center vertically. My game is only designed to be played in portrait mode. However this code doesn't seem to work. Spot what I am doing wrong? import android.content.Context; import android.util.AttributeSet; import android.view.ViewGroup; import android.widget.LinearLayout; public class SpecialLinearLayout extends LinearLayout { private final Context context; public SpecialLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; } protected void onLayout(boolean changed, int l, int t, int r, int b) { int width = r - l; int height = b - t; float aspect = 480.0f / 320.0f; int newheight = (int) Math.floor((float) width * (float) aspect); if(newheight != height) { // create top margins to center vertically ViewGroup.MarginLayoutParams margin = new ViewGroup.MarginLayoutParams(this.getLayoutParams()); margin.setMargins(0, 40, 0, 50); this.setLayoutParams(new LinearLayout.LayoutParams (margin)); } } } On Nov 22, 11:26 am, Mark Murphy mmur...@commonsware.com wrote: rukiman wrote: This is working almost 90% for my game except when testing in WVGA screen resolution, all my images are scaled incorrectly, it is longer vertically than horizontally. I was expecting the screen compatibility to maintain aspect ratios as that of HVGA. No. DROID has been optimized to display wide-screen multimedia (movie) content at its native aspect ratio of 16/9. This is different from the HVGA aspect ratio of 3/2, which is the traditional computer screen format. What this means is that when content is scaled up to full screen, the horizontal (X*1.5) and vertical (Y*1.77) scaling factors are different. As a result, when displaying the same bitmap as a full screen background, round circles can appear as ovals, and squares are elongated to rectangles. http://developer.motorola.com/docstools/library/Support_for_Multiple_... I have no reason to believe this is DROID-specific, but rather is how Android scales things in WVGA800/WVGA854, when you do not supply your own pre-scaled resources. Also in my layout I have a scrollview and it is designed in such a way that in HVGA when it is not scrolled down, the items are hidden away, however now in WVGA those things are shown. If the aspect ratio of HVGA is maintained I won't have this issue. How can I make sure the aspect ratio is maintained? You cannot control the aspect ratio, as that is dictated by the physical parameters of the screen. AFAIK, there is no Android equivalent of letterbox that would put black bars on either side of your app and give you a smaller virtual screen with 3/2 aspect ratio. Also in my layout I am positioning some items using pixel positions. Should I convert these to dpi? If you mean dip (density-independent pixels), perhaps. It depends on what the pixels represent. There is no hard-and-fast rule. How do I calculate what dpi they should be? 1px = 1dip at 160dpi (i.e., traditional normal screen density). -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: screen compatibility not quite right
I just put harcoded fake values for time being, instead of centering. I was expecting everything embedded with the linearlayout which is my main layout to be shrunk by the top and bottom margins I specified. On Nov 22, 1:25 pm, rukiman ruksh...@optushome.com.au wrote: I thought I'd create my own specialized LinearLayout so that I can calculate the aspect ratio and center vertically. My game is only designed to be played in portrait mode. However this code doesn't seem to work. Spot what I am doing wrong? import android.content.Context; import android.util.AttributeSet; import android.view.ViewGroup; import android.widget.LinearLayout; public class SpecialLinearLayout extends LinearLayout { private final Context context; public SpecialLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; } protected void onLayout(boolean changed, int l, int t, int r, int b) { int width = r - l; int height = b - t; float aspect = 480.0f / 320.0f; int newheight = (int) Math.floor((float) width * (float) aspect); if(newheight != height) { // create top margins to center vertically ViewGroup.MarginLayoutParams margin = new ViewGroup.MarginLayoutParams(this.getLayoutParams()); margin.setMargins(0, 40, 0, 50); this.setLayoutParams(new LinearLayout.LayoutParams (margin)); } } } On Nov 22, 11:26 am, Mark Murphy mmur...@commonsware.com wrote: rukiman wrote: This is working almost 90% for my game except when testing in WVGA screen resolution, all my images are scaled incorrectly, it is longer vertically than horizontally. I was expecting the screen compatibility to maintain aspect ratios as that of HVGA. No. DROID has been optimized to display wide-screen multimedia (movie) content at its native aspect ratio of 16/9. This is different from the HVGA aspect ratio of 3/2, which is the traditional computer screen format. What this means is that when content is scaled up to full screen, the horizontal (X*1.5) and vertical (Y*1.77) scaling factors are different. As a result, when displaying the same bitmap as a full screen background, round circles can appear as ovals, and squares are elongated to rectangles. http://developer.motorola.com/docstools/library/Support_for_Multiple_... I have no reason to believe this is DROID-specific, but rather is how Android scales things in WVGA800/WVGA854, when you do not supply your own pre-scaled resources. Also in my layout I have a scrollview and it is designed in such a way that in HVGA when it is not scrolled down, the items are hidden away, however now in WVGA those things are shown. If the aspect ratio of HVGA is maintained I won't have this issue. How can I make sure the aspect ratio is maintained? You cannot control the aspect ratio, as that is dictated by the physical parameters of the screen. AFAIK, there is no Android equivalent of letterbox that would put black bars on either side of your app and give you a smaller virtual screen with 3/2 aspect ratio. Also in my layout I am positioning some items using pixel positions. Should I convert these to dpi? If you mean dip (density-independent pixels), perhaps. It depends on what the pixels represent. There is no hard-and-fast rule. How do I calculate what dpi they should be? 1px = 1dip at 160dpi (i.e., traditional normal screen density). -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] memory leak in activity
In my app activity A creates activity B, however when the back key is pressed it goes back to activity A. This is a simplified version of my application. I would expect memory to be reclaimed when going back to Activity A. Going to activity B allocates more memory. I am using dumpsys meminfo to get the allocated kbs. How can I easily tell what memory is creeping? I do not keep any references to activity B. I know about the ddms allocation tracker, but wondering if there is a more better tool to figure this out. I read somewhere about someone during a heap dump. How do I do that? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] handling expensive operations in the UI thread - posting result from worker thread to UI thread
OK I'm reading this page: http://developer.android.com/guide/appendix/faq/commontasks.html#threading The code is as in the example (see below). In my application, the worker thread has done loading of large bitmaps, and I need to notify the UI thread the filename of the bitmap that was loaded as they get loaded. How can I notify the UI thread of the filename of the bitmap just loaded? I can see anyway to for updateResultsInUi() to be able to take a parameter from the example below. public class MyActivity extends Activity { [ . . . ] // Need handler for callbacks to the UI thread final Handler mHandler = new Handler(); // Create runnable for posting final Runnable mUpdateResults = new Runnable() { public void run() { updateResultsInUi(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); [ . . . ] } protected void startLongRunningOperation() { // Fire off a thread to do some work that we shouldn't do directly in the UI thread Thread t = new Thread() { public void run() { mResults = doSomethingExpensive(); mHandler.post(mUpdateResults); } }; t.start(); } private void updateResultsInUi() { // Back in the UI thread -- update our UI elements based on the data in mResults [ . . . ] } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: handling expensive operations in the UI thread - posting result from worker thread to UI thread
OK I should re-ask my question so its a bit more clearer. in updateResultsInUI() it is updating the results obtained from the doSomethingExpensive() which was calculated in the worker thread. Now what if doSomethingExpensive() is run in a loop continuously and each time it is executed I need to update something in the UI based on the result of doSomethingExpensive()? How can I achieve this? I cannot see how the code below will work for this scenario unless mHandler.post() was synchronous, i.e the UI thread will get notified before another doSomethingExpensive() is executed. This is the example of doSomethingExpensive running in a loop: protected void startLongRunningOperation() { // Fire off a thread to do some work that we shouldn't do directly in the UI thread Thread t = new Thread() { public void run() { while(true) { mResults = doSomethingExpensive(); mHandler.post(mUpdateResults); } } }; t.start(); } On Sep 17, 11:07 am, rukiman ruksh...@optushome.com.au wrote: OK I'm reading this page:http://developer.android.com/guide/appendix/faq/commontasks.html#thre... The code is as in the example (see below). In my application, the worker thread has done loading of large bitmaps, and I need to notify the UI thread the filename of the bitmap that was loaded as they get loaded. How can I notify the UI thread of the filename of the bitmap just loaded? I can see anyway to for updateResultsInUi() to be able to take a parameter from the example below. public class MyActivity extends Activity { [ . . . ] // Need handler for callbacks to the UI thread final Handler mHandler = new Handler(); // Create runnable for posting final Runnable mUpdateResults = new Runnable() { public void run() { updateResultsInUi(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); [ . . . ] } protected void startLongRunningOperation() { // Fire off a thread to do some work that we shouldn't do directly in the UI thread Thread t = new Thread() { public void run() { mResults = doSomethingExpensive(); mHandler.post(mUpdateResults); } }; t.start(); } private void updateResultsInUi() { // Back in the UI thread -- update our UI elements based on the data in mResults [ . . . ] } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: handling expensive operations in the UI thread - posting result from worker thread to UI thread
Thanks for the tip! Reading on it now, and looks exactly like what I wanted. On Sep 17, 11:10 am, Jason Proctor jason.android.li...@gmail.com wrote: i'd do this with an AsyncTask and use the progress reporting feature to communicate state to the UI thread. AsyncTask ftw! OK I'm reading this page: http://developer.android.com/guide/appendix/faq/commontasks.html#thre... The code is as in the example (see below). In my application, the worker thread has done loading of large bitmaps, and I need to notify the UI thread the filename of the bitmap that was loaded as they get loaded. How can I notify the UI thread of the filename of the bitmap just loaded? I can see anyway to for updateResultsInUi() to be able to take a parameter from the example below. public class MyActivity extends Activity { [ . . . ] // Need handler for callbacks to the UI thread final Handler mHandler = new Handler(); // Create runnable for posting final Runnable mUpdateResults = new Runnable() { public void run() { updateResultsInUi(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); [ . . . ] } protected void startLongRunningOperation() { // Fire off a thread to do some work that we shouldn't do directly in the UI thread Thread t = new Thread() { public void run() { mResults = doSomethingExpensive(); mHandler.post(mUpdateResults); } }; t.start(); } private void updateResultsInUi() { // Back in the UI thread -- update our UI elements based on the data in mResults [ . . . ] } } -- jason.vp.engineering.particle --~--~-~--~~~---~--~~ 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: task affinity - what is it?
Can anyone recommend a good book or URL that explains affinity well? Doing a search for affinity in these forums bring up nothing. On Sep 1, 2:08 pm, rukiman ruksh...@optushome.com.au wrote: I am trying to understand what isaffinitygrouping and what its purpose is? Also trying to understand activity reparenting. I have read the javadocs for these but still not sure when and when you would use 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] task affinity - what is it?
I am trying to understand what is affinity grouping and what its purpose is? Also trying to understand activity reparenting. I have read the javadocs for these but still not sure when and when you would use 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: serialization is taking too long, what can I do in terms of the activity life cycle
Ok I spent alot of time over the weekend working on this. And I'm out of options. I profiled it and most of the time is spend on writeObject as expected. This game has a large object graph with cyclic references and hence it is taking 52 seconds on the emulator to serialize and about half to deserialize. I though I would go through my classes and explicity create a writeObject() and readObject() functions where I explicility write out all the fields myself. private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(board); out.writeObject(guesser); out.writeObject(planner); out.writeInt(possibleMoves.size()); for(int i=0; ipossibleMoves.size(); i++) { out.writeObject(possibleMoves.elementAt(i)); } out.writeInt(lastCaptureCounter); out.writeInt(aiSkillLevel); } private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { board = (StrategoBoard) in.readObject(); guesser = (Guesser) in.readObject(); planner = (Planner) in.readObject(); int length = in.readInt(); possibleMoves = new VectorMove(length); for(int i=0; ilength; i++) { possibleMoves.add(i, (Move) in.readObject()); } lastCaptureCounter = in.readInt(); aiSkillLevel = in.readInt(); } The above is just an example of one of the many classes I have done this to. I was hoping this would be quicker. However because I still have to call writeObject() it seems like I am not saving any time according to the profiler there isn't any noticeable difference in speed. So I started looking into other alternatives like xstream but that didnt work as it couldn't serialize some of my fields in my class but it is calling writeObject so doubt it will be any faster. So what are my alternatives to not using Java serialization? I can probably convert Serializable to Externalizable and then call the writeExternal and readExternal functions directly myself as they are public functions. However do you think this will be any faster? Also if I am doing this, I am not sure how to handle references to objects. I don't really want to serialize X copies of the same thing, as then the code will most likely be broken once it is deserialized. Any suggestions are greatly welcome. I'm out of ideas and quite new to serialization. I have in my research come across http://www.eishay.com/2009/03/more-on-benchmarking-java-serialization.html protobuf seems like it is fast but slow in object creation. Would you recommended doing it this way? I'm confused. :S On Jul 30, 11:53 am, rukiman ruksh...@optushome.com.au wrote: I must have been very very patient the first time round or lost track of time because last night, I got back to the game and timed theserializationand it took about a min from hitting the back key to displaying the menu! Also this delay didn't exist until my recent changes to do with theserialization. I will profile tonight or tomorrow and report back my findings. On Jul 29, 6:14 am, Dan Bornstein danf...@android.com wrote: On Mon, Jul 27, 2009 at 9:24 PM, Dianne Hackborn hack...@android.com wrote: On Mon, Jul 27, 2009 at 8:35 PM, rukiman ruksh...@optushome.com.au wrote: Yes I did mean Javaserialization. Any reason why I can't use it (apart from it beingslow) ? Um... it being super-crazyslow? :) It's also very fragile, in that small innocuous-seeming changes to your code could subtly break yourserialization, and, worse, small innocuous-seeming changes to the platform code could also break it. We on the Android team of course endeavor not to break application code, but we are not perfect by any stretch of the imagination, and serializationis a known tricky area to get right. Personally, I might useserializationwhen prototyping a system, but I would be very reluctant to include its use in a finished product. All that being said, if you happen to profile yourserialization-using code and find that the slowness is directly due to code in the core library (classes in java.*, javax.*, or org.apache.*), I would appreciate a bug report detailing your observations. Cheers, -dan --~--~-~--~~~---~--~~ 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] disable scrolling touch events in ScrollView, just want to to scroll programmatically
Just wondering if there is an easier way to simply stop ScrollView from being scrolled via touch inputs? I will programmatically get the ScrollView to scroll to top or bottom. As a last resort, I guess I will have to inherit from ScrollView and capture all the ontouch events. But wondering if there is an easier way before I take this approach? 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: disable scrolling touch events in ScrollView, just want to to scroll programmatically
LinearLayout will not work for me as what I want to put in the ScrollView is much larger than the screen. So I think it is easier to use ScrollView as it knows to not render the widgets until it scrolls onto view? Unless can you get that behaviour using a LinearLayout? On Aug 10, 7:32 pm, Atif Gulzar atif.gul...@gmail.com wrote: do not use scrollView at all and use LinearLauout and use combination of touch events and scrollBy(int, int)file:///E:/android-sdk-windows-1.5_r3/docs/reference/android/view/View .html#scrollBy%28int,%20int%29, scrollTo(int, int)file:///E:/android-sdk-windows-1.5_r3/docs/reference/android/view/View .html#scrollTo%28int,%20int%29. By this way you can also achieve horizontal scrolling. -- Best Regards, Atif Gulzar I Unicode, ɹɐzlnƃ ɟıʇɐ On Mon, Aug 10, 2009 at 2:50 PM, rukiman ruksh...@optushome.com.au wrote: Just wondering if there is an easier way to simply stop ScrollView from being scrolled via touch inputs? I will programmatically get the ScrollView to scroll to top or bottom. As a last resort, I guess I will have to inherit from ScrollView and capture all the ontouch events. But wondering if there is an easier way before I take this approach? 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: disable scrolling touch events in ScrollView, just want to to scroll programmatically
Also I really want to use the .smoothScrollBy() function of the scrollView. On Aug 10, 7:39 pm, rukiman ruksh...@optushome.com.au wrote: LinearLayout will not work for me as what I want to put in the ScrollView is much larger than the screen. So I think it is easier to use ScrollView as it knows to not render the widgets until it scrolls onto view? Unless can you get that behaviour using a LinearLayout? On Aug 10, 7:32 pm, Atif Gulzar atif.gul...@gmail.com wrote: do not use scrollView at all and use LinearLauout and use combination of touch events and scrollBy(int, int)file:///E:/android-sdk-windows-1.5_r3/docs/reference/android/view/View .html#scrollBy%28int,%20int%29, scrollTo(int, int)file:///E:/android-sdk-windows-1.5_r3/docs/reference/android/view/View .html#scrollTo%28int,%20int%29. By this way you can also achieve horizontal scrolling. -- Best Regards, Atif Gulzar I Unicode, ɹɐzlnƃ ɟıʇɐ On Mon, Aug 10, 2009 at 2:50 PM, rukiman ruksh...@optushome.com.au wrote: Just wondering if there is an easier way to simply stop ScrollView from being scrolled via touch inputs? I will programmatically get the ScrollView to scroll to top or bottom. As a last resort, I guess I will have to inherit from ScrollView and capture all the ontouch events. But wondering if there is an easier way before I take this approach? 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: disable scrolling touch events in ScrollView, just want to to scroll programmatically
Ok my requirements for this were 1) need scrollview to do smooth scrolling however only wanted scrolling to occur programmatically and not via touch 2) scrollview hijacks some touch events that stop the inner widgets from working so didnt want this. so I had to extend scrollview to meet my requirements: import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.ScrollView; public class ScrollViewNoScroll extends ScrollView { public ScrollViewNoScroll(Context context, AttributeSet attrs) { super(context, attrs); } public boolean onTouchEvent(MotionEvent ev) { return true; } public boolean onInterceptTouchEvent(MotionEvent ev) { return false; } } On Aug 10, 7:44 pm, rukiman ruksh...@optushome.com.au wrote: Also I really want to use the .smoothScrollBy() function of the scrollView. On Aug 10, 7:39 pm, rukiman ruksh...@optushome.com.au wrote: LinearLayout will not work for me as what I want to put in the ScrollView is much larger than the screen. So I think it is easier to use ScrollView as it knows to not render the widgets until it scrolls onto view? Unless can you get that behaviour using a LinearLayout? On Aug 10, 7:32 pm, Atif Gulzar atif.gul...@gmail.com wrote: do not use scrollView at all and use LinearLauout and use combination of touch events and scrollBy(int, int)file:///E:/android-sdk-windows-1.5_r3/docs/reference/android/view/View .html#scrollBy%28int,%20int%29, scrollTo(int, int)file:///E:/android-sdk-windows-1.5_r3/docs/reference/android/view/View .html#scrollTo%28int,%20int%29. By this way you can also achieve horizontal scrolling. -- Best Regards, Atif Gulzar I Unicode, ɹɐzlnƃ ɟıʇɐ On Mon, Aug 10, 2009 at 2:50 PM, rukiman ruksh...@optushome.com.au wrote: Just wondering if there is an easier way to simply stop ScrollView from being scrolled via touch inputs? I will programmatically get the ScrollView to scroll to top or bottom. As a last resort, I guess I will have to inherit from ScrollView and capture all the ontouch events. But wondering if there is an easier way before I take this approach? 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: serialization is taking too long, what can I do in terms of the activity life cycle
I must have been very very patient the first time round or lost track of time because last night, I got back to the game and timed the serialization and it took about a min from hitting the back key to displaying the menu! Also this delay didn't exist until my recent changes to do with the serialization. I will profile tonight or tomorrow and report back my findings. On Jul 29, 6:14 am, Dan Bornstein danf...@android.com wrote: On Mon, Jul 27, 2009 at 9:24 PM, Dianne Hackborn hack...@android.com wrote: On Mon, Jul 27, 2009 at 8:35 PM, rukiman ruksh...@optushome.com.au wrote: Yes I did mean Java serialization. Any reason why I can't use it (apart from it being slow) ? Um... it being super-crazy slow? :) It's also very fragile, in that small innocuous-seeming changes to your code could subtly break your serialization, and, worse, small innocuous-seeming changes to the platform code could also break it. We on the Android team of course endeavor not to break application code, but we are not perfect by any stretch of the imagination, and serialization is a known tricky area to get right. Personally, I might use serialization when prototyping a system, but I would be very reluctant to include its use in a finished product. All that being said, if you happen to profile your serialization-using code and find that the slowness is directly due to code in the core library (classes in java.*, javax.*, or org.apache.*), I would appreciate a bug report detailing your observations. Cheers, -dan --~--~-~--~~~---~--~~ 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] serialization is taking too long, what can I do in terms of the activity life cycle
Finally after many days of getting StackOverflowError, I've tracked down the issue and fixed it, only to find that my game's serialization takes about 5 -10 seconds on the emulator and most likely around that in the target. So far my the lifecycle of my game is as follows onCreate - check if serialization file exists, if it does, de- serializes it. (~ 5-10 seconds) onPause - if the game is not complete, then serialize it (~ 5-10 seconds) I remember reading somewhere that another activity's onResume will NOT get called UNTIL the previous activity's onPause has ended. So I am worried that my game is delaying another activity that wants to start from doing so i.e like a phone call etc. I think speeding up the serialization is not going to be feasible, so any ideas on what I can do? Can I serialize in the onDestroy instead of the onPause? I read that the onPause is the only safest place to store the state. 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: serialization is taking too long, what can I do in terms of the activity life cycle
Yes I did mean Java serialization. Any reason why I can't use it (apart from it being slow) ? The game has lots of objects in memory and references to objects, it will be a bit tricky to write my own custom code to serialize hence why I went with the Java serialization as it automatically handles serializing only one copy of the object and marking others as references etc. There might be a better way to do it, but relatively new at it and couldn't think of an easier way at the time. To complicate matters most of the game code I am serializing wasn't written by me. So if I was to start a service, can I do that in the onPause? What if my activity received an onPause and was destroy straight away because the new activity chews too much memory, won't my game data in memory be lost at the same time? Or will it still remain in memory as the service has a reference to it? On Jul 28, 12:47 pm, Dianne Hackborn hack...@android.com wrote: 5-10 seconds is way too long to pause (you will easily cause your app to ANR). There really should be no reason for most things to take that long, so the first thing I would do is look at your code. (And if when say serialization, you actually mean Java serialization, then the first thing to do is not use that.) If you really really can't avoid taking so long to write your state, then about the only thing you can do is start a service that then spawns a thread and remains running until the thread is done writing. And of course you will need to deal with all of the nasty threading issues that arise there. On Mon, Jul 27, 2009 at 6:56 PM, rukiman ruksh...@optushome.com.au wrote: Finally after many days of getting StackOverflowError, I've tracked down the issue and fixed it, only to find that my game's serialization takes about 5 -10 seconds on the emulator and most likely around that in the target. So far my the lifecycle of my game is as follows onCreate - check if serialization file exists, if it does, de- serializes it. (~ 5-10 seconds) onPause - if the game is not complete, then serialize it (~ 5-10 seconds) I remember reading somewhere that another activity's onResume will NOT get called UNTIL the previous activity's onPause has ended. So I am worried that my game is delaying another activity that wants to start from doing so i.e like a phone call etc. I think speeding up the serialization is not going to be feasible, so any ideas on what I can do? Can I serialize in the onDestroy instead of the onPause? I read that the onPause is the only safest place to store the state. Thanks. -- 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] singletask activity for games
I am completely confused with this. I am writing a game and there should only be on instance of this game. So far I have: Splash screen activity Menu activity Game activity The Game activity is the default activity and it will fire off an intent with result to start the splash screen activity on the onCreate. The splash screen activity loads all the bitmaps required for the game, once it is finished it will return the result to the game activity which then knows all the bitmaps are finished. The Game activity then will fire off an intent to show the Menu acitivty. Now since I only ever want one instance of my game. Should I make the Splash screen, Menu and Game activity all singleTask? If my Game activity is singleTask and I start a Menu activity that is singleTask, is the Menu on a seperate task to the Game activity? How can i make them all in one task? I guess in my case whenever the Game activity gets an oncreate I can safely assume I have to start from scratch i.e display splash screen etc as I cannot assume the bitmaps are in memory. --~--~-~--~~~---~--~~ 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: singletask activity for games
Ah I see. Thanks, I understand now. On Jul 17, 12:42 pm, Dianne Hackborn hack...@android.com wrote: No, if the user selects your game from home while it is already running, it will be brought to the foreground. On Thu, Jul 16, 2009 at 7:31 PM, rukiman ruksh...@optushome.com.au wrote: Thanks Dianne. I have changed the game so much regarding the singleTask, singleInstance and confused myself in the process in terms of the behaviour I was seeing :) So I'm trying to figure out what meets my game's requirements before making any more confusing changes lol. If I don't make my splashscreen, menu and game activities to be singleTask, doesn't that mean that when a user is playing my game, presses the HOME key and clicks on the game icon, another new instance of my game is created? I want to enforce only one instance of the game, hence my reasoning for singleTask. I had a look at the lunarlander, and I am assuming it does not enforce a single instance as I cannot see any activity flags specified. On Jul 17, 12:24 pm, Dianne Hackborn hack...@android.com wrote: Definitely don't make them singleTask. Is there some behavior you are seeing when using the default launch mode that you are trying to solve? It should work fine from what you describe. As far as what you can assume... receiving onCreate() just means that the system need to make a new instance. This may be because the user pressed back to close your activity and is now restarting it, or they left it by pressing home (but leaving it still running) and the system had to kill it for its memory and the user has now returned to it. You can distinguish these with the savedState -- it will be non-null in the latter case. As far as knowing whether your bitmaps are loaded -- that should probably be done by just checking whether the variable(s) holding those bitmaps are set. I'd guess that you want to put these into a static global, so they will only get reset when your process is killed and restarted. On Thu, Jul 16, 2009 at 7:06 PM, rukiman ruksh...@optushome.com.au wrote: I am completely confused with this. I am writing a game and there should only be on instance of this game. So far I have: Splash screen activity Menu activity Game activity The Game activity is the default activity and it will fire off an intent with result to start the splash screen activity on the onCreate. The splash screen activity loads all the bitmaps required for the game, once it is finished it will return the result to the game activity which then knows all the bitmaps are finished. The Game activity then will fire off an intent to show the Menu acitivty. Now since I only ever want one instance of my game. Should I make the Splash screen, Menu and Game activity all singleTask? If my Game activity is singleTask and I start a Menu activity that is singleTask, is the Menu on a seperate task to the Game activity? How can i make them all in one task? I guess in my case whenever the Game activity gets an oncreate I can safely assume I have to start from scratch i.e display splash screen etc as I cannot assume the bitmaps are in memory. -- 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. -- 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] reposition a widget programmatically
I am creating a custom widget that is a composition of 3 Buttons. I want to reposition the buttons as I am doing in my code, however this doesn't work. Basically I am trying to create a widget that has three buttons positions somewhere in the middle of the screen. Any ideas? My code looks like this: public class ZoomControl extends LinearLayout { private Button zoomIn; private Button zoomOut; private Button magnify; public ZoomControl(Context context) { this(context, null); } public ZoomControl(Context context, AttributeSet attrs) { super(context, attrs); init(context); } private void init(Context context) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.zoomcontrol, this, true); // get handles to views zoomIn = (Button) findViewById(R.id.zoomIn); zoomOut = (Button) findViewById(R.id.zoomOut); magnify = (Button) findViewById(R.id.zoomMagnify); // reposition views zoomIn.offsetLeftAndRight(200); zoomIn.offsetTopAndBottom(200); requestLayout(); } public void dispatchDraw(Canvas canvas) { } } --~--~-~--~~~---~--~~ 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] how to tell when webview has finished loading an image
I am using loadUrl() to get the WebView to load a large image. I need to know when the image is completely loaded. I tried creating a WebViewClient and onPageFinished() however this seems to be called pretty much straight away and couple of time too. This doesn't make any sense to me. The javadocs says Notify the host application that a page has finished loading. This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet. To get the notification for the new Picture, use onNewPicture (WebView, Picture). So I tried creating a PictureListener with onNewPicture() but that is called couple of times too and not when the image is fully loaded. How can I go about this? --~--~-~--~~~---~--~~ 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] webview to show large picture zoomed out
How can I get the WebView to make any content it loads for example a large picture to fit to page when it is loaded? --~--~-~--~~~---~--~~ 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] updating a view based on another view
If I have a View that I want updated at the same time another View updates itself. What is the correct way of doing this? --~--~-~--~~~---~--~~ 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: updating a view based on another view
In other words how can I tell if a Widget is being updated from another Widget? On May 4, 4:10 pm, rukiman ruksh...@optushome.com.au wrote: If I have a View that I want updated at the same time another View updates itself. What is the correct way of doing this? --~--~-~--~~~---~--~~ 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] WebView get position within page
After I have loaded WebView with a html page, is it possible to get the position of the region that is currently being displayed within the WebView widget? --~--~-~--~~~---~--~~ 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: debugging java and c/c++
More specifically how can I debug the file android_view_Display.cpp ? I have made some progress but still cannot get this to work. This is what I have done so far: 1) run './emulator -shell' 2) start up Notepad application 3) do 'ps' in emulator shell to get PID of com.example.android.notepad who's PID is 295 4) run './gdbserver 10.0.2.15:1234 --attach 295' in emulator shell 5) using host shell 'telnet localhost 1234' then type 'redir add tcp: 1234:1234' to redirect port 1234 from emulator to host. At this point gdbserver is setup successfully and listening for connection. 6) create an eclipse C project and import the source code from filesystem frameworks/base/core/jni 7) Create new debug configuration for C/C++ local application with these settings * c/c++ application points to mydroid/out/target/product/ generic/symbols/system/lib/libandroid_runtime.so * debugger is gdbserver with connection set to localhost and port 1234 8) When I click on the debug icon in eclipse, it successfully switches to debug perspective and I can see in the emulator shell gdbserver reports 'remote debugging from host 10.0.2.2' 9) I can put breakpoints in android_view_display.cpp and then in the emulator I go back to the main menu and click on notepad and I am expecting it to break at android_view_Display_getHeight() but it does break at all. What am I doing wrong in this process and is there an easier way to debug native C 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] quicker compiles
Using the cupcake source, typing 'make' builds emulator and other tools. If I have only modified code in the framework, how can I do a quick build to test out my changes as the above 'make' takes 15mins to end. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: creating a transition between two views
OK I am close, this is what I got so far. BUT the the content of the first textview and second textview are displayed on top of each other basically making the screen look messy. What I really want is only the first textview is to be visible and the second textview to become visible ONLY as the rotate transition effect occurs. Is there a way I can set up opacity of the first textview so that the second view is not shown through ? LinearLayout xmlns:android=http://schemas.android.com/apk/res/android; android:id=@+id/listlayout android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical FrameLayout android:id=@+id/container android:layout_width=fill_parent android:layout_height=fill_parent TextView android:id=@+id/description1 android:text=This is the first page of stuff over here. YO YO YOY OY OYOYOYOYO android:scaleType=fitCenter android:textColor=#FF android:background=#FF android:layout_width=fill_parent android:layout_height=fill_parent android:visibility=visible / TextView android:id=@+id/description2 android:text=This is the second page with a bunch of widgets and stuff! android:scaleType=fitCenter android:textColor=#FF android:layout_width=fill_parent android:layout_height=fill_parent android:visibility=visible / /FrameLayout TextView android:id=@+id/listmenu android:layout_width=fill_parent android:layout_height=fill_parent android:gravity=bottom / /LinearLayout package com.ruki.transitiondemo; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.animation.AlphaAnimation; import android.view.animation.RotateAnimation; import android.widget.Button; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; public class TransitionDemo extends Activity { private LinearLayout layout; private TextView list; /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); layout = (LinearLayout) findViewById(R.id.listlayout); list = (TextView) findViewById(R.id.description1); layout.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { RotateAnimation b = new RotateAnimation(0f, 45f); b.setDuration(1000); list.startAnimation(b); } }); } } --~--~-~--~~~---~--~~ 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] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] draw view onto bitmap
Is there a way to get a view to draw itself onto a bitmap/canvas? I can see copyWindowBitmap() and getDrawingCache() public methods in the View class. What do these do exactly and how I do use 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 [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] creating a transition between two views
I am playing with startAnimation() of a View class where I can get it to slide out of the screen by making use of the TranslateAnimation class. However what I really like to do is while sliding the top view out, the second view becomes visible. So it is partially visible at first until the whole first view is out of the screen. How can I do something like this in Android? What is the correct way of doing it? --~--~-~--~~~---~--~~ 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] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: programmatically add a layout existing in xml to a view
OK I found out that the NullPointer exception is caused by this line RelativeLayout layout2 = (RelativeLayout) findViewById(R.id.page1layout); I guess this is because I haven't done a setContentView on page1.xml. But I don't want to do this. I want to basically grab the UI layout described in page1.xml and stick it into main.xml's relativelayout. Is this possible? The reason I want to do this is so that I can have multiple views defined in seperate XML files. If this is not possible can I describe the multiple views in one xml file and somehow programmatically show them. On May 14, 4:08 pm, rukiman [EMAIL PROTECTED] wrote: Perphaps this might help I have main.xml --- main view page1.xml -- the xml I pasted above. So basically I want to set a RelativeLayout widget in main.xml with the components which I defined in page1.xml On May 14, 4:06 pm, rukiman [EMAIL PROTECTED] wrote: Perphaps this might help I have main.xml --- main view page1.xml -- the xml I pasted above. So basically I want to set a RelativeLayout widget in main.xml with the components which I defined in page1.xml- 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 [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] programmatically add a layout existing in xml to a view
Ok this is what I want to do. Assume I have a XML file that described my screen. ?xml version=1.0 encoding=utf-8? RelativeLayout android:id=@+id/page1layout android:layout_width=fill_parent android:layout_height=fill_parent xmlns:android=http://schemas.android.com/apk/res/android; AnalogClock android:id=@+id/clock android:layout_width=wrap_content android:layout_height=wrap_content android:layout_alignParentTop=true android:layout_centerHorizontal=true /AnalogClock /RelativeLayout Now what I want to do is programmatically add this to a view. I am doing this at the moment but it is giving me a NullPointer exception RelativeLayout layout2 = (RelativeLayout) findViewById(R.id.page1layout); RelativeLayout.LayoutParams linear2layout = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); linear2layout.addRule(RelativeLayout.ALIGN_WITH_PARENT_TOP); page2.addView(layout2, linear2layout); where page2 is of type RelativeLayout. Any idea what is going wrong here? If I dynamically create a TextView like below then it works... TextView text2 = new TextView(this); text2.setText(can be any bunch of widgets here...blah blah); RelativeLayout.LayoutParams linear2layout = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); linear2layout.addRule(RelativeLayout.ALIGN_WITH_PARENT_TOP); page2.addView(text2, linear2layout); So all I was trying to do is replace the TextView with the UI described in the XML file. --~--~-~--~~~---~--~~ 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] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] why was PageTurner removed?
I see that in M3 of the SDK, the PageTurner existed which created the page turning effect, however it is removed from M5. Why was it removed? Is there an alternative to get this page turning effect or will it be reintroduced in the future? --~--~-~--~~~---~--~~ 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] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: why was PageTurner removed?
Anyone know the reason behind why it was removed? On May 1, 7:18 pm, Romain Guy [EMAIL PROTECTED] wrote: Hi, There is no alternative to PageTurner in the current SDK and it will not be reintroduced. On Thu, May 1, 2008 at 2:13 AM, rukiman [EMAIL PROTECTED] wrote: I see that in M3 of the SDK, the PageTurner existed which created the page turning effect, however it is removed from M5. Why was it removed? Is there an alternative to get this page turning effect or will it be reintroduced in the future? -- Romain Guywww.curious-creature.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: why was PageTurner removed?
Thanks for the reply. Is it possible to get the source code to the PageTurner.java ? Also where does the source code for Android live? On May 2, 1:40 am, Romain Guy [EMAIL PROTECTED] wrote: We removed it because this widget is not generic enough to justify the cost of maintaining it in the Android UI framework. On Thu, May 1, 2008 at 6:09 AM, rukiman [EMAIL PROTECTED] wrote: Anyone know the reason behind why it was removed? On May 1, 7:18 pm, Romain Guy [EMAIL PROTECTED] wrote: Hi, There is no alternative to PageTurner in the current SDK and it will not be reintroduced. On Thu, May 1, 2008 at 2:13 AM, rukiman [EMAIL PROTECTED] wrote: I see that in M3 of the SDK, the PageTurner existed which created the page turning effect, however it is removed from M5. Why was it removed? Is there an alternative to get this page turning effect or will it be reintroduced in the future? -- Romain Guywww.curious-creature.org -- Romain Guywww.curious-creature.org- 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 [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: why was PageTurner removed?
Also is there an alternative way of getting the page turning effect in Android using existing implementation? If not, I would like your opinion on which is the best way to implement the page turning effect. Thanks for your help. On May 2, 10:22 am, rukiman [EMAIL PROTECTED] wrote: Thanks for the reply. Is it possible to get the source code to the PageTurner.java ? Also where does the source code for Android live? On May 2, 1:40 am, Romain Guy [EMAIL PROTECTED] wrote: We removed it because this widget is not generic enough to justify the cost of maintaining it in the Android UI framework. On Thu, May 1, 2008 at 6:09 AM, rukiman [EMAIL PROTECTED] wrote: Anyone know the reason behind why it was removed? On May 1, 7:18 pm, Romain Guy [EMAIL PROTECTED] wrote: Hi, There is no alternative to PageTurner in the current SDK and it will not be reintroduced. On Thu, May 1, 2008 at 2:13 AM, rukiman [EMAIL PROTECTED] wrote: I see that in M3 of the SDK, the PageTurner existed which created the page turning effect, however it is removed from M5. Why was it removed? Is there an alternative to get this page turning effect or will it be reintroduced in the future? -- Romain Guywww.curious-creature.org -- Romain Guywww.curious-creature.org-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 [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---