[android-developers] What are arbitrary units in the javadoc for computeVerticalScrollOffset?
The documentation for computeVerticalScrollRange() sayshttp://developer.android.com/reference/android/view/View.html#computeVerticalScrollRange() : Compute the vertical range that the vertical scrollbar represents. The range is expressed in *arbitrary units* that must be the same as the units used by computeVerticalScrollExtent()http://developer.android.com/reference/android/view/View.html#computeVerticalScrollExtent() andcomputeVerticalScrollOffset()http://developer.android.com/reference/android/view/View.html#computeVerticalScrollOffset() . The same *arbitrary units* are mentioned in the other two methods. Looking at the sources, this is what I found: protected int computeVerticalScrollRange() { return getHeight(); } protected int computeVerticalScrollOffset() { return mScrollY; } protected int computeVerticalScrollExtent() { return getHeight(); } So, what's going on here? getHeight() is documented to return the height of the view in pixels, and I wander if it makes any sense to measure things in miles, kilometers, astronomic units... Do they documented it in such a way to allow subclasses to use percentages or number of items? In particular, I looked at this methods because I'm implementing a ListView with a custom background http://stackoverflow.com/q/12737600/315306, and it seems I need to deal with scroll dimensions -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Activity lifecycle and a null cursor
I don't know if my assumptions are right, anyway I pushed an update that seems to fix the bug (at least, I have zero reports since I put the new version online, whereas I used to have a few dozens). Here is what I did currently 1. Removed android:onClick in my XML files 2. Manually set the listener inside my custom adapter bindView() 3. Avoid leaks: since the listener happens to be an activity, I unset it either onPause() (via AbsListView.reclaimViews(ListView) and via a custom AbsListView.RecycleListener I want to remark, I don't know if my assumptions are correct and I don't know it this solves the bug. However if both of these are true, we have a collision between View and Activity lifecycle. Basically, if I am right, the View is reused in another activity (since its original one is paused) but still has the old one set as its listener. This causes the NPE because the old activity cursor is effectively null. Again, note that I don't have a single proof of these assumptions: I think the whole thing would be indeed very dangerous, but is the only coherent and conceptually right explanation. The problem here is that I've never been able to reproduce the bug, so I must base my assumptions on the crash reports (which are stopped after the upgrade). I'd like some Android dev on the list to tell if this is indeed possible, because it would be a dangerous thing (it could also be the case for memory leaks). I read the sources myself, but didn't find the relevant code. There is AbsListView.RecycleBin, but it's an instance field of the ListView and I don't think that the whole list view is reused among different Activities in this case. Related question on StackOverflowhttp://stackoverflow.com/q/10475359/315306 2012/5/7 Jason Teagle teagle.ja...@gmail.com Unfortunately the crash reports don't show the device model. The NPE happens when the user clicks a row or one of the buttons in a row (since all three actions share the same code). I have imagined a possible cause for this issue. Looking into the sources (android/view/View.java) here is what the constructor does when it founds android:onClick in XML: an anonymous listener is created, and this listener will call the method on the Context returned by View.getContext(), but this context may be a different instance than the one currently holding the view. This is because Adapter.getView()http://developer.android.com/reference/android/widget/Adapter.html#getView(int,%20android.view.View,%20android.view.ViewGroup)gives a chance for reusing an already existing View, and the default strategy for CursorAdapter (as seen in the sources) is to reuse that simply if it's not null. So here is my scenario 1. Instance#1 of MyActivity is created, its listview is set up and shown. Instance#1 is set as the listener for the list_item view, as per android:onClick in my XML layout 2. onPause is called on instance#1, which causes my method to set adapter's cursor to null 3. the system decides that a new instance of MyActivity is needed, so instance#2 is created. A new cursor is also created and its contents are shown in the list view (via bindView()), but the list item views are recycled somehow, since they were kept in a cache. The old views still keep a reference to instance#1, so when the click event is triggered, instance#1.onClick() is fired and it founds a null cursor, thus throwing the NPE This explanation requires a little bit of imagination, but I think it's still realistic, even if all is to be demonstrated. I am writing a separated, minimal test case to dive into the Android classes with the debugger, but it's not simple. I use an activity with a list view as the only content view, and a list_item with an android:onClick property defined in XML. My goal is to see if a new instance of the activity can be created even when another one is already available. From the Android doc, this would be perfectly legitimate, but is not easy to trigger. The second step is to click the list item and compare the list_item's context with the current Activity. If they are different, we have caught it. Does anybody have any suggestion or experience on this? @Jason, as per the tap tempo, the algorithm to detect the BPM requires three taps at enough close intervals, and the resulting value must also be in the constraints. If you try to tap while you listen a song, it will do its job @Blake, I can argue it from the stack trace. The NPE is throws at this line int position = cursor.getPosition(); so the cursor is obviously null, and the only code that change the cursor (and the adapter) is onPause(), where I set adapter.changeCursor(null); -- 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] Activity lifecycle and a null cursor
My activity displays a ListView which retrieves its data from the associated cursor. I close the database (and the cursor) onPause, and get a new database (and a new cursor) onResume. This means that events callback should access the Cursor only when it's not null. However I get lots of NPE in my listeners. This is the pseudo code (I don't post the whole activity because it's 200 lines and is not runnable without also having XML files, strings and drawables) onResume() { super.onResume(); database = new Database(this).getWriteableDatabase(); adapter = new SimpleCursorAdapter( /* query the SQLite db */); listView.setAdapter(adapter); } onPause() { super.onPause(); adapter.changeCursor(null); // this closes the cursor database.close(); } onClickItem(View view) { Cursor cursor = adapter.getCursor(); int position = cursor.getPosition(); // This line throws the NPE } I can't understand why cursor may be null, since onResume() it's clearly initialized by the query. I can't reproduce this on my devices, which makes it really hard to debug. Also, the situation is quite unrecoverable, meaning that I would consider it a programming error to check inside the event callback if cursor is null, since obviously it must be non-null. If it is, it's better to let my app fail, so I eventually fix 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
Re: [android-developers] Activity lifecycle and a null cursor
I appreciate your pragmatic response, however - while debugging on my devices (and emulators) I never got this NPE, so basically I am blind and must try to figure out what could happen on other devices. But, without being able to reproduce this behavior, the local debug is useless. I'd need to get in touch with the users - Triple checking everything is not the way to make robust software. Deeply understanding the API is. I don't want to mask my bugs with unneeded checkings, because if I don't catch the bug it will pop up sooner or later - Android seems to me too much an *unreliable* platform. i don't know if it's for missing documentation, bad design or whatever, just every piece of the API fails at some point You introduced two interesting questions (which I was already asking myself since a couple of days): 1. Can a click event be fired before onResume() finishes executing? Sure, I could set and clear a flag, but I'd like to see some documentation on this, because it'd completely break the usefulness of Activity lifecycle callbacks 2. Does my code call the very same adapter? A little bit of more information can help answer these questions. In my activity I let Android automatically register/unregistering observers by using android:onClick in the XML layout. The adapter is recreated onResume() and is stored as an instance field of my activity (which also is the OnClickListener). Since the adapter is used to read from the cursor and populate the listview, and since the listview is not empty (otherwise one could not click an item and thus firing the event listeners), how can we have two different adapters? If you want to try to crash my app this is the link to download ithttps://play.google.com/store/apps/details?id=com.zybnet.metronomefree. The Activity we are talking about is started when the user clicks on the LCD screen of the metronome 2012/5/7 Jason Teagle teagle.ja...@gmail.com adapter = new SimpleCursorAdapter( /* query the SQLite db */); I can't understand why cursor may be null, since onResume() it's clearly initialized by the query. You would expect so, but it couldn't hurt to check (as a debugging test) if adapter.getCursor() actually returns a valid cursor immediately after the call to new SimpleCursorAdapter() above. It might also be worth checking that the adapter instance you set into the list view in onResume() and the one you are subsequently seeing in onClickItem() are one and the same. Again, you'd expect it to be, but at this point you've got little to lose by checking. Just as a sanity check, make sure onResume() *is* being called as you expect, before onClickItem() fires. Stranger things have happened... it's clearly initialized by the query ... since obviously it must be non-null If programming (and running into problems) can teach you one thing, hopefully it will be that making assumptions is a mistake {:v) There is nothing in the docs for the SimpleCursorAdapter constructor that says it *guarantees* a valid cursor after the operation, even though that is the logical expectation. -- 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.comandroid-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=enhttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Activity lifecycle and a null cursor
Indeed I agree. I am preparing a dialog to give users an opportunity to submit more information than a typical crash report. However I hope that someone from the Android team is on the list and can put some light on the overall Activity lifecycle and the management of views, threads and instance variables, because there is a total lack of documentation on these things. Sure, we have the sources, but it'd be very sad if they were the most accurate technical specification 2012/5/7 Jason Teagle teagle.ja...@gmail.com while debugging on my devices (and emulators) I never got this NPE, so basically I am blind and must try to figure out what could happen on other devices. But, without being able to reproduce this behavior, the local debug is useless. I'd need to get in touch with the users I don't envy you in that difficult situation. If you can enlist the help of several helpful users to help you track it down by adding temporary debug info into the code and letting them use the temporary version of the app, it will be of benefit. It's in their interest as much as yours to get the situation resolved. Are you aware of any devices in particular that cause this problem? Triple checking everything is not the way to make robust software. ... with unneeded checkings, Be careful about this philosophy. In your code sample, for example, you have Cursor cursor = adapter.getCursor(); int position = cursor.getPosition(); You are using 'cursor' here without checking it for null - you have *zero* checks in there. Whilst I appreciate that 'triple checking' was a slightly exaggerated comment, having *no* checks can be just as bad. because if I don't catch the bug it will pop up sooner or later Agreed. But having your users have to put up with constant failures because you prefer leaving things to fail so that you catch them rather than coding defensively (and *log* the issue in a catch handler, for example, so that you still get information on the problem somehow) isn't always an ideal situation. Some users will prefer to have it fail rather than do something odd, as per your philosophy, but others will prefer to have it try its best to move on rather than die, die, die. I'm willing to bet that the majority fall into the latter category. Android seems to me too much an unreliable platform. i don't know if it's for missing documentation, bad design or whatever, just every piece of the API fails at some point Although I do feel that the documentation has lots of room for extra information, I would suggest that more of the problem you state is to do with trying to get one platform (Android) to cope with all the nuances of each manufacturer's (and even each model's) hardware and firmware. It's not as if manufacturers code with the OS in mind (except, you'd hope, Google's own devices!). Can a click event be fired before onResume() finishes executing? ... because it'd completely break the usefulness of Activity lifecycle callbacks Totally agreed. I would be alarmed if it were possible, to be honest. cursor and populate the listview, and since the listview is not empty (otherwise one could not click an item and thus firing the event listeners), how can we have two different adapters? I agree that it seems ludicrous, but bear in mind that you are (in the click handler) referring to a variable you are maintaining manually (adapter), rather than getting the adapter directly from the list view. There is also the possibility of a threading issue, but since everything happens in the same activity I assume this should not be an issue - it should all be happening on the main UI thread. I can only suggest using (SimpleCursorAdapter)listView.**getAdapter().getCursor() rather than using the [adapter] member variable and see what happens. -- 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.comandroid-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=enhttp://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: Allow button inside listview to be clickable
If I understand correctly, you should simply add android:clickable=true to your list item On Monday, May 7, 2012 3:43:31 PM UTC+2, Juliano Nunes wrote: Hi, I needed to create kind of a sub-list that allows horizontal scrolling, so I created the following structure inside my ListViewItem template: HorizontalScrollView android:id=@+id/schedule_scrollView ... LinearLayout android:id=@+id/schedule_minutes ... /LinearLayout /HorizontalScrollView And I added dynamically several buttons to this LinearLayout (schedule_minutes), which uses a Background Resource to indicate the button state. The problem is, the button is not clickable and doesn't change its state (at least visually as configured on Background Resource). How can I fix 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] Eclipse ADT: virtual devices are not listed if Android version project target?
I recently switched my project target to android-14 because the latest AdMob skd requires so. Still my minSdkVersion in the manifest is 7. I can successfully install and run my app on emulators above Eclair, but these devices are not listed in Eclipse Run menu, so I can't easily test on previous versions from Eclipse. Is this expected behavior? Known bug? Or am I missing something? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Why doesn't Android API publicly allow to listen for incoming SMS?
Yes, I know it and I already wrote it in my question :) I was aksing why it was removed from the official documentation? This way one can't be guaranteed that it works 2012/2/13 DONG HONGJIE hongji...@gmail.com Usually Broadcast Receiver is used to listen to incoming sms, put android.provider.Telephony.SMS_RECEIVED as your intent filter and your receiver will catch it. On Sun, Feb 12, 2012 at 2:21 AM, Raffaele Sgarro raffaelesga...@gmail.com wrote: Recently a question on SO ported this to my attention. Android doesn't have a public API for listening to incoming SMS. There used to be an action android.provider.Telephony.SMS_RECEIVED, but it has been removed from the official API and even if it still works, it's obviously not future-proof. I don't need this feature right now, but I may in the future, and I find it very strange it's not available because: 1. Android has always encouraged the deep customization of every little part of the system (think of tha launcher, the dialer, the contact app) 2. There are plenty of alternatives to the standard SMS app already in the Market (not to mention the vendors' ones) Maybe I am missing something or maybe there's a technical reason - I admit not know how SMS works Originally posted on StackOverflowhttp://stackoverflow.com/q/9243059/315306 -- 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 -- 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] Why doesn't Android API publicly allow to listen for incoming SMS?
Recently a question on SO ported this to my attention. Android doesn't have a public API for listening to incoming SMS. There used to be an action android.provider.Telephony.SMS_RECEIVED, but it has been removed from the official API and even if it still works, it's obviously not future-proof. I don't need this feature right now, but I may in the future, and I find it very strange it's not available because: 1. Android has always encouraged the deep customization of every little part of the system (think of tha launcher, the dialer, the contact app) 2. There are plenty of alternatives to the standard SMS app already in the Market (not to mention the vendors' ones) Maybe I am missing something or maybe there's a technical reason - I admit not know how SMS works Originally posted on StackOverflowhttp://stackoverflow.com/q/9243059/315306 -- 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: First, prevoius, next, and last buttons
You need a View.OnClickListenerhttp://developer.android.com/reference/android/view/View.OnClickListener.html that queries the database depending on the Buttonhttp://developer.android.com/reference/android/widget/Button.html it's attached to. The SQL part is pretty obvious. Once you have the record, you update the interface, and this really depends on the kind of record and the view that display it. For example if it's a TextView you can simpy change the text. If you want you can use a ViewSwitcherhttp://developer.android.com/reference/android/widget/ViewSwitcher.html to add nice animation. -- 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: Anyone help me! Send Mediarecorder video to server through TCP socket and server save it in a file????
You'd better use a http or ftp server -- 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] PopupWindow out of screen when size is unspecified
Most examples out there specify exactly the width and the height of the popup window. I want them to be WRAP_CONTENT - since the content is dinamically determined- so in the constructor I set -2 for both width and height and show it via showAsDropDown(View anchor) Doing this, the popup is always drawn below the anchor view, which means it can be drawn offscreen. The following snippet demonstrates the problem. Try clicking on the last TextView and you won't see any PopupWindow, since it's shown outside of the windows bounds. Why doesn't it work? I remark that specifying dimension explicitly (for example 200, 100) doesn't trigger the problem. Try it yourself http://pastebin.com/iz4p2419 (Line 17, set -2 -2 to see the problem) -- 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] EditText with custom behavior
I want my custom EditText to behave like this - When app starts it seems a TextView (ie normal text on solid color background, cursor not shown) - When users taps, it changes its appearance to look selected (ie a different background, still cursor not displayed) - When user long taps, it requests focus and shows soft keyboard if necessary - When user tap anywhere else, the last long tapped custom EditText, if any, goes back in the normal state It seems quite basic to me, however I can't get it to work properly. A number of unwanted things happens, and when I try to repair one of them, a plenty of new issues arise. I'd like to know if there is a simple workflow for getting an EditText which behaves 1. like a normal TextView when doesn't interact with user and when user tap it 2. like a clicked EditText when user long clicks it (ie show soft keyboard if necessary and possibly change appearance) Please help me. I have read all the docs and the sources for View, TextView and EditText, but the interaction among focus, motion events, selection, etc are so difficult to understand and the code is not commented at all. -- 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: EditText with custom behavior
package com.example.custom.edit.text; import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; public class CustomEditTextActivity extends Activity { public static class CustomEditText extends EditText { public CustomEditText(Context context) { super(context); setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // TODO This isn't called till we setFocusableInTouchMode(false) ((CustomEditText) arg0).setText(SELECTED); } }); setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View arg0) { // TODO request focus and show soft keyboard if necessary return false; } }); } // TODO save this so that some listener can // restore it to NORMAL state private static CustomEditText mLastTapped; } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); CustomEditText cet; for (int i = 0; i 5; i++) { cet = new CustomEditText(this); cet.setText(NORMAL STATE); cet.setBackgroundColor(Color.WHITE); cet.setSelectAllOnFocus(true); layout.addView(cet, new LinearLayout.LayoutParams(-1, -1, 1)); } setContentView(layout); } } -- 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: EditText with custom behavior
Link to pastebin http://pastebin.com/BEp4z2kb I hope someone can help me. It seemed a trivial task when I designed my project, but know I really can't go on. I pasted a self contained Android activity with my custom widget. You only need to create a new Android project with the following settings in Eclipse - CustomEditTextActivity - package com.example.custom.edit.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
Re: [android-developers] Re: EditText with custom behavior
Thanks for your reply, but in my real application I have two nested LinearLayout which make up a table. This table is comprised of CustomEditText, so your solution isn't appliable here. I appreciate your effort, but I need a solution based on the above pattern. I also tried to use a ViewSwitcher to switch between a TextView and an EditText, but it seems a performance hit, since I have a 7x7 table and so I need to instantiate 49 ViewSwitcher besides the 49 TextViews and 49 EditText 2011/10/7 Studio LFP studio@gmail.com Here is something I came up. I haven't worked out all the details, but maybe this will get you started. It works by using a RelativeLayout and when you tap on a TextView, it just sets the bounds of an EditText to match the TextView. It then hides the TextView and layers the EditText on the invisible view. I know I didn't handle the click-change-color and long-click-change-view idea, but these should be fairly easy to add. XML Layout: swap_view.xml --- ?xml version=1.0 encoding=utf-8? RelativeLayout android:id=@+id/rlHolder xmlns:android= http://schemas.android.com/apk/res/android; android:orientation=vertical android:layout_width=match_parent android:layout_height=match_parent TextView android:id=@+id/tvReplace android:layout_width=match_parent android:layout_height=40dp android:text=Test Text android:textSize=20dp / /RelativeLayout Activity Code public class SwapViewActivity extends Activity implements OnClickListener { private RelativeLayout rlHolder; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.swap_view ); rlHolder = (RelativeLayout)findViewById( R.id.rlHolder ); TextView tvReplace = (TextView)findViewById( R.id.tvReplace ); tvReplace.setOnClickListener( this ); } @Override public void onClick( View v ) { switch( v.getId() ) { case R.id.tvReplace: { RelativeLayout.LayoutParams rlpParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT ); rlpParams.addRule( RelativeLayout.ALIGN_LEFT, v.getId() ); rlpParams.addRule( RelativeLayout.ALIGN_TOP, v.getId() ); rlpParams.addRule( RelativeLayout.ALIGN_RIGHT, v.getId() ); rlpParams.addRule( RelativeLayout.ALIGN_BOTTOM, v.getId() ); v.setVisibility( View.INVISIBLE ); EditText etReplace = new EditText( this ); etReplace.setText( ((TextView)v).getText() ); rlHolder.addView( etReplace, rlpParams ); break; } } } } You can then handle the edit and either hide or remove the EditText, set the TextView text to the new text, and make the TextView visible again. Steven Studio-LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: EditText with custom behavior
I can't use your code because your technique is only suitable for a RelativeLayout. In a LinearLayout there is no way to stack views and playing with their visibility. Of course, I could take your approach and find a way to have a floating EditText which is exactly over the TextView (ie an overlay) but I won't be able to forward the click event to the newly showed EditText and so the whole thing wouldn't work as designed. Sorry :( Does anybody here know deeply how focus/inupt work with TextViews? 2011/10/7 Studio LFP studio@gmail.com You could still use my code but instead of using it straight, you could just wrap it in a custom view. So instead of just a TextView or EditView, use the above code wrapped in a custom View and have the TextView/EditView inside it. Use the swap code there and it would actually a bit more simple because you could hold the data on the custom view and it would still fit inside your layout like the existing views. Steven Studio LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: EditText with custom behavior
Hi Kostya, you must be the author of WiFi manager :) Nice to meet you The problem here is not about visual appearance, it's about EditText behavior :) I agree that UIs should be as intuitive as possible, so I can make you an example of what I want to implement. Imagine to have a 7x7 table of TextViews. Obviously the cells are little and the text is ellipsized. I want that when the user taps a cell, a bigger popup displays more information, and when the user long taps the cell, he can directly edit the text in it. I think it's a good design but anyway once the app is out, users will judge it :) I need to know more about how focus is managed on Android platform. Here are some questions 1. Is there ALWAYS a focused element? Or can the focus be empty? 2. How does the soft keyboard relate to the focus? 2011/10/7 Kostya Vasilyev kmans...@gmail.com Some of the things can be done with drawable state list(s) and stuff. The standard EditText uses a state-list drawable for its background, it can be found under: android-sdk\platforms\**platform-X\data\drawable. The name can be found by looking in the platform's styles.xml: style name=Widget.EditText item name=android:focusabletrue**/item item name=android:**focusableInTouchModetrue/**item item name=android:clickabletrue**/item item name=android:background@**android:drawable/edit_text/**item item name=android:textAppearance**?android:attr/** textAppearanceMediumInverse/**item item name=android:textColor@**android:color/primary_text_** light/item item name=android:gravitycenter_**vertical/item /style So it's drawable/edit_text.xml you want. It should be possible to create a similar background state-list XML, to be transparent (or white without the border) for when the EditText is not focused. As for the rest of you requirements, including a long press to enter editing... I believe - as a user - that UIs should be predictable and consistent with the platform's conventions, but maybe I'm just too old for this mobile computing thing :) -- Kostya 07.10.2011 20:29, Studio LFP пишет: You could still use my code but instead of using it straight, you could just wrap it in a custom view. So instead of just a TextView or EditView, use the above code wrapped in a custom View and have the TextView/EditView inside it. Use the swap code there and it would actually a bit more simple because you could hold the data on the custom view and it would still fit inside your layout like the existing views. Steven Studio LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@** googlegroups.com 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=enhttp://groups.google.com/group/android-developers?hl=en -- Kostya Vasilyev -- 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.comandroid-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=enhttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: EditText with custom behavior
I already told you that I tried a similar approach with a ViewSwitcher. There is no need to extend a LinearLayout for this task if there is a pre built ViewSwitcher. The problem with this pattern is that the user click is eaten by the SwapView, so the user has to click another time in the EditText to focus it and show the soft keyboard. I want that when the user long taps my custom view, a soft keyboard is shown if necessary and he can start typing (without having to click it one more time) 2011/10/7 Studio LFP studio@gmail.com Along with the above code you could add an Ok button to the side of the edit text to accept the input and revert back to a TextView. Steven Studio LFP http://www.studio-lfp.com On Friday, October 7, 2011 12:02:52 PM UTC-5, Studio LFP wrote: Using a simple technique, and should be usable anywhere. ?xml version=1.0 encoding=utf-8? RelativeLayout android:id=@+id/rlHolder xmlns:android=http://schemas. **android.com/apk/res/androidhttp://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=match_**parent android:layout_height=match_**parent com.testproject.views.**SwapView android:id=@+id/svReplace android:layout_width=match_**parent android:layout_height=40dp android:text=Test Text android:textSize=20dp / /RelativeLayout public class SwapView extends LinearLayout { public static final int TYPE_TEXT = 0; public static final int TYPE_EDIT = 1; public int iType = 0; public String sText = Text; private LinearLayout.LayoutParams llpParams = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT ); private Context context; public SwapView(Context newContext) { super(newContext); context = newContext; setInitialView(); } public SwapView(Context newContext, AttributeSet attrs) { super(newContext, attrs); context = newContext; setInitialView(); } private void setInitialView() { TextView tvNew = new TextView( context ); tvNew.setText( sText ); addView( tvNew, llpParams ); } public void setActiveType( int iNewType ) { this.removeAllViews(); iType = iNewType; switch( iNewType ) { case TYPE_TEXT: TextView tvNew = new TextView( context ); tvNew.setText( sText ); addView( tvNew, llpParams ); break; case TYPE_EDIT: EditText etNew = new EditText( context ); etNew.setText( sText ); addView( etNew, llpParams ); break; } } } Steven Studio LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: EditText with custom behavior
Sorry Steven, I didn't mean to hurt you I appreciate your help a lot, you are the only one which actually coded something, and I believe this is very valuable. The layout approach was my first attempt, but I'm working on something cleaner and I think I have finally found a solution, which I'll post here so someone can test it and see if it works as expected. 2011/10/7 Studio LFP studio@gmail.com etNew.requestFocus(); InputMethodManager mgr = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showSoftInput( etNew, InputMethodManager.SHOW_IMPLICIT ); There, add that to the case: TYPE_EDIT before the break and your done. And yes, there is a reason to make your own. It's easier, faster and is more configurable because you can control every detail. Ignore help if you want, but I don't think anyone here is going to write all the details for you. We are here to point people in the right direction and for them to fill in the details. There are still details that are needed to make that fully functional, but they are easy because you have infinite control in your own class. Steven Studio LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: EditText with custom behavior
Here is the whole Eclipse projecthttp://www.2shared.com/file/us3MXMdS/custom-edit-text.html? After more than 6 hours working on this, I finally found a solution. It's simpler than what I thought. The key point is using setFocusable()and setFocusableInTouchMode() at the right moments, and manually showing and hiding the soft keyboard. I hope you download the sample and execute it, so I can have a reasonable feedback. There is also a little onKeyPreIme() invocation which causes the custom view to clear its state when the user manually hides the soft keyboard by pressing the return key. Thanks to all of you 2011/10/7 Raffaele Sgarro raffaelesga...@gmail.com Sorry Steven, I didn't mean to hurt you I appreciate your help a lot, you are the only one which actually coded something, and I believe this is very valuable. The layout approach was my first attempt, but I'm working on something cleaner and I think I have finally found a solution, which I'll post here so someone can test it and see if it works as expected. 2011/10/7 Studio LFP studio@gmail.com etNew.requestFocus(); InputMethodManager mgr = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showSoftInput( etNew, InputMethodManager.SHOW_IMPLICIT ); There, add that to the case: TYPE_EDIT before the break and your done. And yes, there is a reason to make your own. It's easier, faster and is more configurable because you can control every detail. Ignore help if you want, but I don't think anyone here is going to write all the details for you. We are here to point people in the right direction and for them to fill in the details. There are still details that are needed to make that fully functional, but they are easy because you have infinite control in your own class. Steven Studio LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: EditText with custom behavior
Unfortunately I can't give you my actual app's code, but #1 and #2 are not issues since they are intended :) #3 seems a bug instead. Can you please describe carefully what are the steps to reproduce it? Also the Android runtime version could matter. I can't reproduce that behavior. Thanks for your support 2011/10/7 Studio LFP studio@gmail.com I'm not hurt by you choosing to go a different path. Just seems like you are leaving a lot on the table that's already written for you by trying to put a square peg into a round hole. I checked out that project and I think you are cutting yourself short here because of the following: 1. Now you have to write a full select/copy/paste routine since you've overridden it by catching the long click 2. You don't give a defined space so the user understands the bounds of the view 3. Touching to place the cursor somewhere causes it to keep editing and leaves the cursor there, but dismiss the keyboard I only tested it a little, so I'm not sure what other issues might pop up as you use it more. You may also want to find a place for android:imeOptions=flagNoExtractUi (or similar in code) so that it doesn't popup the full UI of the keyboard in landscape mode so it still feels like you are editing in place. And a android:configChanges=orientation|keyboardHidden on your activity because it resets your views on rotate otherwise. It seems like you are actually causing more work for yourself, but if it's working like you want it to, then that's what matters. Steven Studio LFP http://www.studio-lfp.com On Friday, October 7, 2011 1:48:57 PM UTC-5, Raffaele Sgarro wrote: Here is the whole Eclipse projecthttp://www.2shared.com/file/us3MXMdS/custom-edit-text.html? After more than 6 hours working on this, I finally found a solution. It's simpler than what I thought. The key point is using setFocusable()and setFocusableInTouchMode() at the right moments, and manually showing and hiding the soft keyboard. I hope you download the sample and execute it, so I can have a reasonable feedback. There is also a little onKeyPreIme() invocation which causes the custom view to clear its state when the user manually hides the soft keyboard by pressing the return key. Thanks to all of you 2011/10/7 Raffaele Sgarro raffael...@gmail.com Sorry Steven, I didn't mean to hurt you I appreciate your help a lot, you are the only one which actually coded something, and I believe this is very valuable. The layout approach was my first attempt, but I'm working on something cleaner and I think I have finally found a solution, which I'll post here so someone can test it and see if it works as expected. 2011/10/7 Studio LFP studi...@gmail.com etNew.requestFocus(); InputMethodManager mgr = (InputMethodManager) context.getSystemService( **Context.INPUT_METHOD_SERVICE); mgr.showSoftInput( etNew, InputMethodManager.SHOW_**IMPLICIT ); There, add that to the case: TYPE_EDIT before the break and your done. And yes, there is a reason to make your own. It's easier, faster and is more configurable because you can control every detail. Ignore help if you want, but I don't think anyone here is going to write all the details for you. We are here to point people in the right direction and for them to fill in the details. There are still details that are needed to make that fully functional, but they are easy because you have infinite control in your own class. Steven Studio LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-d...@googlegroups.com To unsubscribe from this group, send email to android-develop...@**googlegroups.com For more options, visit this group at http://groups.google.com/**group/android-developers?hl=enhttp://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 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: EditText with custom behavior
Oh my god, it's a mess!!! But still I don't understand exactly what happens. I think you do something like 1. Long tap on a view: this shows the soft keyboard and you can type anything 2. Click on the same view: this triggers the mess Is this right? Is the problem when you click in the current focused EditText? Otherwise it goes well 2011/10/7 Studio LFP studio@gmail.com I tested it on the following: Xperia Play - Android 2.3.2 Samsung Galaxy Tab (7 in) - Android 2.2 Motorola Droid (Original) - Android 2.2.2 Droid Bionic - Android 2.3.4 HTC Hero - Androi 2.1-update 1 My Xoom is out for the LTE upgrade so I can't test it on that at the moment. It only worked correctly on the HTC Hero. All others the keyboard poofs when you move the cursor by touch somewhere else in the EditText. The Xperia Play acted a bit more weird than the others and allowed me to select text, but not be able to cancel the select and place the cursor where I wanted it. Steven Studio LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: EditText with custom behavior
Please, try adding this little patch at line 23 if (mLastTapped == arg0) return; This should be enough 2011/10/7 Studio LFP studio@gmail.com Exactly. When I try to touch to move the cursor in an already focused box, the keyboard dismisses on everything but the HTC Hero on 2.1-update 1. The Xperia Play goes into some kind of select text mode the others don't. You may have to check if the view that is clicked on is the one the user is currently editing and prevent this behavior. I can post screen shots in a bit if you need them. Steven Studio LFP http://www.studio-lfp.com On Friday, October 7, 2011 4:22:06 PM UTC-5, Raffaele Sgarro wrote: Oh my god, it's a mess!!! But still I don't understand exactly what happens. I think you do something like 1. Long tap on a view: this shows the soft keyboard and you can type anything 2. Click on the same view: this triggers the mess Is this right? Is the problem when you click in the current focused EditText? Otherwise it goes well 2011/10/7 Studio LFP studi...@gmail.com I tested it on the following: Xperia Play - Android 2.3.2 Samsung Galaxy Tab (7 in) - Android 2.2 Motorola Droid (Original) - Android 2.2.2 Droid Bionic - Android 2.3.4 HTC Hero - Androi 2.1-update 1 My Xoom is out for the LTE upgrade so I can't test it on that at the moment. It only worked correctly on the HTC Hero. All others the keyboard poofs when you move the cursor by touch somewhere else in the EditText. The Xperia Play acted a bit more weird than the others and allowed me to select text, but not be able to cancel the select and place the cursor where I wanted it. Steven Studio LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-d...@googlegroups.com To unsubscribe from this group, send email to android-develop...@**googlegroups.com For more options, visit this group at http://groups.google.com/**group/android-developers?hl=enhttp://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 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: EditText with custom behavior
I really cannot understand what's going on :S The XPeria is the only phone with the hard keyword, isn't it? But if I try in the emulator (which also emulates a hardware keyboard) everything goes fine. I mean, when you long click a View all text is selected (intended, so one can easily erase everything) and I can move the cursor wherever I want, either by clicking and moving the Dpad. Can you give more information? 2011/10/8 Studio LFP studio@gmail.com That worked for all but the Xperia Play. It still selects everything and doesn't let me place a cursor where I want it. You will need to clear that at some point because it prevents clicking on the same view again. This could be bad if the phone goes to sleep or another activity comes up and then they go back to yours. Steven Studio LFP http://www.studio-lfp.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Dynamically loading code in Android application
I'm only evaulating if it's viable.. My plan is to download the code from a server. What's the warning about code injection? 2011/9/13 بالقاسم الشريف b0592221...@gmail.com بتاريخ 2011 9 11 22:36، كتبها Raffaele Sgarro raffaelesga...@gmail.com : Is it possible to run code downloaded ar runtime? Something like new URLClassLoader(myURL).loadClass(MyClassName) The class code will be in a JAR archive. The question is how do I compile and package that code? I think Dalvik cannot executes plain Java bytecode, so I'll have to postprocess the JAR with dx tool. Is is right? But unfortunately dx is not documented, so I really need more information on this topic -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- 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
Re: [android-developers] Dynamically loading code in Android application
Thanks for your reply, but my question was more about how to get the DEX file without Eclipse, since typically my JAR will contain a couple of classes and resource files 2011/9/12 Kristopher Micinski krismicin...@gmail.com On Sun, Sep 11, 2011 at 3:35 PM, Raffaele Sgarro raffaelesga...@gmail.com wrote: Is it possible to run code downloaded ar runtime? Something like new URLClassLoader(myURL).loadClass(MyClassName) The class code will be in a JAR archive. The question is how do I compile and package that code? I think Dalvik cannot executes plain Java bytecode, so I'll have to postprocess the JAR with dx tool. Is is right? But unfortunately dx is not documented, so I really need more information on this topic http://developer.android.com/reference/dalvik/system/DexClassLoader.html ??? Kris -- 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] Dynamically loading code in Android application
Is it possible to run code downloaded ar runtime? Something like new URLClassLoader(myURL).loadClass(MyClassName) The class code will be in a JAR archive. The question is how do I compile and package that code? I think Dalvik cannot executes plain Java bytecode, so I'll have to postprocess the JAR with dx tool. Is is right? But unfortunately dx is not documented, so I really need more information on this topic -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] AudioTrack in streaming mode
I need to stream runtime generated PCM data. This sounds pretty simple, but it doesn't work. Pseudo code: public void run() { while(...) { mAudioTrack.write(whatNoiseDoesThisAnimalMake(mAnimal), ...); } } mAnimal can be changed from UI obviously. Just in case it matters, I set the AudioTrack internal buffer to 0.1 * sampleRate * bitsPerSample / 8 to obtain kinda low latency (100ms). At this time, I can get my sound played only once. -- 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