Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ShareActionProvider work in debugging mode but doesn't in real device
    text
    copied!<p>When I debug my app on device, using Eclipse, this is the result, that is what I want:</p> <p><a href="https://docs.google.com/file/d/0B0uEiAp76nbMYUNURU85VDRac2s/edit?usp=sharing" rel="nofollow">App image from debug mode</a></p> <p>The 'share icon' works fine!</p> <p><strong>HERE, THE PROBLEM!!!! WHEN I ADD THE APP ON GOOGLE PLAY, AND THEN I INSTALL THE APP FROM IT, THIS IS THE RESULT:</strong></p> <p><a href="https://docs.google.com/file/d/0B0uEiAp76nbMNHZsWWRGOHAwREk/edit?usp=sharing" rel="nofollow">App image after install from Google Play</a></p> <p><strong>The 'share icon' doesn't work. It's clickable, but it does nothing. The icon doesn't appear, just the title: "share"</strong></p> <p>This is the code:</p> <pre><code>private ShareActionProvider mShareActionProvider; @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu items for use in the action bar MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); // Set up ShareActionProvider's default share intent MenuItem shareItem = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem); mShareActionProvider.setShareIntent(getDefaultShareIntent()); return super.onCreateOptionsMenu(menu); } private Intent getDefaultShareIntent() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.app_name)); intent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.app_play_address)); return intent; } </code></pre> <p>And this is main.xml file:</p> <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:yourapp="http://schemas.android.com/apk/res-auto"&gt; &lt;item android:id="@+id/action_share" android:title="@string/share" yourapp:showAsAction="ifRoom" yourapp:actionProviderClass="android.support.v7.widget.ShareActionProvider" /&gt; &lt;/menu&gt; </code></pre> <p>In styles.xml file:</p> <pre><code>&lt;resources&gt; &lt;!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --&gt; &lt;style name="AppBaseTheme" parent="@style/Theme.AppCompat"&gt; &lt;/style&gt; &lt;!-- Application theme. --&gt; &lt;style name="AppTheme" parent="AppBaseTheme"&gt; &lt;!-- All customizations that are NOT specific to a particular API-level can go here. --&gt; &lt;/style&gt; </code></pre> <p></p> <p>styles.xml file in v-11:</p> <pre><code>&lt;resources&gt; &lt;!-- Base application theme for API 11+. This theme completely replaces AppBaseTheme from res/values/styles.xml on API 11+ devices. --&gt; &lt;style name="AppBaseTheme" parent="@style/Theme.AppCompat"&gt; &lt;!-- API 11 theme customizations can go here. --&gt; &lt;/style&gt; </code></pre> <p></p> <p>styles.xml file in v-14:</p> <pre><code>&lt;resources&gt; &lt;!-- Base application theme for API 14+. This theme completely replaces AppBaseTheme from BOTH res/values/styles.xml and res/values-v11/styles.xml on API 14+ devices. --&gt; &lt;style name="AppBaseTheme" parent="@style/Theme.AppCompat"&gt; &lt;!-- API 14 theme customizations can go here. --&gt; &lt;/style&gt; </code></pre> <p></p> <p>and, finally, on manifest.xml:</p> <pre><code>&lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload