ABS - ShareActionProvider: How to remove icon on right hand side

Showing 1-9 of 9 messages
ABS - ShareActionProvider: How to remove icon on right hand side tiptopjat 6/16/12 4:26 PM
I have implemented ShareActionProvider in my ABS.

When a user selects an app to share content with, eg Twitter, the actionbar displays a Twitter icon next to the Share button.

Does anybody know how to disable this?
Re: ABS - ShareActionProvider: How to remove icon on right hand side Sven Meier 6/17/12 2:06 AM
Hi,

this is no ABS question but here's a solution anyway:

Implement OnShareTargetSelectedListener and set it on the
ShareActionProvider:

     @Override
     public boolean onShareTargetSelected(ShareActionProvider source,
             Intent intent) {

         context.startActivity(intent);

         // started activity ourself to prevent search history
         return true;
     }

Now the selected share action will no longer appear in the search
history on the actionbar.

Hope this helps
Sven
Re: ABS - ShareActionProvider: How to remove icon on right hand side tiptopjat 6/17/12 3:53 AM
Thanks for sharing this solution, but I can't get it to work.

Here's my code, should I modify anything in OnCreateOptionsMenu()?



public class MainActivity extends SherlockListActivity implements OnShareTargetSelectedListener {

        public onCreate....{}

        @Override
public boolean onCreateOptionsMenu(Menu menu)  {
// Inflate your menu.
getSupportMenuInflater().inflate(R.menu.share_action_provider, menu);

// Set file with share history to the provider and set the share intent.
MenuItem actionItem = menu
.findItem(R.id.menu_item_share_action_provider_action_bar);
ShareActionProvider actionProvider = (ShareActionProvider) actionItem
.getActionProvider();
actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);

//actionProvider.setShareIntent(createShareIntent());

return true;
}
public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
// TODO Auto-generated method stub
this.startActivity(createShareIntent()); 

                 return true; 
}

private Intent createShareIntent() {
// Creates intent to share
intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT,

return intent;
}
Re: ABS - ShareActionProvider: How to remove icon on right hand side tiptopjat 6/17/12 5:59 AM
The main reason I would like to remove the application icon is because the icons have a grey border, which doesn't match my black actionbar. (http://imageshack.us/photo/my-images/155/20120617130029.jpg/). Do you know how I can change this from black to grey? I would be happy to keep the app icon on the action bar if I could change the grey colour.


On Sunday, June 17, 2012 10:06:02 AM UTC+1, Sven Meier wrote:
Re: ABS - ShareActionProvider: How to remove icon on right hand side Sven Meier 6/17/12 6:42 AM
You have to set your listener on the action provider:

    actionProvider.setOnShareTargetSelectedListener(this);

Sven
Re: ABS - ShareActionProvider: How to remove icon on right hand side tiptopjat 6/17/12 7:03 AM
That works perfectly! Thank you. 
Re: ABS - ShareActionProvider: How to remove icon on right hand side Chris Ian Fiel 2/8/13 1:06 AM

I tried this solution but it does not work. the button cannot be press this is my code below. any idea what I am missing?

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.tonesdetail, menu);

MenuItem actionItem = menu.findItem(R.id.share);
ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
actionProvider.setOnShareTargetSelectedListener(this);

return true;
}

@Override 
        public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { 
               this.startActivity(createShareIntent()); 
        return true; 

        private Intent createShareIntent() {
       File file = new File(SharedPrefsConfig.SD_TONES+name+".mp3");
           Intent shareIntent = new Intent(Intent.ACTION_SEND);
           shareIntent.setType("audio/*");
           Uri uri =  Uri.fromFile(file);
           shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
        return shareIntent;
Re: ABS - ShareActionProvider: How to remove icon on right hand side තරිඳු ගුණවර්ධන 8/18/13 1:06 AM
Set the intent to your provider.
ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
actionProvider.setShareIntent(createShareIntent());
...

Then,
@Override 
        public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { 
               this.startActivity(intent); 
        return true; 
Re: ABS - ShareActionProvider: How to remove icon on right hand side Prasanna Gunasekeran 6/2/14 12:18 AM
This solution is not at all woorking cant able to clik on share icon...
Anybody know the exact solution