[android-developers] = Returning images to the Quick Search Box Asynchronously =
The images returned to the cursor in the QSB seem to require an image on the device. My images live on a remote server that would have to be downloaded to the device asynchronously with callbacks. This would be prohibitively slow returning search results. Is there a way that the QSB can retrieve images from a remote server on its own, given the URL? Or perhaps can I return a URI that maps to a ContentProvider that returns the image? Any ideas? Thanks Clark Battle, Rhapsody -- 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: == How to Toast or Notify in response to ACTION_VIEW without showing my app ==
That's what I'm already doing. It looks like the toast can not show unless it is over the activity that started it. On Mar 14, 7:44 pm, metal mikey coref...@gmail.com wrote: One idea: Try using an intermediary Activity that is lightweight completely transparent, it handles the decision as to whether to show the Toast message or instead of starting your App (seems your App is already started, though, since you've created a QSB...). On Mar 15, 11:32 am, ClarkBattle clarkbat...@gmail.com wrote: When a user clicks on a cached Quick Search Box shortcut it takes the user to an activity that they should not see if they are in airplane mode. I would like to show them a toast or a notification from within the QSB, without showing my app. The message will be You can not view this content while offline. If I simply show a toast from my QuickSearchActivity.onCreate(), then finish() it shows the toast over my app. I want it to show the toast over the QSB. Even if I put the finish() in the onResume() or put it in a postDelayed() it still shows the app. Strange. If it is possible to show a toast over the QSB in response to an item being clicked then how do you do it? If you cant show a toast over the QSB then a notification is acceptable. However, I still need to NOT show my app (and not change its activity stack if it is running in the background). Basically I need my Activity to just notify the user through a toast or notification and stay in the background, never showing itself. How? 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: == How to Toast or Notify in response to ACTION_VIEW without showing my app ==
Nope. That doesnt work either. Here is my code for the activity that responds to the QSB. You'll see that I am using the application context for the toast. My app shows with the toast over it. If it is possible to show a toast over the QSB then how? (Example code) public class GlobalSearchActivity extends Activity { @Override protected void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); String extra = getIntent().getStringExtra( SearchManager.EXTRA_DATA_KEY ); if( extra == null ) finish(); if( ActivityHelpers.isOffline() ) { String message = You can not view this content while offline; Toast.makeText( getApplicationContext(), message, Toast.LENGTH_SHORT).show(); finish(); } else { Intent myIntent = new Intent( this, SplashScreen.class ); myIntent.setAction( getIntent().getAction() ); Bundle extras = getIntent().getExtras(); if( extras != null extras.size() 0 ) myIntent.putExtras( extras ); try { this.startActivity( myIntent ); } catch( ActivityNotFoundException activityNotFoundException ) {} finish(); } } } -- 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: == How to Toast or Notify in response to ACTION_VIEW without showing my app ==
The big problem here seems to be that the target of the Intent thrown from selecting a search suggestion in the Android Quick Search Box must be an Activity. If it could be a Service then I could simply show a toast from that if offline or start the appropriate activity if not. Nope. If its not an activity its not even searchable! But starting an activity shows the app with the activity on the top of the stack. So finish() simply shows the activity that was below it in my app's activity stack. Perhaps i can simulate a back button press after showing the toast. Its a hack though (can you even do that?) Any other ideas? -- 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 Toast or Notify in response to ACTION_VIEW without showing my app ==
When a user clicks on a cached Quick Search Box shortcut it takes the user to an activity that they should not see if they are in airplane mode. I would like to show them a toast or a notification from within the QSB, without showing my app. The message will be You can not view this content while offline. If I simply show a toast from my QuickSearchActivity.onCreate(), then finish() it shows the toast over my app. I want it to show the toast over the QSB. Even if I put the finish() in the onResume() or put it in a postDelayed() it still shows the app. Strange. If it is possible to show a toast over the QSB in response to an item being clicked then how do you do it? If you cant show a toast over the QSB then a notification is acceptable. However, I still need to NOT show my app (and not change its activity stack if it is running in the background). Basically I need my Activity to just notify the user through a toast or notification and stay in the background, never showing itself. How? 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] Quick Search Box - Getting results in All
I can get search results in my app's search area (selecting the app icon in the 2.3 quick search box to restrict the search to my app). However, i dont see any of my results when All is selected. Does android just deprioritize them? What determines what search results show up in the All category? Is there something I need to do? 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] ==Making back return to the app that launched the current activity
I have some results that I am returning to the Android Quick Search Box. When a result is selected it takes the user into my app. However, when the user presses back at this point I want them to return to the Quick Search Box, not to the previous activity in my app. Currently I am starting the activity in my app with: newintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_NEW_TASK); startActivity( newintent ); What do I need to change to make back return to the android Quick Search Box that launched it? Thanks, Clark -- 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: ==Making back return to the app that launched the current activity
If I do that then when my task is started from within my app (rather than the quick search box) wont the affinity defined in the manifest mess it up? If the task is not launched from the QSB but from my app I would like the back button to act as expected but navigating to the previous activity in my app. Only when the activity is started by the QSB do I want its affinity to be associated to the QSB. Since its affinity can be either I would think that means that I cant define it from the manifest. It should be done programmatically. Is there a way or will it work that way anyway? Thanks. On Mar 4, 4:45 pm, Dianne Hackborn hack...@android.com wrote: Use android:taskAffinity= (or some other name like :searchtask) for that activity. On Fri, Mar 4, 2011 at 4:37 PM, ClarkBattle clarkbat...@gmail.com wrote: I have some results that I am returning to the Android Quick Search Box. When a result is selected it takes the user into my app. However, when the user presses back at this point I want them to return to the Quick Search Box, not to the previous activity in my app. Currently I am starting the activity in my app with: newintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_NEW_TASK); startActivity( newintent ); What do I need to change to make back return to the android Quick Search Box that launched it? Thanks, Clark -- 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 -- 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] Re: ==Making back return to the app that launched the current activity
Thanks Dianne. You rock! On Mar 4, 5:36 pm, Dianne Hackborn hack...@android.com wrote: Then use which means to have no affinity, so it will have affinity to whatever task it is part of. You also can not be part of the QSB task there is no such thing -- that is a launching point with a task break to other apps. On Fri, Mar 4, 2011 at 5:04 PM, ClarkBattle clarkbat...@gmail.com wrote: If I do that then when my task is started from within my app (rather than the quick search box) wont the affinity defined in the manifest mess it up? If the task is not launched from the QSB but from my app I would like the back button to act as expected but navigating to the previous activity in my app. Only when the activity is started by the QSB do I want its affinity to be associated to the QSB. Since its affinity can be either I would think that means that I cant define it from the manifest. It should be done programmatically. Is there a way or will it work that way anyway? Thanks. On Mar 4, 4:45 pm, Dianne Hackborn hack...@android.com wrote: Use android:taskAffinity= (or some other name like :searchtask) for that activity. On Fri, Mar 4, 2011 at 4:37 PM, ClarkBattle clarkbat...@gmail.com wrote: I have some results that I am returning to the Android Quick Search Box. When a result is selected it takes the user into my app. However, when the user presses back at this point I want them to return to the Quick Search Box, not to the previous activity in my app. Currently I am starting the activity in my app with: newintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_NEW_TASK); startActivity( newintent ); What do I need to change to make back return to the android Quick Search Box that launched it? Thanks, Clark -- 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 -- 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 -- 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] Re: == Populated MatrixCursor returned to the Global Search shows wrong results ==
The reason this happens is that Google hasn't updated their docs for search in a long time and they are now completely out of date with what the ACTUAL requirements are for cursor rows returned to the Global Search Box. Also, they changed the required columns and uniqueness requirements in 2.2 and didnt tell anyone about it. Google needs to update these docs (http://developer.android.com/guide/topics/ search/adding-custom-suggestions.html). Not only are they wrong but very hard to understand. They introduce WAY too much complexity up front with a misguided emphasis on completeness. It is better to start with several minimal examples that each illustrate a single basic concept. Only then, after the basics have been introduced should you provide more advanced details. Context before exposition. Tech Docs 101. Here's the REAL requirements: BaseColumns._ID - This is documented as required and as a unique INTEGER(long), whatever that means. It is required but as a unique String up until android 2.1. The string need not be numeric (neither an INTEGER or a long). It can be anything, but it must be unique. After 2.1, it can be anything, even null. It doesn't matter. You don't even have to include _id in the cursor at all. SearchManager.SUGGEST_COLUMN_INTENT_DATA - This is documented as optional. It is optional until 2.2, where not only is it a required String but it must be unique! It is required whether you specify android:searchSuggestIntentData in your searchable.xml or not. It does not have to be a URL. So, to be compatible with all versions of android (so far) you need both lines. Like this: private static final String[] SEARCH_CURSOR_COLUMNS = new String[]{ BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2, SearchManager.SUGGEST_COLUMN_INTENT_DATA, SearchManager.SUGGEST_COLUMN_SHORTCUT_ID }; public Cursor query( Uri uri, String[] columns, String where, String[] whereArgs, String sortOrder ) { MatrixCursor cursor = new MatrixCursor( SEARCH_CURSOR_COLUMNS ); cursor.addRow( newCursorRow(uniqueId1, Android docs, Need refactoring) ); cursor.addRow( newCursorRow(uniqueId2, Bait, and Switch) ); return cursor; } private Object[] newCursorRow( String uniqueId, String text1, String text2 ) { return new String[] { uniqueId, // _ID text1, // SUGGEST_COLUMN_TEXT_1 text2, // SUGGEST_COLUMN_TEXT_2 uniqueId, // SUGGEST_COLUMN_INTENT_DATA SearchManager.SUGGEST_NEVER_MAKE_SHORTCUT }; // SUGGEST_COLUMN_SHORTCUT_ID } Clark Battle -- 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] == Populated MatrixCursor returned to the Global Search shows wrong results ==
I am trying to populate results for the global search box. I can currently type in the search box and have my debugger stop in query() just as I would expect. Just as a test I am populating a MatrixCursor manually to return from the query() method. Here is the test code... public class GlobalSearchProvider extends ContentProvider { private static final String[] SEARCH_CURSOR_COLUMNS = new String[] {_ID,SUGGEST_COLUMN_TEXT_1,SUGGEST_COLUMN_TEXT_2,SUGGEST_COLUMN_ICON_1,SUGGEST_COLUMN_INTENT_EXTRA_DATA}; @Override public Cursor query( Uri uri, String[] columns, String where, String[] whereArgs, String sortOrder ) { switch( uriMatcher.match( uri ) ) { case GLOBAL_SEARCH_SUGGESTION_CODE: { return getSuggestionTest( whereArgs[0] ); } default: throw new IllegalArgumentException( Unknown Uri: + uri ); } } private Cursor getSuggestionTest( String searchTerm ) { MatrixCursor cursor = new MatrixCursor( SEARCH_CURSOR_COLUMNS ); if( searchTerm == null || searchTerm.length() == 0 ) return cursor; ArrayListObject columnValues = new ArrayListObject(); columnValues.add( 0 ); // _ID columnValues.add( Poofy and the Buttons); columnValues.add( searchTerm ); columnValues.add( null ); columnValues.add( 0 ); cursor.addRow( columnValues ); ArrayListObject columnValues2 = new ArrayListObject(); columnValues2.add( 1 ); // _ID columnValues2.add( Joe Mama); columnValues2.add( searchTerm ); columnValues2.add( null ); columnValues2.add( 0 ); cursor.addRow( columnValues2 ); int nr = cursor.getCount(); return cursor; } } Here is the searchable.xml searchable xmlns:android=http://schemas.android.com/apk/res/android; android:label=@string/search_label android:hint=@string/search_hint android:searchSuggestAuthority=com.poofy.GlobalSearchProvider android:searchSuggestThreshold=1 android:includeInGlobalSearch=true android:searchSuggestIntentAction=android.Intent.action.VIEW /searchable And in the manifest provider android:name=.GlobalSearchProvider android:authorities=com.poofy.GlobalSearchProvider / Very simple. It returns a cursor with two elements. The debugger shows it working nicely... until you see that the search list actually contains only one result with no text in it! Yes, I have enabled search to get results from my app (or it would have never stopped the debugger). Its as if the contents of the MatrixCursor is not recognized by the system. (I have to use a MatrixCursor because my results do not come from a database.) Any idea what might be happening here? 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: == Populated MatrixCursor returned to the Global Search shows wrong results ==
Oops. My searchable is this. searchable xmlns:android=http://schemas.android.com/apk/res/android; android:label=@string/search_label android:hint=@string/search_hint android:searchSuggestAuthority=com.rhapsody.content.GlobalSearchProvider android:searchSuggestSelection= ? android:searchSuggestThreshold=1 android:includeInGlobalSearch=true android:searchSuggestIntentAction=android.Intent.action.VIEW /searchable And I also have this in the ContentProvider... private static final UriMatcher uriMatcher = buildUriMatcher(); private static UriMatcher buildUriMatcher() { // Add some filters so that when the URI matches one it returns a code UriMatcher matcher = new UriMatcher( UriMatcher.NO_MATCH ); // For global search suggestions matcher.addURI( AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, GLOBAL_SEARCH_SUGGESTION_CODE ); matcher.addURI( AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + / *, GLOBAL_SEARCH_SUGGESTION_CODE ); return matcher; } -- 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: === My ContentProvider.query() can not populate a Cursor. ===
Cool! Thanks. On Feb 8, 10:58 pm, Kostya Vasilyev kmans...@gmail.com wrote: Take a look at MatrixCursor. -- 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] === My ContentProvider.query() can not populate a Cursor. ===
I am making a ContentProvider to provide results of the android global search box. I am supposed to @Override query() to return my results in a Cursor. The problem is that my results do not come from a database. They come from a server that gives me a populated ListContent. Perhaps I need to manually populate a new Cursor with my list contents. However, Cursor appears to be a read only interface. Is there a way to make a new Cursor and populate it manually? If not then what else can I do? What should I do? 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: Receiving hard search button broadcasts within an app
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] Receiving hard search button broadcasts within an app
When the hard search button is pressed while my app is active I want it to open my search activity. I have tried this in the manifest: receiver android:name=.receivers.HardwareSearchReceiver intent-filter action android:name=android.intent.action.SEARCH_LONG_PRESS/ /intent-filter /receiver along with: public class HardwareSearchReceiver extends BroadcastReceiver { @Override public void onReceive( Context context, Intent intent ) {...} } It doesnt work. What is the right way to do this? 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: Buggy sample code for an interview
Thanks for the ideas. On Nov 16, 11:21 am, Kostya Vasilyev kmans...@gmail.com wrote: Ok, a few off top of my head: A ListView, an adapter for it, and getView that doesn't recycle views. Or one that recycles, and only sets values if a new layout is loaded. Code that makes network calls on the UI thread. Code that treats Thread as a Runnable, without calling thread.start() A layout done with px units. Code that does database inserts with literal values in the SQL statement string, rather than using parameters. An Activity that runs an AsyncTask but fails to terminate it or carry it over during orientation changes. -- Kostya 16.11.2010 22:08, ClarkBattle пишет: I think too many interviews are of the write new code variety and not enough of the analyze this code variety. I would like to ask a candidate to analyze some android code. I am looking for a good example with some bugs or potential optimizations in it that can be improved. Does anyone have something like this sitting around that I could use? Any suggestions? Thanks, -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.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
[android-developers] == Type ahead search timer ==
I am implementing a type ahead search so that results are returned as the user is typing. I want to have a timer so that the search is not sent to the server until the user stops typing. Stops typing is defined by a number of milliseconds. I figure that I can use a Timer to start the search in another thread. If another type ahead character is received then I can restart the timer. Is this a reasonable approach or is there a simpler way? 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] Buggy sample code for an interview
I think too many interviews are of the write new code variety and not enough of the analyze this code variety. I would like to ask a candidate to analyze some android code. I am looking for a good example with some bugs or potential optimizations in it that can be improved. Does anyone have something like this sitting around that I could use? Any suggestions? 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: === IllegalArgumentException: View not attached to window manager ===
Thanks Dianne, I'm still not sure what to do about it though. I often dont have the reference to the dialog in onDestroy(). A lot of people have had trouble with this. Rotating dialogs shouldn't be this difficult. On Nov 8, 2:41 pm, Dianne Hackborn hack...@android.com wrote: This is definitely an error -- if you are getting the report, the user saw an app crash dialog, and explicitly asked it to report the error to you. This is probably a good example of why android:configChanges is dangerous -- it can hide real errors by making them less likely to be seen. In this case, if you were doing this to take care of such errors about dialogs being closed, this wouldn't be fixing a problem but just making it less likely to be seen. Generally what is happening in such an error is that the app is dismissing a dialog after its containing activity has been destroyed. This could be because of it being restarted due to a config change, or could just as well be it being destroyed after the user pressed back to finish it. In either case, you should make sure to dismiss such dialogs yourself before the activity is destroyed. On Mon, Nov 8, 2010 at 2:02 PM, ClarkBattle clarkbat...@gmail.com wrote: There are about 10 different dialogs and they are are all a little different. I have no idea which one it is coming from. I think this is a non-error. Dismissing a dialog that has already been destroyed by android is not really a problem. I'll just try-catch the exception at every dialog.dismiss(). -- 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 -- 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] === IllegalArgumentException: View not attached to window manager ===
I am getting this error automatically sent to me from a lot of beta users. java.lang.IllegalArgumentException: View not attached to window manager at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java: 355) at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200) at android.view.Window $LocalWindowManager.removeView(Window.java:432) at android.app.Dialog.dismissDialog(Dialog.java:278) at android.app.Dialog.access$000(Dialog.java:71) at android.app.Dialog$1.run(Dialog.java:111) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:143) at android.app.ActivityThread.main(ActivityThread.java:4701) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method) Since it comes from external beta users I dont know what they were doing when they got it. Nor do i know how to reproduce it. The stack trace does not list any of our code. Usually, this error means that there was an orientation change while a dialog was open, thereby invalidating the reference to the dialog when android recreates it. All of my activities already uses android:configChanges=keyboardHidden|orientation in order to prevent them from doing this. We still get the error. Has anyone else seen this before? What could be the problem? Thanks, Clark -- 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: === IllegalArgumentException: View not attached to window manager ===
There are about 10 different dialogs and they are are all a little different. I have no idea which one it is coming from. I think this is a non-error. Dismissing a dialog that has already been destroyed by android is not really a problem. I'll just try-catch the exception at every dialog.dismiss(). -- 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] Programmatically resizing a custom view?
I am trying to programmatically resize a custom view in android. The custom view contains a Button and an EditText in a LinearLayout. I want to make several instances of this custom view and alter the width of each one slightly narrower than the last so that they overlap each other. At what point can I do this and how? If I override the custom view's onWindowFocusChanged() to set the width using this.setLayoutParams( newWidth, LayoutParams.FILL_PARENT); it crashes later on with a ClassCastException in the LinearLayout. Like this... @Override public void onWindowFocusChanged( boolean changed ) { super.onWindowFocusChanged( changed ); // reset the width int fullWidth = this.getWidth(); if( fullWidth 0 ) { int width = fullWidth - (20 * (viewNumber)); this.setLayoutParams(new LinearLayout.LayoutParams( width, LayoutParams.FILL_PARENT)); } } So, obviously, this is not the way to do it. How then? 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: TextView resets its location after an animation
The answer is that it needs to have animation.setFillAfter( true ); in order to persist the animation after its end. Strange that this is not true by default. On Sep 17, 3:09 pm, ClarkBattle clarkbat...@gmail.com wrote: Ive tried several interpolators and many different values. It always resets. RELATIVE_TO_PARENT is not appropriate for this app. I have a small textView that just needs to shrink to a small strip on the side of the screen when swiped, exposing another text view below it. Thanks though. On Sep 17, 12:55 pm, Tommy droi...@gmail.com wrote: I haven't worked to much with animations but the ones I have that slide in from the right look like this: Animation inFromRight = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f ); inFromRight.setDuration(600); inFromRight.setInterpolator(new AccelerateInterpolator()); maybe try to copy and paste that into your app and see if it changes anything. They look almost the same to me except for some numbers and AccelerateInterpolator that I use. Let me know if it works if you copy/paste it. Tommy Android Mobile Phone Application Developer Database Administrator .net Web Specialist -Original Message- From: android-developers@googlegroups.com [mailto:android-develop...@googlegroups.com] On Behalf Of ClarkBattle Sent: Friday, September 17, 2010 3:37 PM To: Android Developers Subject: [android-developers] TextView resets its location after an animation I am using a Translate animation on a text view. TranslateAnimation animation = new TranslateAnimation( TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.8f, TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF, 0f ); animation.setDuration( ANIMATION_DURATION ); animation.setInterpolator( new DecelerateInterpolator() ); myTextView.startAnimation( animation ); This works in that it slides the text view to the right. However, when the animation is complete it puts the text view right back where it started! I was under the impression tat the view should remain where the animation left it. Why does this happen? 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 athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: TextView resets its location after an animation
The answer is that it needs to have animation.setFillAfter( true ); in order to persist the animation after its end. Strange that this is not true by default. On Sep 17, 3:09 pm, ClarkBattle clarkbat...@gmail.com wrote: Ive tried several interpolators and many different values. It always resets. RELATIVE_TO_PARENT is not appropriate for this app. I have a small textView that just needs to shrink to a small strip on the side of the screen when swiped, exposing another text view below it. Thanks though. On Sep 17, 12:55 pm, Tommy droi...@gmail.com wrote: I haven't worked to much with animations but the ones I have that slide in from the right look like this: Animation inFromRight = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f ); inFromRight.setDuration(600); inFromRight.setInterpolator(new AccelerateInterpolator()); maybe try to copy and paste that into your app and see if it changes anything. They look almost the same to me except for some numbers and AccelerateInterpolator that I use. Let me know if it works if you copy/paste it. Tommy Android Mobile Phone Application Developer Database Administrator .net Web Specialist -Original Message- From: android-developers@googlegroups.com [mailto:android-develop...@googlegroups.com] On Behalf Of ClarkBattle Sent: Friday, September 17, 2010 3:37 PM To: Android Developers Subject: [android-developers] TextView resets its location after an animation I am using a Translate animation on a text view. TranslateAnimation animation = new TranslateAnimation( TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.8f, TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF, 0f ); animation.setDuration( ANIMATION_DURATION ); animation.setInterpolator( new DecelerateInterpolator() ); myTextView.startAnimation( animation ); This works in that it slides the text view to the right. However, when the animation is complete it puts the text view right back where it started! I was under the impression tat the view should remain where the animation left it. Why does this happen? 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 athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] TextView resets its location after an animation
I am using a Translate animation on a text view. TranslateAnimation animation = new TranslateAnimation( TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.8f, TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF, 0f ); animation.setDuration( ANIMATION_DURATION ); animation.setInterpolator( new DecelerateInterpolator() ); myTextView.startAnimation( animation ); This works in that it slides the text view to the right. However, when the animation is complete it puts the text view right back where it started! I was under the impression tat the view should remain where the animation left it. Why does this happen? 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: TextView resets its location after an animation
Ive tried several interpolators and many different values. It always resets. RELATIVE_TO_PARENT is not appropriate for this app. I have a small textView that just needs to shrink to a small strip on the side of the screen when swiped, exposing another text view below it. Thanks though. On Sep 17, 12:55 pm, Tommy droi...@gmail.com wrote: I haven't worked to much with animations but the ones I have that slide in from the right look like this: Animation inFromRight = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f ); inFromRight.setDuration(600); inFromRight.setInterpolator(new AccelerateInterpolator()); maybe try to copy and paste that into your app and see if it changes anything. They look almost the same to me except for some numbers and AccelerateInterpolator that I use. Let me know if it works if you copy/paste it. Tommy Android Mobile Phone Application Developer Database Administrator .net Web Specialist -Original Message- From: android-developers@googlegroups.com [mailto:android-develop...@googlegroups.com] On Behalf Of ClarkBattle Sent: Friday, September 17, 2010 3:37 PM To: Android Developers Subject: [android-developers] TextView resets its location after an animation I am using a Translate animation on a text view. TranslateAnimation animation = new TranslateAnimation( TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.8f, TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF, 0f ); animation.setDuration( ANIMATION_DURATION ); animation.setInterpolator( new DecelerateInterpolator() ); myTextView.startAnimation( animation ); This works in that it slides the text view to the right. However, when the animation is complete it puts the text view right back where it started! I was under the impression tat the view should remain where the animation left it. Why does this happen? 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 athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: A hand of cards
Thanks! On Sep 15, 5:42 pm, Mark Murphy mmur...@commonsware.com wrote: Use a RelativeLayout (for the overlapping cards) and a TranslateAnimation (for the movement of a card). On Wed, Sep 15, 2010 at 8:33 PM, ClarkBattle clarkbat...@gmail.com wrote: Imagine that you had five overlapped playing cards horizontally fanned so that you could see the top card and the right edges of the other four. Now you slide over the top card until its right edge is on the left of the screen, revealing the body of the second card with the right edges of the remaining three cards on the right. Any idea how to do this? I dont want to fake it with a plain old view flipper and dummy images that pop up on the side. It has to animate and scroll as if it were a real card. Is there any code that does something similar? -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy -- 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] A hand of cards
Imagine that you had five overlapped playing cards horizontally fanned so that you could see the top card and the right edges of the other four. Now you slide over the top card until its right edge is on the left of the screen, revealing the body of the second card with the right edges of the remaining three cards on the right. Any idea how to do this? I dont want to fake it with a plain old view flipper and dummy images that pop up on the side. It has to animate and scroll as if it were a real card. Is there any code that does something similar? 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: Eclipse debugger is skipping instructions!
Great insights. I had broken everything out onto separate lines just to force the compiler to evaluate each separately. I never figured that it would get all smart and ignore what I wrote. I refactored the code and now it runs as expected. Clark -- 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 debugger is skipping instructions!
I am debugging an app that tests an API I wrote. There is a section of code that simply reads a DB cursor like this: Cursor row = mDatabase.query(properties, null, where, null, null, null, null, null); if( row != null ) { if( row.moveToFirst() ) // A { int n=row.getColumnIndexOrThrow(value); value = row.getString( n ); // B } } The debugger steps through line at a time until it gets to the line commented // A. The next line the debugger gets to is the line commented // B!!! It completely skips over the int n =... line. Even stranger, at that point the int n is not listed as being in scope at all. Basically, as soon as it executes any method on row the debugger skips. I also have to step twice over each clause in any conditional. So this: if( a==2 || b==4 ) would require four step over actions to get past it. Very strange. I re-installed the latest version of eclipse with the latest ADB and the latest emulator. It still happens. This is running against Android 2.0, which is a requirement. I am on Windows 7 64 bit with a 32 bit installation of eclipse. Has anyone seen this strange debugger behavior? What should I try to do? 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] All of the sudden = IOException java.net.UnknownHostException: Host is unresolved: www.google.com:443
I have a method that I use to get the auth token for a user. I have been using it for months with no problem. All of the sudden today it stated failing with: IOException java.net.UnknownHostException: Host is unresolved: www.google.com:443 The manifest contains uses-permission android:name=android.permission.INTERNET / The code has not changed since it worked. It is: public static String getAuthToken( String gmail, String pwd ) { //=== Validate params if( gmail == null || gmail.length() == 0 ) return null; if( pwd == null || pwd.length() == 0 ) return null; if( gmail.toLowerCase().endsWith( @gmail.com ) == false ) gmail += @gmail.com; //=== Get the auth token String authToken = null; try { HttpsURLConnection uc = (HttpsURLConnection)new URL( mAuthURL ).openConnection(); if( uc != null ) { HostnameVerifier HOSTNAME_VERIFIER = new HostnameVerifier() { public boolean verify( String hostname, SSLSession session ) { return mHostName.equals( hostname ); } }; uc.setHostnameVerifier( HOSTNAME_VERIFIER ); uc.setDoOutput( true ); uc.setRequestMethod( POST ); uc.setRequestProperty( Content-Type, application/x-www-form- urlencoded ); uc.setUseCaches( false ); BufferedWriter bw = new BufferedWriter( new OutputStreamWriter( uc.getOutputStream() ), BUFFER_SIZE ); if( bw != null ) { bw.write( URLEncoder.encode( accountType, UTF-8 ) + = + URLEncoder.encode( HOSTED_OR_GOOGLE, UTF-8 ) + ); bw.write( URLEncoder.encode( Email, UTF-8 ) + = + URLEncoder.encode( gmail, UTF-8 ) + ); bw.write( URLEncoder.encode( Passwd, UTF-8 ) + = + URLEncoder.encode( pwd, UTF-8 ) + ); bw.write( URLEncoder.encode( source, UTF-8 ) + = + URLEncoder.encode( icd-MyCalendar, UTF-8 ) + ); bw.write( URLEncoder.encode( service, UTF-8 ) + = + URLEncoder.encode( cl, UTF-8 ) ); bw.close(); } if( uc.getResponseCode() != HttpsURLConnection.HTTP_FORBIDDEN ) { BufferedReader in = new BufferedReader( new InputStreamReader( uc.getInputStream() ), BUFFER_SIZE ); if( in != null ) { for( String line = in.readLine(); line != null; line = in.readLine() ) if( line != null line.toLowerCase().startsWith( auth= ) ) { authToken = line.substring( 5 ); break; } in.close(); } } } } catch( IOException ex ) { ex.printStackTrace(); } return authToken; } -- 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: All of the sudden = IOException java.net.UnknownHostException: Host is unresolved: www.google.com:443
Strangely, I restarted eclipse and the problem went away. -- 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] Unseen GridViews in a ViewFlipper dont inflate?
Hello, I am having a problem with a calendar app i am writing. I have three GridViews within a ViewFlipper . Each GridView shows a month. The ViewFlipper responds to flings in order to flip to the next or previous month GridView and update the unseen GridViews. The problem is that while the first month shows perfectly the adjacent two months in either direction dont appear at all until the user has flinged past them to the third month away. So if I start in February, March wont show until I fling to May and then back to March. April wont show until I fling to June and back. However, once I fling to June all months show correctly and the calendar works perfectly in both directions. It would appear to be an initialization problem but the method that initializes the months is the same used to flip the months. All three months are initialized to now in the constructor and then flipped by 0, +1, -1 using the same method that flips them on fling. I thought that unseen GridViews might not inflate immediately, so I tried waiting for a few minutes before flinging and it still happened. I am calling onFinishInflate() everywhere things are being inflated and they are all called predictably. The GridView population happens in a separate thread, so I suspected that the GridView is displayed before the thread has a chance to finish running. However, this theory is suspect because the problem only happens on initialization. After three flings the whole thing works perfectly regardless of how fast or slow you fling it. At this point I am at a loss. When I tried this using TableLayouts instead of GridViews the fling initialization worked perfectly (but the grid was not uniform, so I cant use TableLayout). Is there some strange interaction between GridView and ViewSwitcher that prevents the unseen GridViews from rendering immediately? Any ideas? Thanks, Clark -- 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: Unseen GridViews in a ViewFlipper dont inflate?
The problem appears to be that findViewById() returns null when looking for the views within the GridView, until the ViewFlipper has flipped a few times. -- 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: Unseen GridViews in a ViewFlipper dont inflate?
Of course, i still dont know why. -- 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: Equally spaced TableLayout grid
I think you just have to use GridView -- 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 can a parent handle touch events BEFORE its children?
I have a custom view (A) that contains a ViewFlipper, which flips between three custom views (B1, B2, B3). Each B view is a LinearLayout containing a TextView and a GridView. The problem is that i need touch events on the GridView to be handled by the A view. This is so that fling events on any GridView get handled by the ViewFlipper. It seems simple enough... just make the touch listeners for the B views and GridViews return false, right? Wrong. It doesnt work. The B.onTouchEvent() is never called by touch events on a GridView and neither is ViewFlipper.onTouchEvent(). Strange but true, and I have the Logs to prove it. I tried passing an instance of the parent A view to each of the B views so that when a touch event happens I can dispatch all touch events to the parent A view. The result...an infinite loop and stack overflow because the A view first passes the event back to its children. How do I get a view to handle all of its touch events without passing those events to its children? In truth, i dont need children to respond to ANY touch events at all. Ideally, I would like ALL touch events to be handled by the A view and never by any of its children. Is there a way to force this? 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: How can a parent handle touch events BEFORE its children?
Brilliant! Thanks :) On Feb 2, 3:15 pm, Romain Guy romain...@android.com wrote: Just override dispatchTouchEvent() in your custom view A and don't call super.dispatchTouchEvent(). -- 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] Equally spaced TableLayout grid
I have a TableLayout where each cell of the table contains a single button or textView. I want to make sure that every cell has the same height and the same width. In other words all column widths are the same and all row heights are the same. Of course, it has to do this while resizing the TableLayout to its given layout_width and layout_height. Do I have to do the math myself and set each cell manually or is there an automatic way to do it? 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] View.getLocationInWindow() only returns Y (and sometimes not even X)
I have an app with the following code using android 2.0.1 int[] loc = new int[2]; Button btn = (Button) findViewById( R.id.btn3 ); if( btn != null ) btn.getLocationInWindow( loc); Log.i(Where?,x= + where[0] + y= + where[1] ); This logs x=0 y=88 but R.id.btn3 is in the middle of the screen! I was experiencing this in android 2.0.1 so I wrote the following test app in android 2.1 that logs the XY coordinates of a button in the middle of the screen. This logs x=0 and y=0 public class TestLoc extends Activity { @Override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.main ); } @Override public void onStart() { super.onStart(); int[] where = new int[2]; Button view = (Button) findViewById( R.id.btnThree ); if( view != null ) { view.getLocationInWindow( where ); Log.i(Where?,x= + where[0] + y= + where[1] ); } } } ?xml version=1.0 encoding=utf-8? TableLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_width=wrap_content android:layout_height=wrap_content TableRow android:id=@+id/rowOne Button android:id=@+id/btnOne/ /TableRow TableRow android:id=@+id/rowTwo Button android:id=@+id/btnTwo/ Button android:id=@+id/btnThree/ /TableRow /TableLayout Wha's up? Is there a reliable way to get the window coordinates of any view? Thanks for reading, Clark -- 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: View.getLocationInWindow() only returns Y (and sometimes not even X)
Sorry, in that first example I meant; Log.i(Where?,x= + loc[0] + y= + loc[1] ); not Log.i(Where?,x= + where[0] + y= + where[1] ); Copy/paste user error :) -- 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: View.getLocationInWindow() only returns Y (and sometimes not even X)
But its in onStart() while the layout happens in onCreate(). There is no onFinishInflate() for Activities. How do i make sure that the inflation has happened? On Jan 28, 2:52 pm, Romain Guy romain...@android.com wrote: You are probably calling getLocationInWindow() before the layout happened. On Thu, Jan 28, 2010 at 2:50 PM, ClarkBattle clarkbat...@gmail.com wrote: I have an app with the following code using android 2.0.1 int[] loc = new int[2]; Button btn = (Button) findViewById( R.id.btn3 ); if( btn != null ) btn.getLocationInWindow( loc); Log.i(Where?,x= + where[0] + y= + where[1] ); This logs x=0 y=88 but R.id.btn3 is in the middle of the screen! I was experiencing this in android 2.0.1 so I wrote the following test app in android 2.1 that logs the XY coordinates of a button in the middle of the screen. This logs x=0 and y=0 public class TestLoc extends Activity { �...@override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.main ); } �...@override public void onStart() { super.onStart(); int[] where = new int[2]; Button view = (Button) findViewById( R.id.btnThree ); if( view != null ) { view.getLocationInWindow( where ); Log.i(Where?,x= + where[0] + y= + where[1] ); } } } ?xml version=1.0 encoding=utf-8? TableLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_width=wrap_content android:layout_height=wrap_content TableRow android:id=@+id/rowOne Button android:id=@+id/btnOne/ /TableRow TableRow android:id=@+id/rowTwo Button android:id=@+id/btnTwo/ Button android:id=@+id/btnThree/ /TableRow /TableLayout Wha's up? Is there a reliable way to get the window coordinates of any view? Thanks for reading, Clark -- 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: findViewById doesnt work directly after inflate() !! Why?
I ended up changing extending a View to a FrameLayout. This way I can use it as the root in inflate because it is a ViewGroup. I think the problem was that having a null parent in an inflate doesnt actually render the views. I may be wrong about this but it worked for me. Caching the subviews in onFinishInflate() is a good idea, so i did that too. Thanks. On Jan 19, 5:25 pm, Jason Proctor jason.android.li...@gmail.com wrote: override onFinishInflate() and cache your subviews there. the view constructor is too early for findViewById(). I have an activity defined as: public class FlipperDemo extends Activity { �...@override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.main ); } } With this in main.xml ?xml version=1.0 encoding=utf-8? com.test.MyFlipper xmlns:android=http://schemas.android.com/apk/res/android; android:layout_width=wrap_content android:layout_height=wrap_content / MyFlipper.java contains class MyFlipper extends View { public MyView( Context context, AttributeSet attrs ) { super( context, attrs ); ViewFlipper flipper1 = (ViewFlipper) LayoutInflater.from ( context ).inflate( R.layout.myflipper, null ); ViewFlipper flipper2 = (ViewFlipper) findViewById ( R.id.flipper ); } } And myflipper.xml contains ?xml version=1.0 encoding=utf-8? ViewFlipper xmlns:android=http://schemas.android.com/apk/res/ android android:id=@+id/flipper android:layout_width=fill_parent android:layout_height=fill_parent Button android:id=@+id/button1 android:layout_width=fill_parent android:layout_height=fill_parent / Button android:id=@+id/button2 android:layout_width=fill_parent android:layout_height=fill_parent / /ViewFlipper The problem is that in the MyView() constructor flipper1 gets set, but flipper2 is null! Why cant i get flipper by Id here? -- 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 -- 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] Why aren't ACTION_UP and ACTION_MOVE Touch Events passed through to custom views?
I have an activity defined as: public class MyDemo extends Activity { @Override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.main ); } @Override public boolean onTouchEvent(MotionEvent me) { Log.i(MyDemo motion, + me.getAction()); return false; } } With this custom view in main.xml ?xml version=1.0 encoding=utf-8? com.test.MyCustomView xmlns:android=http://schemas.android.com/apk/res/android; android:layout_width=wrap_content android:layout_height=wrap_content / MyCustomView.java contains public class MyCustomView extends FrameLayout implements OnGestureListener { public MyTest( Context context, AttributeSet attrs ) { super( context, attrs ); LayoutInflater.from( context ).inflate( R.layout.doofer, this, true ); } @Override public boolean onTouchEvent(MotionEvent me) { Log.i(MyCustomView motion, + me.getAction()); return false; } } And finally doofer.xml is ?xml version=1.0 encoding=utf-8? FrameLayout xmlns:android=http://schemas.android.com/apk/res/ android android:id=@+id/dooferFrame android:layout_width=200dip android:layout_height=200dip android:background=#80ff TextView android:id=@+id/doofer android:layout_width=fill_parent android:layout_height=fill_parent / /FrameLayout So... looking at LogCat we can see the motion events that occur. The MyDemo Activity logs down, up and move events perfectly as expected. However, MyCustomView only logs down events! Why aren't ACTION_UP and ACTION_DOWN Touch Events passed through to custom views? I need to handle the touch events in the custom view (not the activity) because there are several custom views in the activity and all of them need to respond individually to fling motions. Detecting fling events in the activity wont tell me over which view the fling event happened. So i would like to handle the touch events in the custom view (its a better OO practice than handling it in the Activity). Any Clue? -- 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: Why aren't ACTION_UP and ACTION_MOVE Touch Events passed through to custom views?
Strange. According to the docs false means that the event has not been handled: true if the event is consumed, else false Changing it to true works though. Thanks. On Jan 20, 12:53 pm, Romain Guy romain...@android.com wrote: Because you return false, which means you don't want to handle events. On Wed, Jan 20, 2010 at 12:49 PM, ClarkBattle clarkbat...@gmail.com wrote: I have an activity defined as: public class MyDemo extends Activity { �...@override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.main ); } �...@override public boolean onTouchEvent(MotionEvent me) { Log.i(MyDemo motion, + me.getAction()); return false; } } With this custom view in main.xml ?xml version=1.0 encoding=utf-8? com.test.MyCustomView xmlns:android=http://schemas.android.com/apk/res/android; android:layout_width=wrap_content android:layout_height=wrap_content / MyCustomView.java contains public class MyCustomView extends FrameLayout implements OnGestureListener { public MyTest( Context context, AttributeSet attrs ) { super( context, attrs ); LayoutInflater.from( context ).inflate( R.layout.doofer, this, true ); } �...@override public boolean onTouchEvent(MotionEvent me) { Log.i(MyCustomView motion, + me.getAction()); return false; } } And finally doofer.xml is ?xml version=1.0 encoding=utf-8? FrameLayout xmlns:android=http://schemas.android.com/apk/res/ android android:id=@+id/dooferFrame android:layout_width=200dip android:layout_height=200dip android:background=#80ff TextView android:id=@+id/doofer android:layout_width=fill_parent android:layout_height=fill_parent / /FrameLayout So... looking at LogCat we can see the motion events that occur. The MyDemo Activity logs down, up and move events perfectly as expected. However, MyCustomView only logs down events! Why aren't ACTION_UP and ACTION_DOWN Touch Events passed through to custom views? I need to handle the touch events in the custom view (not the activity) because there are several custom views in the activity and all of them need to respond individually to fling motions. Detecting fling events in the activity wont tell me over which view the fling event happened. So i would like to handle the touch events in the custom view (its a better OO practice than handling it in the Activity). Any Clue? -- 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] findViewById doesnt work directly after inflate() !! Why?
I have an activity defined as: public class FlipperDemo extends Activity { @Override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.main ); } } With this in main.xml ?xml version=1.0 encoding=utf-8? com.test.MyFlipper xmlns:android=http://schemas.android.com/apk/res/android; android:layout_width=wrap_content android:layout_height=wrap_content / MyFlipper.java contains class MyFlipper extends View { public MyView( Context context, AttributeSet attrs ) { super( context, attrs ); ViewFlipper flipper1 = (ViewFlipper) LayoutInflater.from ( context ).inflate( R.layout.myflipper, null ); ViewFlipper flipper2 = (ViewFlipper) findViewById ( R.id.flipper ); } } And myflipper.xml contains ?xml version=1.0 encoding=utf-8? ViewFlipper xmlns:android=http://schemas.android.com/apk/res/ android android:id=@+id/flipper android:layout_width=fill_parent android:layout_height=fill_parent Button android:id=@+id/button1 android:layout_width=fill_parent android:layout_height=fill_parent / Button android:id=@+id/button2 android:layout_width=fill_parent android:layout_height=fill_parent / /ViewFlipper The problem is that in the MyView() constructor flipper1 gets set, but flipper2 is null! Why cant i get flipper by Id here? -- 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] CircularLayout for HorizontalScrollView ?
I am writing an day planner that requires fling gestures to horizontally scroll to the next previous day. Each day contains text and buttons and whatnot. I would like to use HorizontalScrollView for the scrolling. The problem is that a horizontal LinearLayout is bounded at creation. In other words, I have to decide how many days I want to be able to scroll through in advance. That will not work. What I would like is a CircularLayout to use as a child of HorizontalScrollView. The CircularLayout would have three frames: current, next previous. Every time the CircularLayout is scrolled the three frames are re-rendered to give the impression of an infinite list of views. Is there any way to do this? is there another way that will give me what I want? Thanks, Clark -- 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: Implementing a touchable calendar
So if I use the 42 buttons approach then is it better to enclose them in a TableLayout or a GridView? Thanks! On Jan 12, 3:50 pm, Mark Murphy mmur...@commonsware.com wrote: ClarkBattle wrote: Is my 42 buttons is too many assumption correct? If the assumption is that it is a resource hogging solution, I wouldn't worry about it. A reasonably complicated ListView might have many more widgets than that, and scrolling/recycling to deal with besides. Is my keyboard assumption correct? You cannot embed an IME as if it were a View. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 In Print! -- 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: Implementing a touchable calendar
Thanks for your help! On Jan 12, 5:25 pm, Mark Murphy mmur...@commonsware.com wrote: ClarkBattle wrote: So if I use the 42 buttons approach then is it better to enclose them in a TableLayout or a GridView? TableLayout, since you don't need selection or scrolling, which are key things GridView brings to the table. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy Android App Developer Training:http://commonsware.com/training -- 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] Android Bug: Time.parse3339 crashes BEFORE it throws a TimeFormatException!
Here is some code I write to parse a 3339 time that I get back from Google's gData: try { Log.d(setUpdated, newTime ); Time time = new Time(); if( time.parse3339( newTime ) ) { this.mUpdated = time; } } catch( android.util.TimeFormatException ex ) { ex.printStackTrace(); } Here is some of the log output from LogCat: setUpdated 2010-01-07T20:26:29.000Z setUpdated 2010-01-07T20:26:36.000Z setUpdated 2010-01-07T20:26:22.000Z setUpdated 2010-01- Then it crashes because of a TimeFormatException. The times are coming from the gData calendar API so it is surprising that it returns a bad time in only one case. However, that is not the problem. Notice that I said that it CRASHES because of a TimeFormatException, not that it THROWS a TimeFormatException. I said that because it doesnt actually throw the exception! If I put a breakpoint on the stack trace line the debugger never gets there. if I put a Log.d there it doesnt display. If i change the catch to an Exception it still never gets there. However, dalvikvm clearly outputs the TimeFormatException and its stack trace to LogCat. (I'd post it here but you cant copy-paste from LogCat). This leads me to believe that there is a bug in android.text.format.Time.parse3339() where it crashes before it has the opportunity to throw the exception it just logged! Has anyone else seen this? This is using Android 2.0. Is it known and fixed in 2.0.1? Is there a way to report this to the android devs? -- 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: Android Bug: Time.parse3339 crashes BEFORE it throws a TimeFormatException!
I just confirmed that this is fixed in 2.0.1! -- 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: Why is my eclipse up to date with 2.0.1 but no android tools appear in the UI?
Apparently this is a common issue with Windows 7 and eclipse plugins. Eclipse does not like having more than one plug in at a time on Windows 7. Doing so may or may not work depending on how astrological constellations align with the mating cycle of the Australian Gypsy Moth. The solution is to log in as admin and blow away C:\Users\admin \.eclipse directory. Eclipse will recreate it when you restart it. You then have to re-enter the plug-in url for android and update it. This time android will be the only plug in. Not even the ones that came with Eclipse will be there. This fixed it for me. On Jan 4, 3:38 pm, Daan daan_v...@hotmail.com wrote: I am on Windows 7 too, but didn't have any problem installing the Android SDK. Try watching this videohttp://www.youtube.com/watch?v=lqPfi6N4iEY and see if you missed out any steps. It's Windows XP, but it doesn't matter it works the same as Vista and 7. On Jan 4, 11:24 pm, ClarkBattle clarkbat...@gmail.com wrote: I am installing on Windows 7. Window Preferences... Android is not there, even though the tools are installed. Reinstalling Eclipse does not fix the problem. On Jan 4, 1:10 pm, ClarkBattle clarkbat...@gmail.com wrote: I was completely set up with android 2.0 and eclipse. Everything worked fine. Then I tried to upgrade to 2.0.1 and now eclipse wont show any of the android plug in stuff. There is nothing in the IDE relating to android anymore. No AVD, no android projects, nothing. If I go to Help - Install New Software, select Android Eclair -https://dl-ssl.google.com/android/eclipse/; for the Work with, and look under Developer Tools I get these: Android DDMS 0.9.5.v200911191123-20404 Android Development Tools 0.9.5.v200911191123-20404 These are the mot current android 2.0.1 tools. It shows that they are already installed (clicking the Hide items that are already installed box removes them). However, eclipse looks like i just installed it vanilla with no plugins at all. Is there something else I need to do? Check for Updates says there is nothing to update. Should I blow away eclipse and reinstall it from scratch? Doesnt that defeat the purpose of the automatic updater? Confused -- 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 is my eclipse up to date with 2.0.1 but no android tools appear in the UI?
I was completely set up with android 2.0 and eclipse. Everything worked fine. Then I tried to upgrade to 2.0.1 and now eclipse wont show any of the android plug in stuff. There is nothing in the IDE relating to android anymore. No AVD, no android projects, nothing. If I go to Help - Install New Software, select Android Eclair - https://dl-ssl.google.com/android/eclipse/; for the Work with, and look under Developer Tools I get these: Android DDMS0.9.5.v200911191123-20404 Android Development Tools 0.9.5.v200911191123-20404 These are the mot current android 2.0.1 tools. It shows that they are already installed (clicking the Hide items that are already installed box removes them). However, eclipse looks like i just installed it vanilla with no plugins at all. Is there something else I need to do? Check for Updates says there is nothing to update. Should I blow away eclipse and reinstall it from scratch? Doesnt that defeat the purpose of the automatic updater? Confused -- 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: Why is my eclipse up to date with 2.0.1 but no android tools appear in the UI?
I am installing on Windows 7. Window Preferences... Android is not there, even though the tools are installed. Reinstalling Eclipse does not fix the problem. On Jan 4, 1:10 pm, ClarkBattle clarkbat...@gmail.com wrote: I was completely set up with android 2.0 and eclipse. Everything worked fine. Then I tried to upgrade to 2.0.1 and now eclipse wont show any of the android plug in stuff. There is nothing in the IDE relating to android anymore. No AVD, no android projects, nothing. If I go to Help - Install New Software, select Android Eclair -https://dl-ssl.google.com/android/eclipse/; for the Work with, and look under Developer Tools I get these: Android DDMS 0.9.5.v200911191123-20404 Android Development Tools 0.9.5.v200911191123-20404 These are the mot current android 2.0.1 tools. It shows that they are already installed (clicking the Hide items that are already installed box removes them). However, eclipse looks like i just installed it vanilla with no plugins at all. Is there something else I need to do? Check for Updates says there is nothing to update. Should I blow away eclipse and reinstall it from scratch? Doesnt that defeat the purpose of the automatic updater? Confused -- 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: Launching an external activity from a widget
Thanks a lot Mark, Dianne and Walter. We ended up having to call pendingIntent.send() before the call to remoteView.setOnClickPendingIntent() in the handleButtonAction() method. That works, although it seems like the remote view should be responsible for sending the pending intent. Thanks again! Clark On Dec 22, 6:12 pm, Mark Murphy mmur...@commonsware.com wrote: ClarkBattle wrote: The other developer is sitting right next to me. Its the same company. Well, that certainly simplifies matters... :-) He just implemented an intent-filter in his manifest to listen for an action called com.poof.intent.action.MovieApp Does his intent-filter have anything else? For these sorts of things, I usually just have the action element in the filter and nothing else. You don't need a category or anything, and they can actually get in the way a bit. For example, if his intent-filter has a category, you'll need that category in your Intent as well, AFAIK. I changed my code to Intent intent = new Intent( com.poof.intent.action.MovieApp ); intent.putExtra(FILENAME, MOVIES[state.currentMovie].filename); PendingIntent pendingIntent = PendingIntent.getActivity( context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT ); remoteView.setOnClickPendingIntent( R.id.btnDoIt, pendingIntent ); And updated his apk on my emulator. The button still does nothing. Any ideas? Examples? Well, assuming his intent-filter is just the action, that should be fine. Are you seeing any warnings in LogCat? If Android can't find a match on the Intent, it'll toss out a warning, not an error. Also, you could toss together a scrap project and call a regular startActivity() in there on the Intent, to see if that launches. That'll tell you if your problem is in the Intent construction or in the app widget proper. In terms of an example, here's one where I am starting up the browser on a URL: Intent i=new Intent(Intent.ACTION_VIEW, Uri.parse(c.getString(1))); PendingIntent pi=PendingIntent.getActivity(this, 0, i, 0); updateViews.setOnClickPendingIntent(R.id.title, pi); updateViews.setOnClickPendingIntent(R.id.panel, pi); In this case, I am using the same PendingIntent on two views in the app widget, because the title itself (a TextView) is kinda thin and difficult to tap, so I have the panel (a layout) behind it also respond to a click to provide a larger target. Also, c.getString(1) is pulling a String URL value out of a Cursor. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy Android App Developer Training:http://commonsware.com/training -- 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] Launching an external activity from a widget
I have written a widget that cycles through a series of movie poster images with next/prev buttons. This works. There is another button on the widget that needs to launch an external activity, sending it the name of the shown movie. The other activity is not in the same namespace, package or eclipse project as the widget. It is written by another developer and its apk is installed on my emulator. What code do I need to start up an external activity from a widget? I tried this in my handleButtonAction() method. Intent intent = new Intent( Intent.ACTION_VIEW ); intent.setClassName( context, com.poof.ExternalMovieApp ); intent.putExtra(FILENAME, MOVIES[state.currentMovie].filename); PendingIntent pendingIntent = PendingIntent.getActivity( context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT ); remoteView.setOnClickPendingIntent( R.id.btnDoIt, pendingIntent ); I tried it with and without the action parameter in the intent constructor. Either way, nothing happens when I press the button. Is this code wrong? Do I need to add the external activity to my manifest (how?)? Is there a better way to get the external activity's class name than hard coding it like this? Are there any online examples that do this sort of thing? All of the examples i've seen merely launch configuration apps that are in the same package as the widget. 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: Launching an external activity from a widget
The other developer is sitting right next to me. Its the same company. He just implemented an intent-filter in his manifest to listen for an action called com.poof.intent.action.MovieApp I changed my code to Intent intent = new Intent( com.poof.intent.action.MovieApp ); intent.putExtra(FILENAME, MOVIES[state.currentMovie].filename); PendingIntent pendingIntent = PendingIntent.getActivity( context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT ); remoteView.setOnClickPendingIntent( R.id.btnDoIt, pendingIntent ); And updated his apk on my emulator. The button still does nothing. Any ideas? Examples? Thanks On Dec 22, 5:29 pm, Mark Murphy mmur...@commonsware.com wrote: ClarkBattle wrote: What code do I need to start up an external activity from a widget? That would be a fine question to ask the developer of the external activity. If the developer of the external activity wishes to support third-party apps like yours linking to it, (s)he can provide you with a suitable Intent to use. If the developer of the external activity does not wish to support third-party apps like yours, you should abide by the developer's wishes. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 2.8 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] How do I create a jar containing the .class files in bin?
I am making an API for my own use. It is an Android project in eclipse. An Android activity project in the same workspace uses it to do stuff. Or at least, thats the idea. The problem is that when i try to export the API as a jar that can be used by the activity the JAR wizard only shows me source files. It will not allow me to add .class files to the jar! It wont even show them. In the package explorer the bin directory is not there. However, it is there if you look at the file system. The clas files are built and in bin like I would expect. How do I create a jar containing the .class files in my API that can be used by another project? (Oddly, i had this working at one point but now it wont... even after recreating the project from scratch!) 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] CalendarService - ExceptionInInitializerError
I am trying to use the CalendarService in an android app to add events to my google calendar. I get a ExceptionInInitializerError when instantiating the class. CalendarService myService = new CalendarService( MyCalendar ); Is this not supported in android? If not then how do you do it? I also tried it by writing an xml request directly to http://www.google.com/calendar/feeds/... That returned an http success but no event showed up on my calendar. And yes, I have the INTERNET permission set. Any ideas? -- 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: Need an invitation to google Wave?
I'd love one! Thanks On Oct 31, 10:20 pm, Auguste Lunang legraphi...@gmail.com wrote: Hi, i have some google wave. invits to share. tell me if u want .. thx -- 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] AVD with a custom resolution
I created a new AVD in Eclipse for Eclair with a custom skin resolution or 1024x600 (called BigEclair). When I run apps on it the AVD crashes. [2009-11-03 11:54:47 - Timer]Android Launch! [2009-11-03 11:54:47 - Timer]adb is running normally. [2009-11-03 11:54:47 - Timer]Performing com.icd.timer.TimerActivity activity launch [2009-11-03 11:54:47 - Timer]Automatic Target Mode: Preferred AVD 'BigEclair' is available on emulator 'emulator-5554' [2009-11-03 11:54:47 - Timer]Uploading Timer.apk onto device 'emulator-5554' [2009-11-03 11:54:47 - Timer]Failed to upload Timer.apk on device 'emulator-5554' [2009-11-03 11:54:47 - Timer]java.io.IOException: Unable to open sync connection! [2009-11-03 11:54:47 - Timer]Launch canceled! The app runs fine in the built-in resolutions. I there something else that I need to do to make an emulator with a custom resolution? 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: Eclipse Layout Editor Not Showing
This happened to me too. Thanks! On Oct 29, 6:40 pm, Open ldonel...@gmail.com wrote: Figured it out myself. I had to specify the Android Layout Editor as the default for Android XML files under Preferences - General- Editors-File Associations. On Oct 29, 7:33 pm, Open ldonel...@gmail.com wrote: Relative noob working with Eclipse and Android. I just switched from Windows XP to Mac (Snow Leopard) and I'm having a little trouble getting Eclipse up and running the way I like it. I installed the Android Mac SDK, but my layout editor isn't showing me a preview of the activity layout, it's just showing me the XML tree, even when I'm on thedesigntab. Is there something I need to do to enable the layout editor in eclipse? Here's a screen grab:http://bit.ly/3PRzYA 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] Example Needed: a view containing a reference to its activity
I have a custom view that needs a reference to the activity that created it. Dianne Hackborn said in another thread: Give your view a reference to the activity (or a Java interface it implements) and call back through that. Much much MUCH more efficient than sending a broadcast. See all of the standard view and view subclass callbacks for examples. Sadly, I dont understand her reply and cant find any decent examples that show how to do this. Can anyone point me to an example or post one here? 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: Example Needed: a view containing a reference to its activity
But my activity never explicitly calls the view's constructor. The activity simply calls: setContentView( R.layout.main ); in its onCreate() method, and the custom view is specified in the main.xml. I think the constructor is called when the device is booted. Is there another way to set the content view explicity? On Oct 28, 1:48 pm, Mark Murphy mmur...@commonsware.com wrote: Would you have to use instanceof to find out if the context was the activity? At least once in development, to confirm that your View's Context is an Activity. If you're concerned about the Context's underlying type changing -- and it's not an unreasonable concern -- then you're better served holding your own reference to the Activity. That's fairly cheap, and if you require an Activity in the constructor, you eliminate all doubt. -- Mark Murphy (a Commons Guy)http://commonsware.com Android App Developer Books:http://commonsware.com/books.html --~--~-~--~~~---~--~~ 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: Example Needed: a view containing a reference to its activity
Very tricky. I like it! Thanks. On Oct 28, 1:12 pm, RichardC richard.crit...@googlemail.com wrote: In your activity onCreate method 1. find your custom view by id. 2. call a method on your custom view and pass it this (of your activity class) and save it in the custom view. In the custom view used the saved reference to your activity class to call back into your activity class when you need to. -- RichardC On Oct 28, 7:40 pm, ClarkBattle clarkbat...@gmail.com wrote: I have a custom view that needs a reference to the activity that created it. Dianne Hackborn said in another thread: Give your view a reference to the activity (or a Java interface it implements) and call back through that. Much much MUCH more efficient than sending a broadcast. See all of the standard view and view subclass callbacks for examples. Sadly, I dont understand her reply and cant find any decent examples that show how to do this. Can anyone point me to an example or post one here? 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: Architecting a count down timer
Thanks a lot! Your suggestions greatly simplified my code. I changed it so that the TimerView binds to the TimerService and communicates to it directly through its ServiceConnection (just like in the sample code). There is so much to the API I didnt know about that sample or about the CountDownTimer! Thanks again. On Oct 22, 6:44 pm, Mark Murphy mmur...@commonsware.com wrote: ClarkBattle wrote: TimerActivity.onCreate() inflates the TimerView (allowing the user to set the time and hit the start button) and starts the TimerService. Creating a custom View is certainly possible but probably way overkill for this sort of app. When the start button is pressed the TimerView broadcasts a START intent containing the number of seconds. The TimerService contains a BroadcastReceiver listening for the START intent. Why not just call a method on the service object? You can get the service object either by creating your own public static singleton or by using the local binding pattern shown in the ApiDemos of your SDK. When the TimerService receives START it begins broadcasting a TICK intent (containing the number of seconds remaining) every second until zero is reached. Why not just register a listener object with the service, that the service calls periodically? Broadcast Intents are broadcast to the device, not the app, and so are much more expensive in terms of CPU time than merely calling a method. They are also public, in the sense that any app can receive those broadcasts. public class TimerService extends Service { private int _seconds = 0; private Handler _timerHandler; �...@override public void onCreate() { _timerHandler = new Handler( ); } ... public class StartListener extends BroadcastReceiver { �...@override public void onReceive(Context context, Intent intent) { _seconds = intent.getIntExtra( seconds, 0 ); _timerHandler.postAtTime( runTimer, SystemClock.uptimeMillis() + 1000 ); } I have never used a Handler in a Service, so I don't know how that fares. As an alternative, you might use android.os.CountDownTimer, which seems tailor-made for your scenario. receiver android:name=TimerService$StartListener intent-filter action android:name=com.poof.timer.action.START/ /intent-filter /receiver For temporary broadcast receivers, use registerReceiver() in Java code, not a manifest-registered receiver like you have here. Look good so far? Well, it isnt. The problem is that it wont build because, according to Eclipse, com.icd.timer.TimerService $StartListener is enclosed, but not static. Its the same with TickListener. I could simply make the StartReceiver and TickReceiver classes static but that wont work because both of them need to set the state of their containing objects. How do I get around this? Try getting rid of the public keyword and make them simply package-private or private inner classes, after switching to using registerReceiver(). If you switch to the listener pattern, the receivers all become moot, anyway. (Its my first android app). Welcome to Android! -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy Android Training in Germany, 18-22 January 2010:http://bignerdranch.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 -~--~~~~--~~--~--~---
[android-developers] Architecting a count down timer
I am writing a timer application that counts backward from a time and notifies when the timer reaches zero. It is intended to allow the user to start a timer that continues to tick and will notify them when complete even after the activity is backgrounded. Also, it will show the correct in-progress countdown after the activity is re- foregrounded. TimerActivity.onCreate() inflates the TimerView (allowing the user to set the time and hit the start button) and starts the TimerService. When the start button is pressed the TimerView broadcasts a START intent containing the number of seconds. The TimerService contains a BroadcastReceiver listening for the START intent. When the TimerService receives START it begins broadcasting a TICK intent (containing the number of seconds remaining) every second until zero is reached. The TimerService looks like this. The BroadastReceiver is inside of the TimerService because it must set the TimerService's members. public class TimerService extends Service { private int _seconds = 0; private Handler _timerHandler; @Override public void onCreate() { _timerHandler = new Handler( ); } ... public class StartListener extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { _seconds = intent.getIntExtra( seconds, 0 ); _timerHandler.postAtTime( runTimer, SystemClock.uptimeMillis() + 1000 ); } private Runnable runTimer = new Runnable() { public void run() { // Decrement the counter == if( _seconds 0 ) _seconds--; // Broadcast the tick = Intent intent = new Intent(TICK_ACTION); intent.putExtra( seconds, _seconds ); sendBroadcast( intent ); // Schedule another tick? == if( _seconds 0 ) scheduleTick( this ); } }; } } I would like the TimerView to be able to receive the TICK broadcasts from the TimerService and update itself accordingly. So, something like this... public class TimerView extends FrameLayout { public TimerView(Context context, AttributeSet attrs, int defStyle) { super( context, attrs, defStyle ); LayoutInflater.from( context ).inflate( R.layout.timerview, this, true ); ... mStartButton = (ToggleButton)findViewById( R.id.Start ); mStartButton.setOnClickListener( new OnClickListener() public void onClick(View view) { requestFocus(); Intent intent = new Intent(START_ACTION); intent.putExtra( seconds, getTimeInSeconds() ); Context context = this.getContext(); context.sendBroadcast( intent ); } } ); } public class TickListener extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { int seconds = intent.getIntExtra( seconds, 0 ); setTimeInSeconds( seconds ); // Sets the view to the number of seconds remaining } } } The application tag in the manifest contians this to tie it all together manifest xmlns:android=http://schemas.android.com/apk/res/android; package=com.poof.timer android:versionCode=1 android:versionName=1.0 application android:icon=@drawable/icon android:label=@string/ app_name activity android:name=.TimerActivity android:label=@string/ app_name intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity receiver android:name=TimerActivity$TickListener intent-filter action android:name=com.poof.timer.action.TICK/ /intent-filter /receiver service android:name=.TimerService android:enabled=true /service receiver android:name=TimerService$StartListener intent-filter action android:name=com.poof.timer.action.START/ /intent-filter /receiver /application /manifest Look good so far? Well, it isnt. The problem is that it