My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 25467: android.widget.ShareActionProvider does not work on the emulator
33 people starred this issue and may be notified of changes. Back to list
 
Reported by Lars.Vo...@gmail.com, Feb 13, 2012
If I add a ShareActionProvider to my application it works file on a real device but not on the emulator. If I press the Share button in the emulator nothing happens.


Here is my menu:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

   <item android:id="@+id/menu_share"
          android:title="Share"
          android:showAsAction="ifRoom"
          android:actionProviderClass="android.widget.ShareActionProvider" />
    <item
        android:id="@+id/item1"
        android:showAsAction="ifRoom"
        android:title="Hello">
    </item>
    <item
        android:id="@+id/item2"
        android:showAsAction="ifRoom"
        android:title="This will not fit in the Action bar">
    </item>

</menu>

I add this menu to my Activity:

@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.mymenu, menu);
		provider = (ShareActionProvider) menu.findItem(R.id.menu_share)
				.getActionProvider();
		doShare();
		return true;
	}



	public void doShare() {
		Intent intent = new Intent(Intent.ACTION_SEND);
		intent.setType("text/plain");
		intent.putExtra(Intent.EXTRA_TEXT, "Message");
		provider.setShareIntent(intent);
	}
Feb 23, 2012
Project Member #1 x...@android.com
(No comment was entered for this change.)
Status:
Owner: ad...@android.com
Labels: -Component-Tools Component-Framework
Mar 29, 2012
#2 jakewhar...@gmail.com
This is due to their only being a single (or zero) applications which support that intent. If this is the case the provider will not allow any interaction. It would be nice if there was a Toast or the dropdown still showed with a message of some sort.
Mar 30, 2012
#3 buz...@gmail.com
I agree with Jake : this is because the emulator do not have many apps that can answer the intent.
Mar 30, 2012
#4 Lars.Vo...@gmail.com
SMS app is available and this accepts Intent.ACTION_SEND. If I trigger this directly it also works. Hence I suspect still a bug.
Mar 30, 2012
Project Member #5 ad...@android.com
(No comment was entered for this change.)
Owner: svetosla...@android.com
Jun 7, 2012
#6 dfuerniss
If you add another app (see attachment for example) to your emulator supporting ShareIntents of type text/plain and accepting Intent.ACTION_SEND, the ShareProvider will work. It then also displays the already mentioned Messaging App. This however should be considered a workaround. 
pva-sharetarget.zip
147 KB   Download
Aug 1, 2012
#7 digi...@gmail.com
I can reproduce this bug too, and the weird thing is it works if you've opened the list at least once, with at least two intents. 

For example:

Two activities: Open list.
Change intent to one that resolves to one activity.
Open list: Still works.

It doesn't work if you haven't yet opened it.
Aug 1, 2012
#8 digi...@gmail.com
Seems related to these lines in ActivityChooserView$ActivityChooserViewAdapter:

if (!mShowDefaultActivity && mDataModel.getDefaultActivity() != null) {
activityCount--;
}

IF you haven't opened the list yet, activityCount gets subtracted by 1, getCount() returns 0 and the button gets disabled. The list still contains one activity.

The title should be changed, because this doesn't really have anything to do with the emulator and affects real production devices. Even if there's only 1 activity, it should still be shown instead of disabling the button.
Dec 10, 2012
#9 adla...@gmail.com
I wonder, based on the title, whether this bug is as visible as it should be. Is there a way to update the title to more closely reflect the nature of the bug?

I can imagine that emulator-related bugs hover somewhere near the bottom of the priority list, and this is not an emulator-only bug. A proper title might also help with searching, which might prevent a few developers from spending 3 hours wondering why their shiny new share button just... does... nothing.

Dec 26, 2012
#10 doppio...@gmail.com
I have something similar going on here: http://stackoverflow.com/questions/12087164/shareactionprovider-not-clickable-and-not-rendering-properly-on-first-render

Not sure if it's the same thing. I'm experiencing the issue on my device as well as the emulator though.
Dec 26, 2012
#11 ezelspin...@gmail.com
Haven't tried to reproduce myself, but wonder if an old IntentChooser would have this problem too?

One of you created this duplicate (for reference): https://code.google.com/p/android/issues/detail?id=41209
Jun 18, 2013
#12 jbq@android.com
(No comment was entered for this change.)
Status: Assigned
Sign in to add a comment

Powered by Google Project Hosting