[android-developers] Re: Changing view pager view set causes app to crash.
Added this to the view pager adapter. Good to go now. public int getItemPosition(Object object) { return POSITION_NONE; } On Mar 12, 2:00 pm, tatebn wrote: > I've stopped the crashing by making sure notifyDataSetChanged is > called in a handler on the main thread. But the current web view > doesn't go away. Other pages show up as their supposed to, but the > current one is never replaced. > > On Mar 9, 5:07 pm, tatebn wrote: > > > > > > > > > I'm using a ViewPager with the android support library to load static > > html pages into webviews > > and flip through them similar to a magazine app. > > > I can load the initial page fine, which is using loadContentId(). > > When the user clicks on a link I'm calling the same loadContentId() > > method. > > When I call this, 1 of 2 things happens. > > > Either nothing happens at all. The method runs and my log statements > > print, but the views > > do not redraw/change. Or, the app crashes with the "Only the original > > thread that created a view hierarchy > > can touch its views." error. > > > I can not seem to find a way to do this without the app crashing. How > > do I reset the adapter on this ViewPager and > > show new views? I've tried invalidating the view pager. I've tried > > invalidating the view pager. I've tried using notifyDataSetChanged() > > in various places. I've tried using a handler to remove the webView > > from the view pager. > > > Here is the pertinent code. > > > /** > > * Loads the internalContentPager with the swipe navigation set > > for the given content id. > > * @param contentId > > */ > > public void loadContentId(String contentId){ > > //this.internalContentAdapter.loadContentWithId(contentId); > > this.currentContentId = contentId; > > > Log.i(TAG, "in load content id " + contentId); > > > //this.internalContentPager.removeAllViews(); > > > if(this.internalContentAdapter == null){ > > InternalContentAdapter adapter = new > > InternalContentAdapter(); > > adapter.loadContentWithId(contentId); > > this.internalContentAdapter = adapter; > > > this.internalContentPager.setAdapter(this.internalContentAdapter); > > } > > else{ > > this.internalContentAdapter.loadContentWithId(contentId); > > // > > this.internalContentAdapter.startUpdate(this.internalContentPager); > > //this.internalContentAdapter.notifyDataSetChanged(); > > } > > > this.navigationStack.push(contentId); > > > } > > > /** > > * Pager Adapter to handle internal web view pages. This drives > > the swipe navigation for the internal content. > > * > > * @author btate > > * > > */ > > private class InternalContentAdapter extends PagerAdapter{ > > > /** The content objects represented by this pager. */ > > private List contents; > > > /** The starting position. */ > > private int startPosition = 0; > > > /** The starting content id. */ > > private String startContentId = null; > > > /** Flag for whether or not to set the starting position. */ > > private boolean setPrimary = true; > > > @Override > > public int getCount() { > > // Send back the contents size > > return this.contents.size(); > > } > > > /** > > * Create the page for the given position. The adapter is > > responsible > > * for adding the view to the container given here, although it > > only > > * must ensure this is done by the time it returns from > > * {@link #finishUpdate()}. > > * > > * @param container The containing View in which the page will > > be > > shown. > > * @param position The page position to be instantiated. > > * @return Returns an Object representing the new page. This > > does not > > * need to be a View, but can be some other container of the > > page. > > */ > > @Override > > public Object instantiateItem(Vie
[android-developers] Re: Changing view pager view set causes app to crash.
I've stopped the crashing by making sure notifyDataSetChanged is called in a handler on the main thread. But the current web view doesn't go away. Other pages show up as their supposed to, but the current one is never replaced. On Mar 9, 5:07 pm, tatebn wrote: > I'm using a ViewPager with the android support library to load static > html pages into webviews > and flip through them similar to a magazine app. > > I can load the initial page fine, which is using loadContentId(). > When the user clicks on a link I'm calling the same loadContentId() > method. > When I call this, 1 of 2 things happens. > > Either nothing happens at all. The method runs and my log statements > print, but the views > do not redraw/change. Or, the app crashes with the "Only the original > thread that created a view hierarchy > can touch its views." error. > > I can not seem to find a way to do this without the app crashing. How > do I reset the adapter on this ViewPager and > show new views? I've tried invalidating the view pager. I've tried > invalidating the view pager. I've tried using notifyDataSetChanged() > in various places. I've tried using a handler to remove the webView > from the view pager. > > Here is the pertinent code. > > /** > * Loads the internalContentPager with the swipe navigation set > for the given content id. > * @param contentId > */ > public void loadContentId(String contentId){ > //this.internalContentAdapter.loadContentWithId(contentId); > this.currentContentId = contentId; > > Log.i(TAG, "in load content id " + contentId); > > //this.internalContentPager.removeAllViews(); > > if(this.internalContentAdapter == null){ > InternalContentAdapter adapter = new InternalContentAdapter(); > adapter.loadContentWithId(contentId); > this.internalContentAdapter = adapter; > > this.internalContentPager.setAdapter(this.internalContentAdapter); > } > else{ > this.internalContentAdapter.loadContentWithId(contentId); > // > this.internalContentAdapter.startUpdate(this.internalContentPager); > //this.internalContentAdapter.notifyDataSetChanged(); > } > > this.navigationStack.push(contentId); > > } > > /** > * Pager Adapter to handle internal web view pages. This drives > the swipe navigation for the internal content. > * > * @author btate > * > */ > private class InternalContentAdapter extends PagerAdapter{ > > /** The content objects represented by this pager. */ > private List contents; > > /** The starting position. */ > private int startPosition = 0; > > /** The starting content id. */ > private String startContentId = null; > > /** Flag for whether or not to set the starting position. */ > private boolean setPrimary = true; > > @Override > public int getCount() { > // Send back the contents size > return this.contents.size(); > } > > /** > * Create the page for the given position. The adapter is > responsible > * for adding the view to the container given here, although it > only > * must ensure this is done by the time it returns from > * {@link #finishUpdate()}. > * > * @param container The containing View in which the page will be > shown. > * @param position The page position to be instantiated. > * @return Returns an Object representing the new page. This > does not > * need to be a View, but can be some other container of the > page. > */ > @Override > public Object instantiateItem(ViewGroup container, int > position) { > > // Load up the page > InternalWebView page = new InternalWebView(ctx, repo); > > page.loadInternalPage(this.contents.get(position).getContentId()); > page.setInternalWebViewListener(getListener()); > > //this.parentActivity.registerForContextMenu(page); > > // Need to add this without the position > container.addView(page); > > // I would like this to work, but it doesn't > if(this.startPosition == position){ >
[android-developers] Changing view pager view set causes app to crash.
I'm using a ViewPager with the android support library to load static html pages into webviews and flip through them similar to a magazine app. I can load the initial page fine, which is using loadContentId(). When the user clicks on a link I'm calling the same loadContentId() method. When I call this, 1 of 2 things happens. Either nothing happens at all. The method runs and my log statements print, but the views do not redraw/change. Or, the app crashes with the "Only the original thread that created a view hierarchy can touch its views." error. I can not seem to find a way to do this without the app crashing. How do I reset the adapter on this ViewPager and show new views? I've tried invalidating the view pager. I've tried invalidating the view pager. I've tried using notifyDataSetChanged() in various places. I've tried using a handler to remove the webView from the view pager. Here is the pertinent code. /** * Loads the internalContentPager with the swipe navigation set for the given content id. * @param contentId */ public void loadContentId(String contentId){ //this.internalContentAdapter.loadContentWithId(contentId); this.currentContentId = contentId; Log.i(TAG, "in load content id " + contentId); //this.internalContentPager.removeAllViews(); if(this.internalContentAdapter == null){ InternalContentAdapter adapter = new InternalContentAdapter(); adapter.loadContentWithId(contentId); this.internalContentAdapter = adapter; this.internalContentPager.setAdapter(this.internalContentAdapter); } else{ this.internalContentAdapter.loadContentWithId(contentId); // this.internalContentAdapter.startUpdate(this.internalContentPager); //this.internalContentAdapter.notifyDataSetChanged(); } this.navigationStack.push(contentId); } /** * Pager Adapter to handle internal web view pages. This drives the swipe navigation for the internal content. * * @author btate * */ private class InternalContentAdapter extends PagerAdapter{ /** The content objects represented by this pager. */ private List contents; /** The starting position. */ private int startPosition = 0; /** The starting content id. */ private String startContentId = null; /** Flag for whether or not to set the starting position. */ private boolean setPrimary = true; @Override public int getCount() { // Send back the contents size return this.contents.size(); } /** * Create the page for the given position. The adapter is responsible * for adding the view to the container given here, although it only * must ensure this is done by the time it returns from * {@link #finishUpdate()}. * * @param container The containing View in which the page will be shown. * @param position The page position to be instantiated. * @return Returns an Object representing the new page. This does not * need to be a View, but can be some other container of the page. */ @Override public Object instantiateItem(ViewGroup container, int position) { // Load up the page InternalWebView page = new InternalWebView(ctx, repo); page.loadInternalPage(this.contents.get(position).getContentId()); page.setInternalWebViewListener(getListener()); //this.parentActivity.registerForContextMenu(page); // Need to add this without the position container.addView(page); // I would like this to work, but it doesn't if(this.startPosition == position){ Log.i(TAG, "setting primary item with position " + position); this.setPrimaryItem(internalContentPager, position, page); } return page; } /** * Remove a page for the given position. The adapter is responsible * for removing the view from its container, although it only must ensure * this is done by the time it returns from {@link #finishUpdate()}. * * @param container The containing View from which the page will be removed. * @param position The page position to be removed. * @param object The same object that was returned by * {@link #instantiateItem(View, int)}. */ @Override public void destroyItem(View containe
[android-developers] Re: Using ViewPager with dynamic view sets
Sorry, I'm pretty new to android myself. I don't think I can be much help to you on that. On Feb 10, 1:09 pm, Adi wrote: > @tatebn - Hi, I desperately needed this post! But as yours seems to be > an internal web view, mine is an external file on the SD-Card. I'm > trying to read it using this, > > BufferedReader in = new BufferedReader(new FileReader("/sdcard/ > TextFiles/post.txt")); > > And I cannot further decide how to split the content into different > page views so that they can be added to the addView method. Let me > know if you have a solution or guide me elsewhere. > > P.S. I'm new to Android. > > On Feb 8, 9:05 pm, tatebn wrote: > > > > > > > > > I ended up getting this solved as follows. > > > I basically just created a new adapter every time the data set needed > > to change and replaced the adapter for the view pager. > > > InternalContentAdapter adapter = new InternalContentAdapter(); > > adapter.loadContents(someContentList); > > this.internalContentPager.setAdapter(adapter); > > > This is my pager adapter. I'm using internal web views as my views. > > This probably isn't the best explanation (or implementation) but it > > works for me. Let me know if you have any questions. > > > /** > > * Pager Adapter to handle internal web view pages. This drives > > the swipe navigation for the internal content. > > * > > * @author btate > > * > > */ > > private class InternalContentAdapter extends PagerAdapter{ > > > /** The content objects represented by this pager. */ > > private List contents; > > > /** The starting position. */ > > private int startPosition = 0; > > > /** The starting content id. */ > > private String startContentId = null; > > > /** Flag for whether or not to set the starting position. */ > > private boolean setPrimary = true; > > > @Override > > public int getCount() { > > // Send back the contents size > > return this.contents.size(); > > } > > > /** > > * Create the page for the given position. The adapter is > > responsible > > * for adding the view to the container given here, although it > > only > > * must ensure this is done by the time it returns from > > * {@link #finishUpdate()}. > > * > > * @param container The containing View in which the page will > > be > > shown. > > * @param position The page position to be instantiated. > > * @return Returns an Object representing the new page. This > > does not > > * need to be a View, but can be some other container of the > > page. > > */ > > @Override > > public Object instantiateItem(ViewGroup container, int > > position) { > > > // Load up the page > > InternalWebView page = new InternalWebView(ctx, repo); > > > page.loadInternalPage(this.contents.get(position).getContentId()); > > page.setInternalWebViewListener(getListener()); > > > //this.parentActivity.registerForContextMenu(page); > > > // Need to add this without the position > > container.addView(page); > > > return page; > > } > > > /** > > * Remove a page for the given position. The adapter is > > responsible > > * for removing the view from its container, although it only > > must ensure > > * this is done by the time it returns from {@link > > #finishUpdate()}. > > * > > * @param container The containing View from which the page will > > be removed. > > * @param position The page position to be removed. > > * @param object The same object that was returned by > > * {@link #instantiateItem(View, int)}. > > */ > > @Override > > public void destroyItem(View container, int position, > > Object view) { > > ((ViewPager) > > container).removeView((InternalWebView) view); > >
[android-developers] Re: Passing ArrayList in BroadcastReceiver in Android
As it turns out, I'm emptying that array after I send it off. For some reason the broadcast receiver is either using a reference to it, so it gets the cleared one, or is sending after it's cleared. Either way, not clearing the array after allows it to show up correctly. On Mar 2, 2:13 pm, tatebn wrote: > What's confusing to me is that it actually gets an ArrayList. > It's just been emptied out somehow. > > On Mar 2, 1:25 pm, tatebn wrote: > > > > > > > > > Accidentally left that prefix in the code there. That's not the issue > > in the actual app. > > > On Mar 2, 1:17 pm, tatebn wrote: > > > > It's the intent in the broadcast receiver's onReceive message > > > > /** Handler for content ids updated. */ > > > private BroadcastReceiver mContentIdsUpdated = new BroadcastReceiver() > > > { > > > @Override > > > public void onReceive(Context context, Intent intent) { > > > Log.i(TAG, "received " + > > > intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey).size() > > > + " items in receiver"); // 0 > > > Log.i(TAG, "content ids updated in activity " + > > > intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey)); // > > > empty array > > > } > > > > }; > > > > // In oncreate > > > > LocalBroadcastManager.getInstance(this).registerReceiver(mContentIdsUpdated > > > , > > > new > > > IntentFilter(Common.ContentIdsUpdatedNotification)); > > > > On Mar 2, 12:15 pm, Mark Murphy wrote: > > > > > Are you sure you are looking at the right Intent? > > > > > On Fri, Mar 2, 2012 at 11:25 AM, tatebn wrote: > > > > > > I'm using LocalBroadcastManager to send data between classes. I'm > > > > > trying to send an ArrayList of String objects, 1 dimensional, in one > > > > > of them. The array has all my strings when I send it, but on the > > > > > receiving end it is empty. Has anyone seen this before? Here's my > > > > > code. > > > > > > Send Message (I can print the array here and it has 5 items): > > > > > > Intent updatedIdsIntent = new > > > > > Intent(Common.ContentIdsUpdatedNotification); > > > > > > updatedIdsIntent.putStringArrayListExtra(Common.UpdatedContentIdsKey, > > > > > this.updatedContentIds); > > > > > > LocalBroadcastManager.getInstance(ctx).sendBroadcast(updatedIdsIntent); > > > > > > Retrieve Message (always empty): > > > > > > Log.i(TAG, "content ids updated in activity " + > > > > > intent.getStringArrayListExtra(Common.UpdatedContentIdsKey)); > > > > > > Why are the items gone from the array in the broadcast receiver? > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > > > 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 > > > > > -- > > > > Mark Murphy (a Commons > > > > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > > > > Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google 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: Passing ArrayList in BroadcastReceiver in Android
What's confusing to me is that it actually gets an ArrayList. It's just been emptied out somehow. On Mar 2, 1:25 pm, tatebn wrote: > Accidentally left that prefix in the code there. That's not the issue > in the actual app. > > On Mar 2, 1:17 pm, tatebn wrote: > > > > > > > > > It's the intent in the broadcast receiver's onReceive message > > > /** Handler for content ids updated. */ > > private BroadcastReceiver mContentIdsUpdated = new BroadcastReceiver() > > { > > @Override > > public void onReceive(Context context, Intent intent) { > > Log.i(TAG, "received " + > > intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey).size() > > + " items in receiver"); // 0 > > Log.i(TAG, "content ids updated in activity " + > > intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey)); // > > empty array > > } > > > }; > > > // In oncreate > > > LocalBroadcastManager.getInstance(this).registerReceiver(mContentIdsUpdated > > , > > new > > IntentFilter(Common.ContentIdsUpdatedNotification)); > > > On Mar 2, 12:15 pm, Mark Murphy wrote: > > > > Are you sure you are looking at the right Intent? > > > > On Fri, Mar 2, 2012 at 11:25 AM, tatebn wrote: > > > > > I'm using LocalBroadcastManager to send data between classes. I'm > > > > trying to send an ArrayList of String objects, 1 dimensional, in one > > > > of them. The array has all my strings when I send it, but on the > > > > receiving end it is empty. Has anyone seen this before? Here's my > > > > code. > > > > > Send Message (I can print the array here and it has 5 items): > > > > > Intent updatedIdsIntent = new > > > > Intent(Common.ContentIdsUpdatedNotification); > > > > > updatedIdsIntent.putStringArrayListExtra(Common.UpdatedContentIdsKey, > > > > this.updatedContentIds); > > > > > LocalBroadcastManager.getInstance(ctx).sendBroadcast(updatedIdsIntent); > > > > > Retrieve Message (always empty): > > > > > Log.i(TAG, "content ids updated in activity " + > > > > intent.getStringArrayListExtra(Common.UpdatedContentIdsKey)); > > > > > Why are the items gone from the array in the broadcast receiver? > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > 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 > > > > -- > > > Mark Murphy (a Commons > > > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > > > Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google 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: Passing ArrayList in BroadcastReceiver in Android
Accidentally left that prefix in the code there. That's not the issue in the actual app. On Mar 2, 1:17 pm, tatebn wrote: > It's the intent in the broadcast receiver's onReceive message > > /** Handler for content ids updated. */ > private BroadcastReceiver mContentIdsUpdated = new BroadcastReceiver() > { > @Override > public void onReceive(Context context, Intent intent) { > Log.i(TAG, "received " + > intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey).size() > + " items in receiver"); // 0 > Log.i(TAG, "content ids updated in activity " + > intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey)); // > empty array > } > > }; > > // In oncreate > > LocalBroadcastManager.getInstance(this).registerReceiver(mContentIdsUpdated , > new > IntentFilter(Common.ContentIdsUpdatedNotification)); > > On Mar 2, 12:15 pm, Mark Murphy wrote: > > > > > > > > > Are you sure you are looking at the right Intent? > > > On Fri, Mar 2, 2012 at 11:25 AM, tatebn wrote: > > > > I'm using LocalBroadcastManager to send data between classes. I'm > > > trying to send an ArrayList of String objects, 1 dimensional, in one > > > of them. The array has all my strings when I send it, but on the > > > receiving end it is empty. Has anyone seen this before? Here's my > > > code. > > > > Send Message (I can print the array here and it has 5 items): > > > > Intent updatedIdsIntent = new > > > Intent(Common.ContentIdsUpdatedNotification); > > > > updatedIdsIntent.putStringArrayListExtra(Common.UpdatedContentIdsKey, > > > this.updatedContentIds); > > > > LocalBroadcastManager.getInstance(ctx).sendBroadcast(updatedIdsIntent); > > > > Retrieve Message (always empty): > > > > Log.i(TAG, "content ids updated in activity " + > > > intent.getStringArrayListExtra(Common.UpdatedContentIdsKey)); > > > > Why are the items gone from the array in the broadcast receiver? > > > > -- > > > You received this message because you are subscribed to the Google > > > 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 > > > -- > > Mark Murphy (a Commons > > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > > Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google 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: Passing ArrayList in BroadcastReceiver in Android
It's the intent in the broadcast receiver's onReceive message /** Handler for content ids updated. */ private BroadcastReceiver mContentIdsUpdated = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.i(TAG, "received " + intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey).size() + " items in receiver"); // 0 Log.i(TAG, "content ids updated in activity " + intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey)); // empty array } }; // In oncreate LocalBroadcastManager.getInstance(this).registerReceiver(mContentIdsUpdated, new IntentFilter(Common.ContentIdsUpdatedNotification)); On Mar 2, 12:15 pm, Mark Murphy wrote: > Are you sure you are looking at the right Intent? > > > > > > > > > > On Fri, Mar 2, 2012 at 11:25 AM, tatebn wrote: > > > I'm using LocalBroadcastManager to send data between classes. I'm > > trying to send an ArrayList of String objects, 1 dimensional, in one > > of them. The array has all my strings when I send it, but on the > > receiving end it is empty. Has anyone seen this before? Here's my > > code. > > > Send Message (I can print the array here and it has 5 items): > > > Intent updatedIdsIntent = new > > Intent(Common.ContentIdsUpdatedNotification); > > > updatedIdsIntent.putStringArrayListExtra(Common.UpdatedContentIdsKey, > > this.updatedContentIds); > > > LocalBroadcastManager.getInstance(ctx).sendBroadcast(updatedIdsIntent); > > > Retrieve Message (always empty): > > > Log.i(TAG, "content ids updated in activity " + > > intent.getStringArrayListExtra(Common.UpdatedContentIdsKey)); > > > Why are the items gone from the array in the broadcast receiver? > > > -- > > You received this message because you are subscribed to the Google > > 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 > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google 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] Passing ArrayList in BroadcastReceiver in Android
I'm using LocalBroadcastManager to send data between classes. I'm trying to send an ArrayList of String objects, 1 dimensional, in one of them. The array has all my strings when I send it, but on the receiving end it is empty. Has anyone seen this before? Here's my code. Send Message (I can print the array here and it has 5 items): Intent updatedIdsIntent = new Intent(Common.ContentIdsUpdatedNotification); updatedIdsIntent.putStringArrayListExtra(Common.UpdatedContentIdsKey, this.updatedContentIds); LocalBroadcastManager.getInstance(ctx).sendBroadcast(updatedIdsIntent); Retrieve Message (always empty): Log.i(TAG, "content ids updated in activity " + intent.getStringArrayListExtra(Common.UpdatedContentIdsKey)); Why are the items gone from the array in the broadcast receiver? -- You received this message because you are subscribed to the Google 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] Trouble Skinning Options Menu Item
I'm trying to skin the options menu on android. I have the background color changed with a custom theme, but I can't get the text color to change for some reason. My Theme- @color/ optionsMenuBackgroundColor
- @color/ optionsMenuBackgroundColor
- @style/OptionsMenuFont item> My Style for the options menu font
- @drawable/menu_item_font
My drawable for the button color selector menu_item_font.xml http://schemas.android.com/apk/res/android"; > That color is just a hex color #c4c4c4. I have also tried just putting a straight hex color value of #ff in there, which also doesn't work. What am I missing 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] Re: Using ViewPager with dynamic view sets
public void setContents(List contents, int startPosition){ // Tells it to set the primary page this.setPrimary = true; // Set the contents this.contents = contents; // Figure out the start position for the finished update function if(this.startContentId != null){ for(Content tmp : this.contents){ if(this.startContentId != null && this.startContent.equals(tmp.getContentId())) this.startPosition = this.contents.indexOf(tmp); } } this.notifyDataSetChanged(); } } On Feb 7, 12:13 am, HeneryH wrote: > tatebn, did you ever solve this problem? I have been going crazy trying to > dynamically add views to a viewpager based on database items. > > If I find one more sample with three statically defined views each adding a > textview with the index I will go crazy! -- You received this message because you are subscribed to the Google 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] Use javascript to get web view selection.
I need to run some javascript in an android web view. I understand this works fine by loading a javascript: url. It seems that when I do that though the selected text in the web view is cleared. The javascript I'm running gets the range of the selected text, so I need it to remain selected. I have my web view set up to allow javascript. How can I run the javascript without losing the selection? -- You received this message because you are subscribed to the Google 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] Creating a context menu similar to gmail app.
I need to create a context menu similar to the menu that pops up in the gmail app. I need this menu to show up when I select text in a web view. I found this tutorial on quick action bars, http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/ and it looks straight forward enough to build them. But I don't know how to tie in to the text selection of a web view. Basically when a user selects text in a web view I need to build a quick action menu on the fly based on the text they selected. Is there an event for that I can listen for? -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
Ok. I got it. And I feel a little bit stupid. I have multiple url schemes I'm using within the app to do things like send analytics, etc. One of those schemes is "finishedloading://", which tells me that the page is ready for me to inject javascript. In my shouldOverrideMethod, if (uri.getScheme().equalsIgnoreCase( "finishedLoading" ) ){ // Call an inject javascript method this.injectJavascript( view ); return true; } The inject javascript method is where I'm calling that getJSValue stuff. So since the shouldOverride hadn't returned yet, I was getting conflicts. If I inject javascript after returning true from shouldOverride, I'm good to go. Thanks so much for all your help. It hit me like a ton of bricks when reading through the WebViewCore thread stack trace. On Jan 18, 2:35 pm, Streets Of Boston wrote: > That looks good. > > Now enable the latch again (call await) and run your app. When your app > hangs, debug it: Press 'pause' on your app that will suspend all your > threads. Then open/expand the threads so you see each thread's stack-trace. > One should be at the 'await' call. Look at other threads (especially the > ones related to WebView and WebViewCore) and see where they are waiting. It > may give you some indication of what is going on. -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
Nevermind. Looks like loadUrl() is being loaded in the main thread. And setValue() is being called in the WebViewCoreThread. On Jan 18, 2:12 pm, tatebn wrote: > The javascript is actually generated in the getJSValue method. For > this test I'm using "2 + 2" as my expression. So I don't think the > actual js is the issue. > > How do I tell which thread which method call is happening in? > > On Jan 18, 1:20 pm, Streets Of Boston wrote: > > > > > > > > > Very odd. > > > The call to loadUrl should just post a message with the Url on the > > WebViewCore which, in its turn, will run this url (javascript) on its own > > thread-pool. > > > I would examine your JavaScript as well. Maybe it does something that needs > > to be run on the same thread on which you call loadUrl (i.e. the main UI > > thread). > > > Remove the latches/semaphores temporarily and see on which thread your > > loadUrl is called an on which thread the setValue callback is called. If it > > is the same thread, that would explain the deadlock easily. If they are > > different threads, see if there is any other coordination/wait-states > > between these two threads that could cause the deadlock. -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
The javascript is actually generated in the getJSValue method. For this test I'm using "2 + 2" as my expression. So I don't think the actual js is the issue. How do I tell which thread which method call is happening in? On Jan 18, 1:20 pm, Streets Of Boston wrote: > Very odd. > > The call to loadUrl should just post a message with the Url on the > WebViewCore which, in its turn, will run this url (javascript) on its own > thread-pool. > > I would examine your JavaScript as well. Maybe it does something that needs > to be run on the same thread on which you call loadUrl (i.e. the main UI > thread). > > Remove the latches/semaphores temporarily and see on which thread your > loadUrl is called an on which thread the setValue callback is called. If it > is the same thread, that would explain the deadlock easily. If they are > different threads, see if there is any other coordination/wait-states > between these two threads that could cause the deadlock. -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
Thanks, but I have the javascript to java binding working. My issue is that I need to wait and return the value set via that binding from javascript. But it seems that the loadUrl() method in the web view isn't using it's own thread. So any waiting I'm doing stops the javascript from executing. On Jan 18, 12:49 pm, Daniel Drozdzewski wrote: > It should read that you can bind your Java code so it is accessible > from JavaScript. Obviously the biding is defined within your Java > code, and JavaScript assumes existence of said binding. > > Reading through the example should clarify... > > On 18 January 2012 17:41, Daniel Drozdzewski > > > > > > > > > > wrote: > > You can bind Java code from within your JavaScript by calling > > *WebView.addJavascriptInterface()*. In other words you could call one > > method within Java object of your choosing, when user selects A in UI > > or different method of different object, when user interacts with UI > > differently. > > > JavaDocs are poor, but fairly good example can be found here: > >http://mobile.tutsplus.com/tutorials/mobile-web-apps/build-a-contacts... > > (have a look at section 'Integrating HTML/JavaScript Based UI With > > Android Java Back-end') > > > HTH > > > Daniel > > > On 18 January 2012 17:21, Streets Of Boston wrote: > >> It's from a separate class (runJS does something like > >> mWebView.loadUrl(javaScriptUrl);) > > >> In my sample code, the run and runJS are usually executed on the main UI > >> thread (that's why there the await call has a (short) timeout). > >> The WebView's JavaScript execution's callback to Java (setValue in your > >> example) is done on a separate thread (managed by the WebView, i suppose). > > >> If you use my code, does the call to 'latch.await' time-out? > > >> If so, this means that the WebView never properly loaded the url (code) in > >> the loadUrl call. Look at your LogCat and see what may be the problem. > > >> Note that the WebView we use returns false for it's > >> WebViewClient's shouldOverrideUrlLoading method. > > >> -- > >> You received this message because you are subscribed to the Google > >> 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 > > > -- > > Daniel Drozdzewski > > -- > Daniel Drozdzewski -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
Nevermind that. Misread the log. The latch.await times out every time. But the javascript is not evaluated until after the timeout. On Jan 18, 12:21 pm, Streets Of Boston wrote: > It's from a separate class (runJS does something like > mWebView.loadUrl(javaScriptUrl);) > > In my sample code, the *run *and *runJS *are usually executed on the main > UI thread (that's why there the *await *call has a (short) timeout). > The WebView's JavaScript execution's callback to Java (setValue in your > example) is done on a separate thread (managed by the WebView, i suppose). > > If you use my code, does the call to 'latch.await' time-out? > > If so, this means that the WebView never properly loaded the url (code) in > the loadUrl call. Look at your LogCat and see what may be the problem. > > Note that the WebView we use returns *false *for it's > WebViewClient's shouldOverrideUrlLoading method. -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
My getJSValue() is run on the main thread as well. As far as the latch.await goes, If I run webView.loadUrl() in an asyncTask I get the full time out (10 seconds for testing). If I just run webView.loadUrl() in the current task, there is no time out. The latch.await call instantly comes back, but the return value doesn't get set until 180 milliseconds afterward. So I'm just instantly returning null. If I remove latch.await, the javascript executes and the setValue is called. Just after the return has already happened. I'm returning true in my shouldOverrideUrlLoading method for some schemes, but this doesn't seem to be getting called for "javascript:" urls. On Jan 18, 12:21 pm, Streets Of Boston wrote: > It's from a separate class (runJS does something like > mWebView.loadUrl(javaScriptUrl);) > > In my sample code, the *run *and *runJS *are usually executed on the main > UI thread (that's why there the *await *call has a (short) timeout). > The WebView's JavaScript execution's callback to Java (setValue in your > example) is done on a separate thread (managed by the WebView, i suppose). > > If you use my code, does the call to 'latch.await' time-out? > > If so, this means that the WebView never properly loaded the url (code) in > the loadUrl call. Look at your LogCat and see what may be the problem. > > Note that the WebView we use returns *false *for it's > WebViewClient's shouldOverrideUrlLoading method. -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
I've tried executing the javascript in an async task, which I thought would fix any threading issues. But I get the same issue. How do you have your threads specified when you run yours? Are you running this from a WebView subclass or from a separate class for you javascript interface? I've tried both. On Jan 18, 11:41 am, Streets Of Boston wrote: > ... we use it successfully all over the place. > For some reason, it seems that the stack-frame of your call to loadUrl in > your code needs to finish before the javascript in 'code' is actually > executed. The call to 'loadUrl' should cause the javascript to be executed > on a separate thread in the WebView. On what thread are you calling > 'getJSValue(...)'? If this is the same thread on which the javascript is > executed, then you get a dead-lock. -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
I need to put up a context menu in the app when the user selects text in the WebView. The options in that context menu depend on yes or no answers I pull from javascript. The content is local content that is set up to deliver these answers. if(webView.needsOption1()) // Add option1 to context menu. I find it strange that this is such a difficult task in Android. I feel like I'm almost there, I'm just missing something thread related that causing my web view to lock. On Jan 18, 11:35 am, Daniel Drozdzewski wrote: > Why does your JS has to be synchronous? > > Simply within JS make of your page a throbber and only swap it > back to its actual content as a last statement in the JS function that > you want to process. > > On 18 January 2012 16:24, tatebn wrote: > > > > > > > > > > > I'm getting the same issue using the CountDownLatch. The WebView > > can't load the url because of the lock. > > > On Jan 18, 11:01 am, Streets Of Boston > > wrote: > >> We use a countdown latch instead: > > >> String returnValue; > >> private CountDownLatch latch = null; > > >> public String run(String javaScript, int waitInMilliSecs) { > >> latch = new CountDownLatch(1); > >> runJS(javaScript); // this method just runs the given javascript in the > >> WebView. > >> try { > >> latch.await(waitInMilliSecs, TimeUnit.MILLISECONDS); > > >> } catch (InterruptedException e) { } return returnValue; > >> } > > >> ... > >> ... > > >> // method being called by the javascript in WebView > >> public void setValue(String value) { > >> try { > >> // do your stuff here with 'value': > >> returnValue = value;} > > >> finally { > >> try { latch.countDown(); } catch (Exception e) {} > > >> } > >> } > > > -- > > You received this message because you are subscribed to the Google > > 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 > > -- > Daniel Drozdzewski -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
I'm getting the same issue using the CountDownLatch. The WebView can't load the url because of the lock. On Jan 18, 11:01 am, Streets Of Boston wrote: > We use a countdown latch instead: > > String returnValue; > private CountDownLatch latch = null; > > public String run(String javaScript, int waitInMilliSecs) { > latch = new CountDownLatch(1); > runJS(javaScript); // this method just runs the given javascript in the > WebView. > try { > latch.await(waitInMilliSecs, TimeUnit.MILLISECONDS); > > } catch (InterruptedException e) { } return returnValue; > } > > ... > ... > > // method being called by the javascript in WebView > public void setValue(String value) { > try { > // do your stuff here with 'value': > returnValue = value;} > > finally { > try { latch.countDown(); } catch (Exception e) {} > > > > > > > > } > } -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
WebView doesn't evaluate the JavaScript synchronously. I need an immediate return not a call to a separate interface method. The only method I've found of anyone evaluating javascript synchronously is using this semaphore method, but I can't get the javascript to continue evaluating when the semaphore is locked. I've tried running the javascript evaluation code in an async task as well, still no lock. On Jan 18, 10:32 am, Daniel Drozdzewski wrote: > Why can't you just let webview evaluate the JavaScript? > > On 18 January 2012 15:18, tatebn wrote: > > > > > > > > > > > I need the semaphore to hold there so that the return doesn't happen > > until the value is sent back from javascript. How do I get the web > > view to continue evaluating the javascript in the background? > > > On Jan 18, 10:05 am, Daniel Drozdzewski > > wrote: > >> Your semaphore allows ZERO passes through, in which case you have to > >> release first. > > >> Either change the parameter to Semaphore constructor or release before > >> calling Semaphore.acquire() > > >> Daniel > > >> On 18 January 2012 15:00, tatebn wrote: > > >> > By the way, this code is located in a subclassed WebView. > > >> > On Jan 18, 9:53 am, tatebn wrote: > >> >> I'm trying to evaluate javascript with a semaphore lock. I need to > >> >> query some web content about which context menus to show and need it > >> >> to be synchronous. When I try to acquire the semaphore the thread > >> >> locks without the javascript being evaluated and my javascript > >> >> interface method being called. > > >> >> Here's my code. > > >> >> private Semaphore returnSemaphore = new Semaphore(0); > >> >> private String returnValue; > > >> >> public String getJSValue(String expression) > >> >> { > >> >> String code = > >> >> "javascript:_JSEval.setValue((function(){try{return " > >> >> + expression > >> >> + "+\"\";}catch(js_eval_err){return '';}})());"; > >> >> //String code = "javascript: alert('here');"; > >> >> Log.d(TAG, "eval: " + code); > > >> >> this.loadUrl(code); > > >> >> try { > >> >> Log.d(TAG, "eval: about to acquire semaphore, " > >> >> + > >> >> returnSemaphore.availablePermits()); > > >> >> returnSemaphore.acquire(); > > >> >> Log.d(TAG, "past semaphore acquire"); > > >> >> return returnValue; > >> >> } catch (InterruptedException e) { > >> >> Log.e(TAG, "eval: Interrupted", e); > >> >> } > >> >> return null; > > >> >> } > > >> >> @SuppressWarnings("unused") > >> >> private class JSEval > >> >> { > >> >> public void setValue(String value) > >> >> { > >> >> Log.i(TAG, "eval: in set value"); > >> >> //if (value != null) { > >> >> returnValue = value; > >> >> //} > >> >> returnSemaphore.release(); > >> >> } > >> >> } > > >> >> If I remove the semaphore acquire call, I get a result in setValue, so > >> >> I know the interface is working. > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > 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 > > >> -- > >> Daniel Drozdzewski > > > -- > > You received this message because you are subscribed to the Google > > 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 > > -- > Daniel Drozdzewski -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
I need the semaphore to hold there so that the return doesn't happen until the value is sent back from javascript. How do I get the web view to continue evaluating the javascript in the background? On Jan 18, 10:05 am, Daniel Drozdzewski wrote: > Your semaphore allows ZERO passes through, in which case you have to > release first. > > Either change the parameter to Semaphore constructor or release before > calling Semaphore.acquire() > > Daniel > > On 18 January 2012 15:00, tatebn wrote: > > > > > > > > > > > By the way, this code is located in a subclassed WebView. > > > On Jan 18, 9:53 am, tatebn wrote: > >> I'm trying to evaluate javascript with a semaphore lock. I need to > >> query some web content about which context menus to show and need it > >> to be synchronous. When I try to acquire the semaphore the thread > >> locks without the javascript being evaluated and my javascript > >> interface method being called. > > >> Here's my code. > > >> private Semaphore returnSemaphore = new Semaphore(0); > >> private String returnValue; > > >> public String getJSValue(String expression) > >> { > >> String code = > >> "javascript:_JSEval.setValue((function(){try{return " > >> + expression > >> + "+\"\";}catch(js_eval_err){return '';}})());"; > >> //String code = "javascript: alert('here');"; > >> Log.d(TAG, "eval: " + code); > > >> this.loadUrl(code); > > >> try { > >> Log.d(TAG, "eval: about to acquire semaphore, " + > >> returnSemaphore.availablePermits()); > > >> returnSemaphore.acquire(); > > >> Log.d(TAG, "past semaphore acquire"); > > >> return returnValue; > >> } catch (InterruptedException e) { > >> Log.e(TAG, "eval: Interrupted", e); > >> } > >> return null; > > >> } > > >> @SuppressWarnings("unused") > >> private class JSEval > >> { > >> public void setValue(String value) > >> { > >> Log.i(TAG, "eval: in set value"); > >> //if (value != null) { > >> returnValue = value; > >> //} > >> returnSemaphore.release(); > >> } > >> } > > >> If I remove the semaphore acquire call, I get a result in setValue, so > >> I know the interface is working. > > > -- > > You received this message because you are subscribed to the Google > > 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 > > -- > Daniel Drozdzewski -- You received this message because you are subscribed to the Google 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: Problem evaluating javascript with a semaphore lock
By the way, this code is located in a subclassed WebView. On Jan 18, 9:53 am, tatebn wrote: > I'm trying to evaluate javascript with a semaphore lock. I need to > query some web content about which context menus to show and need it > to be synchronous. When I try to acquire the semaphore the thread > locks without the javascript being evaluated and my javascript > interface method being called. > > Here's my code. > > private Semaphore returnSemaphore = new Semaphore(0); > private String returnValue; > > public String getJSValue(String expression) > { > String code = > "javascript:_JSEval.setValue((function(){try{return " > + expression > + "+\"\";}catch(js_eval_err){return '';}})());"; > //String code = "javascript: alert('here');"; > Log.d(TAG, "eval: " + code); > > this.loadUrl(code); > > try { > Log.d(TAG, "eval: about to acquire semaphore, " + > returnSemaphore.availablePermits()); > > returnSemaphore.acquire(); > > Log.d(TAG, "past semaphore acquire"); > > return returnValue; > } catch (InterruptedException e) { > Log.e(TAG, "eval: Interrupted", e); > } > return null; > > } > > @SuppressWarnings("unused") > private class JSEval > { > public void setValue(String value) > { > Log.i(TAG, "eval: in set value"); > //if (value != null) { > returnValue = value; > //} > returnSemaphore.release(); > } > } > > If I remove the semaphore acquire call, I get a result in setValue, so > I know the interface is working. -- You received this message because you are subscribed to the Google 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] Problem evaluating javascript with a semaphore lock
I'm trying to evaluate javascript with a semaphore lock. I need to query some web content about which context menus to show and need it to be synchronous. When I try to acquire the semaphore the thread locks without the javascript being evaluated and my javascript interface method being called. Here's my code. private Semaphore returnSemaphore = new Semaphore(0); private String returnValue; public String getJSValue(String expression) { String code = "javascript:_JSEval.setValue((function(){try{return " + expression + "+\"\";}catch(js_eval_err){return '';}})());"; //String code = "javascript: alert('here');"; Log.d(TAG, "eval: " + code); this.loadUrl(code); try { Log.d(TAG, "eval: about to acquire semaphore, " + returnSemaphore.availablePermits()); returnSemaphore.acquire(); Log.d(TAG, "past semaphore acquire"); return returnValue; } catch (InterruptedException e) { Log.e(TAG, "eval: Interrupted", e); } return null; } @SuppressWarnings("unused") private class JSEval { public void setValue(String value) { Log.i(TAG, "eval: in set value"); //if (value != null) { returnValue = value; //} returnSemaphore.release(); } } If I remove the semaphore acquire call, I get a result in setValue, so I know the interface is working. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Using ViewPager with dynamic view sets
The destroyItem will work, but the instantiateItem will not. The instatiateItem method is called the number of times returned in getCount, which is overrided to return a specific number. instantiateItem doesn't not take a parameter for a view or object to add. It just creates and adds one based on position. On Dec 27, 3:35 pm, TreKing wrote: > On Tue, Dec 27, 2011 at 2:10 PM, tatebn wrote: > > I don't see add and remove items. > > Try the official docs instead of some random open source > project.http://developer.android.com/reference/android/support/v4/view/PagerA... > > --- > -- > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago > transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Using ViewPager with dynamic view sets
I don't see add and remove items. http://www.java2s.com/Open-Source/Android/App/appsorganizer/com/google/code/appsorganizer/prova/PageAdapter.java.htm There are add and remove methods in the ViewPager. But using them outside of the adapter doesn't seem to do anything. On Dec 27, 12:43 pm, TreKing wrote: > On Tue, Dec 27, 2011 at 10:49 AM, tatebn wrote: > > I've looked at the ViewPager examples which look like it uses an adapter > > which has a defined number of pages. > > A brief look at the PageAdapter shows methods for adding and removing > items. I'm sure you tried that already. What's the problem with those > methods? > > --- > -- > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago > transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Using ViewPager with dynamic view sets
I'm trying to use ViewPager to allow the user to flip through a series of web views. I've looked at the ViewPager examples which look like it uses an adapter which has a defined number of pages. The problem I have is that the number of pages I have changes regularly. Is there not a way to just use the ViewPager for it's paging ability and add/ remove views as I see fit? -- You received this message because you are subscribed to the Google 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: Loading internal html content in android web view
Scratch this. I got it working by using a URI (all caps) URI fileUri = URI.create(filePath); to create the file. The blank web view content was because the unzipped files were empty. On Dec 6, 10:01 am, tatebn wrote: > I'm trying to load internal content in an android web view. The > content is in a content directory that's been unzipped into the app's > files directory. I can verify that the files are there by using the > adb shell. However I keep getting an error in the web view that the > file doesn't exist. I'm using a content provider for to load this. > It's registered correctly and being called. And the file path it > prints out is the same as the file path in the adb shell. > > public class InternalContentProvider extends ContentProvider{ > > private static final String TAG = "InternalContentProvider"; > > @Override > public ParcelFileDescriptor openFile(Uri uri, String mode) throws > FileNotFoundException{ > String filePath = "file://" + this.getContext().getFilesDir() > + "/content" + uri.getPath(); > File file = new File(filePath); > > Log.i(TAG, "File uri = " + filePath); > Log.i(TAG, "File name = " + file.getName()); > > ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file, > ParcelFileDescriptor.MODE_READ_ONLY); > return parcel; > } > > @Override > public boolean onCreate() { > System.out.println("Created ContentProvider"); > return true; > } > > @Override > public int delete(Uri uri, String s, String[] as) { > throw new UnsupportedOperationException("Not supported by this > provider"); > } > > @Override > public String getType(Uri uri) { > return "text/html"; > } > > @Override > public Uri insert(Uri uri, ContentValues contentvalues) { > throw new UnsupportedOperationException("Not supported by this > provider"); > } > > @Override > public Cursor query(Uri uri, String[] as, String s, String[] as1, > String s1) { > throw new UnsupportedOperationException("Not supported by this > provider"); > } > > @Override > public int update(Uri uri, ContentValues contentvalues, String s, > String[] as) { > throw new UnsupportedOperationException("Not supported by this > provider"); > } > > } > > I'm doing this in the android emulator. API level is 8. -- You received this message because you are subscribed to the Google 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: Loading internal html content in android web view
I can get it to recognize the file's existence if I remove the file:// from the front of the path. But then the web view loads a blank white page. On Dec 6, 10:01 am, tatebn wrote: > I'm trying to load internal content in an android web view. The > content is in a content directory that's been unzipped into the app's > files directory. I can verify that the files are there by using the > adb shell. However I keep getting an error in the web view that the > file doesn't exist. I'm using a content provider for to load this. > It's registered correctly and being called. And the file path it > prints out is the same as the file path in the adb shell. > > public class InternalContentProvider extends ContentProvider{ > > private static final String TAG = "InternalContentProvider"; > > @Override > public ParcelFileDescriptor openFile(Uri uri, String mode) throws > FileNotFoundException{ > String filePath = "file://" + this.getContext().getFilesDir() > + "/content" + uri.getPath(); > File file = new File(filePath); > > Log.i(TAG, "File uri = " + filePath); > Log.i(TAG, "File name = " + file.getName()); > > ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file, > ParcelFileDescriptor.MODE_READ_ONLY); > return parcel; > } > > @Override > public boolean onCreate() { > System.out.println("Created ContentProvider"); > return true; > } > > @Override > public int delete(Uri uri, String s, String[] as) { > throw new UnsupportedOperationException("Not supported by this > provider"); > } > > @Override > public String getType(Uri uri) { > return "text/html"; > } > > @Override > public Uri insert(Uri uri, ContentValues contentvalues) { > throw new UnsupportedOperationException("Not supported by this > provider"); > } > > @Override > public Cursor query(Uri uri, String[] as, String s, String[] as1, > String s1) { > throw new UnsupportedOperationException("Not supported by this > provider"); > } > > @Override > public int update(Uri uri, ContentValues contentvalues, String s, > String[] as) { > throw new UnsupportedOperationException("Not supported by this > provider"); > } > > } > > I'm doing this in the android emulator. API level is 8. -- You received this message because you are subscribed to the Google 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] Loading internal html content in android web view
I'm trying to load internal content in an android web view. The content is in a content directory that's been unzipped into the app's files directory. I can verify that the files are there by using the adb shell. However I keep getting an error in the web view that the file doesn't exist. I'm using a content provider for to load this. It's registered correctly and being called. And the file path it prints out is the same as the file path in the adb shell. public class InternalContentProvider extends ContentProvider{ private static final String TAG = "InternalContentProvider"; @Override public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException{ String filePath = "file://" + this.getContext().getFilesDir() + "/content" + uri.getPath(); File file = new File(filePath); Log.i(TAG, "File uri = " + filePath); Log.i(TAG, "File name = " + file.getName()); ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); return parcel; } @Override public boolean onCreate() { System.out.println("Created ContentProvider"); return true; } @Override public int delete(Uri uri, String s, String[] as) { throw new UnsupportedOperationException("Not supported by this provider"); } @Override public String getType(Uri uri) { return "text/html"; } @Override public Uri insert(Uri uri, ContentValues contentvalues) { throw new UnsupportedOperationException("Not supported by this provider"); } @Override public Cursor query(Uri uri, String[] as, String s, String[] as1, String s1) { throw new UnsupportedOperationException("Not supported by this provider"); } @Override public int update(Uri uri, ContentValues contentvalues, String s, String[] as) { throw new UnsupportedOperationException("Not supported by this provider"); } } I'm doing this in the android emulator. API level is 8. -- You received this message because you are subscribed to the Google 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: Cross Activity Listeners
Thanks, was actually just about to post that. Sorry for all the little questions. One of these days I'll get this crazy Android stuff. On Sep 14, 2:14 pm, Mark Murphy wrote: > On Tue, Sep 14, 2010 at 1:45 PM, tatebn wrote: > > I've stumbled on a new, related issue. One of the tabs is a mapview. > > How do I work with that? I get an error having a mapView outside of a > > mapActivity. Since I'm obviously extending TabActivity here, how do I > > get a map in one of these tabs? > > Don't extend TabActivity. Extend MapActivity. After getting your > TabHost via findViewById(), call setup() on it before proceeding. You > can see this in the two examples I linked to. > > -- > 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] Re: Cross Activity Listeners
I've stumbled on a new, related issue. One of the tabs is a mapview. How do I work with that? I get an error having a mapView outside of a mapActivity. Since I'm obviously extending TabActivity here, how do I get a map in one of these tabs? On Sep 14, 1:35 pm, tatebn wrote: > Nevermind, I think I got it as per your examples. Thanks. > > On Sep 14, 1:22 pm, tatebn wrote: > > > I tried using the set content with the view. > > > spec = tabHost.newTabSpec("albums").setIndicator("List", > > > res.getDrawable(R.drawable.driving_directions_tab_list)) > > .setContent(R.layout.driving_directions_list_screen); > > > But it's telling me it can't create the view content because it can't > > find the view with id "whatever". What am I doing wrong here? > > > Thanks > > > On Sep 14, 11:37 am, tatebn wrote: > > > > Can you point me to an example of how to do that? Currently I'm > > > creating a new intent with the activity class and setting that intent > > > as the content. How do I manage the tabs otherwise? If I just pass > > > in a view for the tab, how do I work with it to do things like refresh > > > the list, etc? > > > > On Sep 14, 11:27 am, Mark Murphy wrote: > > > > > Don't implement them as separate activities. Use the setContent() that > > > > takes a view ID as a parameter. Then, you won't have a problem. You > > > > will also take up less heap space, less stack space, and less CPU time > > > > than does your current implementation. > > > > > On Tue, Sep 14, 2010 at 11:24 AM, tatebn wrote: > > > > > Can I have one Activity listen for a message from another? I have a > > > > > TabActivity and I need to call a function/send a message to the > > > > > associated tabs. How do I go about doing that? > > > > > -- > > > > 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] Re: Cross Activity Listeners
Nevermind, I think I got it as per your examples. Thanks. On Sep 14, 1:22 pm, tatebn wrote: > I tried using the set content with the view. > > spec = tabHost.newTabSpec("albums").setIndicator("List", > > res.getDrawable(R.drawable.driving_directions_tab_list)) > .setContent(R.layout.driving_directions_list_screen); > > But it's telling me it can't create the view content because it can't > find the view with id "whatever". What am I doing wrong here? > > Thanks > > On Sep 14, 11:37 am, tatebn wrote: > > > Can you point me to an example of how to do that? Currently I'm > > creating a new intent with the activity class and setting that intent > > as the content. How do I manage the tabs otherwise? If I just pass > > in a view for the tab, how do I work with it to do things like refresh > > the list, etc? > > > On Sep 14, 11:27 am, Mark Murphy wrote: > > > > Don't implement them as separate activities. Use the setContent() that > > > takes a view ID as a parameter. Then, you won't have a problem. You > > > will also take up less heap space, less stack space, and less CPU time > > > than does your current implementation. > > > > On Tue, Sep 14, 2010 at 11:24 AM, tatebn wrote: > > > > Can I have one Activity listen for a message from another? I have a > > > > TabActivity and I need to call a function/send a message to the > > > > associated tabs. How do I go about doing that? > > > > -- > > > 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] Re: Cross Activity Listeners
I tried using the set content with the view. spec = tabHost.newTabSpec("albums").setIndicator("List", res.getDrawable(R.drawable.driving_directions_tab_list)) .setContent(R.layout.driving_directions_list_screen); But it's telling me it can't create the view content because it can't find the view with id "whatever". What am I doing wrong here? Thanks On Sep 14, 11:37 am, tatebn wrote: > Can you point me to an example of how to do that? Currently I'm > creating a new intent with the activity class and setting that intent > as the content. How do I manage the tabs otherwise? If I just pass > in a view for the tab, how do I work with it to do things like refresh > the list, etc? > > On Sep 14, 11:27 am, Mark Murphy wrote: > > > Don't implement them as separate activities. Use the setContent() that > > takes a view ID as a parameter. Then, you won't have a problem. You > > will also take up less heap space, less stack space, and less CPU time > > than does your current implementation. > > > On Tue, Sep 14, 2010 at 11:24 AM, tatebn wrote: > > > Can I have one Activity listen for a message from another? I have a > > > TabActivity and I need to call a function/send a message to the > > > associated tabs. How do I go about doing that? > > > -- > > 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] Re: Cross Activity Listeners
Can you point me to an example of how to do that? Currently I'm creating a new intent with the activity class and setting that intent as the content. How do I manage the tabs otherwise? If I just pass in a view for the tab, how do I work with it to do things like refresh the list, etc? On Sep 14, 11:27 am, Mark Murphy wrote: > Don't implement them as separate activities. Use the setContent() that > takes a view ID as a parameter. Then, you won't have a problem. You > will also take up less heap space, less stack space, and less CPU time > than does your current implementation. > > On Tue, Sep 14, 2010 at 11:24 AM, tatebn wrote: > > Can I have one Activity listen for a message from another? I have a > > TabActivity and I need to call a function/send a message to the > > associated tabs. How do I go about doing that? > > -- > 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] Cross Activity Listeners
Can I have one Activity listen for a message from another? I have a TabActivity and I need to call a function/send a message to the associated tabs. How do I go about doing that? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] GeoCoding Problems
I'm trying to use the GeoCoder to get the lat/lon for a couple of addresses. I'm running into an error where the address list comes back empty sometimes. It seems to be completely random. I have a start point and an end point to draw and route. Sometimes I can't get either one, sometimes I can get the start but not the end, sometimes I can get the end but not the start. I never seem to be able to get both. Not sure why. Yesterday it worked fine. Any thoughts? -- You received this message because you are subscribed to the Google 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] Getting variables from tab activity in the child activities
If I have a tab activity with multiple tabs, each containing a different activity, is it possible to have a variable in the tab activity and access it from the child activities? How would I do that? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Maps with directions.
Is it possibly to have a button in my app that switches to the phone's Maps application while passing in a destination for directions? And how would I do that? Haven't been able to find anything about 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] Re: Smoothing out a line on a canvas.
Perfect, thanks. On Sep 3, 2:40 pm, Romain Guy wrote: > Turn on antialiasing on the Paint used to draw the lines. > > > > On Fri, Sep 3, 2010 at 11:12 AM, tatebn wrote: > > I'm trying to draw out a race track in a map overlay. I have a series > > of locations that define the track. I have the drawing working fine > > just using canvas.drawLine() from one point to the next. But, > > understandably, this looks kind of choppy. Is there a decent way to > > smooth the line out? > > > -- > > You received this message because you are subscribed to the Google > > 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] Smoothing out a line on a canvas.
I'm trying to draw out a race track in a map overlay. I have a series of locations that define the track. I have the drawing working fine just using canvas.drawLine() from one point to the next. But, understandably, this looks kind of choppy. Is there a decent way to smooth the line out? -- You received this message because you are subscribed to the Google 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] ListView listener problems
I'm using a ListAction and I'm having some trouble with my listeners. I'm using onListItemClick to catch any item clicks, which works fine unless I add an OnLongClickListener to the list items. In that case the long click works but the short click doesn't register. I've tried adding an OnClickListener to the items individually as I had done with the long click. This works, but the regular click fires every time the long click does. How do I keep these things separate? Thanks, Brandon -- You received this message because you are subscribed to the Google 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: Searching in a tab
When I change the launch mode to singleInstance, it no longer pushes the the new intent on top, but the search intent fills the screen on search and covers the tabs. On Aug 25, 3:09 pm, tatebn wrote: > I have a tab host with two tabs. I want one of those tabs to be a > search screen. The content for the tab is a ListActivity. I'm > pulling the content from a web service. > > My problem is, when I execute the search a new intent is pushed onto > the screen. I've used the android:launchMode="singleTop" property in > my manifest for the search activity. What that seems to have done is, > once the new intent is pushed on top of the TabActivity, every time I > run the search it reuses that intent. But I want the already existing > intent which is set as the tab's content to be the one it uses. > > What can I do? -- You received this message because you are subscribed to the Google 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] Searching in a tab
I have a tab host with two tabs. I want one of those tabs to be a search screen. The content for the tab is a ListActivity. I'm pulling the content from a web service. My problem is, when I execute the search a new intent is pushed onto the screen. I've used the android:launchMode="singleTop" property in my manifest for the search activity. What that seems to have done is, once the new intent is pushed on top of the TabActivity, every time I run the search it reuses that intent. But I want the already existing intent which is set as the tab's content to be the one it uses. What can I do? -- You received this message because you are subscribed to the Google 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: Database transaction help needed.
That just makes perfect sense. Thanks. I ended up adding a second constructor to the table access wrappers that accepts both the context and an already open database connection. Works great. On Aug 24, 3:36 pm, Kostya Vasilyev wrote: > Transactions are per-connection. That's on purpose, so a connection sees all > changes made by others only once are of them are complete. > > Either switch to one connection, or don't use transactions, preferably both. > > -- > Kostya Vasilyev --http://kmansoft.wordpress.com > > 24.08.2010 23:21 пользователь "Kim Damevin" написал: > > Hi, > > Do you call getWriteableDatabase twice ? because you shouldn't. > It should be the same SQLiteDatabase object or you have to end the > transaction from the first one before you start a new one. > > Kim > > On Tue, Aug 24, 2010 at 9:09 PM, tatebn wrote: > > > I'm using transaction... > > -- You received this message because you are subscribed to the Google 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] Database transaction help needed.
I'm using transactions to insert data into several tables with foreign key relationships. Basically I have a wrapper for each table. Each wrapper creates it's own SQLiteOpenHelper and holds onto the SQLiteDatabase that comes from the getWriteableDatabase() call. Now here's the problem, When I insert a row into the main table I begin a transaction. After the main data is inserted I do an insert for the other tables with FK relationships to the main table. Each of those inserts is contained in a wrapper for the specific table, and begins it's own transaction. Each level checks to see if anything failed before setting its transaction to complete. The problem is when I go to a second level, my transaction dies because the database is locked, presumably from the first level. Here are the error messages I get. 08-24 14:54:53.105: ERROR/Database(468): CREATE TABLE android_metadata failed 08-24 14:54:53.120: ERROR/Database(468): Failed to setLocale() when constructing, closing the database 08-24 14:54:53.120: ERROR/Database(468): android.database.sqlite.SQLiteException: database is locked This is happening on the open call to the second level. How can I avoid this? Thanks, Brandon -- You received this message because you are subscribed to the Google 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