File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes Code won't work, unable to remove recently shared button from actionbar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Code won Watch "Code won New topic
Author

Code won't work, unable to remove recently shared button from actionbar

Andrew Tyrer
Greenhorn

Joined: Feb 17, 2014
Posts: 8
I created a share button on the action bar and although I like the fact it allows me to share to communication components like messaging. I wanted to remove the recently shared button that appears after you've shared to for instance messaging.

I simply can't get the code for this to work.

My code and a link to my project files are below:


Link to project files:

https://www.mediafire.com/?qjysm9suvj1lvjc

**MainActivity


Menu.xml


Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
Have you tried to set the shared history file to null? Something like:

Your activity implements the OnShareTargetSelectedListener interface. Shouldn't you use it as a listener instead of creating an anonymous inner class.
Andrew Tyrer
Greenhorn

Joined: Feb 17, 2014
Posts: 8
Irina Goble wrote:Have you tried to set the shared history file to null? Something like:

Your activity implements the OnShareTargetSelectedListener interface. Shouldn't you use it as a listener instead of creating an anonymous inner class.


I tried that, couldn't get it to work...

Have you had any luck??

What changes would you make to the above code?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Andrew Tyrer wrote:
Irina Goble wrote:Have you tried to set the shared history file to null? Something like:


I tried that, couldn't get it to work...

What did you try? What didn't work? What Irina described is what you should be doing. Read the API for ShareActionProvider for a description (see here).


Steve
Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
I've never used ShareActionProvider before. The documentation says:
Set to null if share history should not be persisted between sessions.
I tried a simple app to see how it works and turns out there is more to it.
This class, ShareActionProvider, gets quite involved with keeping history of called activities. And there is no simple way to disable the default activity button as it is set not just from a history file but from the history records in the underlying Adapter. Here is a code fragment from the source code that is responsible for this: android.widget.ActivityChooserView.updateAppearance()

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code won't work, unable to remove recently shared button from actionbar