이클립스를 사용하여 장치에 내 응용 프로그램을 디버깅 할 때,이 결과는, 즉 내가 원하는입니다 :안드로이드 ShareActionProvider 디버깅 모드에서 작동하지만,하지 않습니다 실제 장치에서
'공유 아이콘 '이 잘 작동합니다!
여기문제 !!!!
App image after install from Google Play
'공유 아이콘'이 작동하지 않습니다 : 나는 Google Play의 앱을 추가 한 다음 내가 IT에서 앱을 설치하면, 다음은 결과입니다. 클릭 할 수 있지만 아무것도 수행하지 않습니다.
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;
}
그리고이 main.xml에 파일 : styles.xml에서
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_share"
android:title="@string/share"
yourapp:showAsAction="ifRoom"
yourapp:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
</menu>
이 코드입니다
"공유"아이콘은, 단지 제목을 표시되지 않습니다 파일 :
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
V-11 0
styles.xml 파일 : V-14
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
<!-- API 11 theme customizations can go here. -->
</style>
styles.xml 파일 : 마지막
<resources>
<!--
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.
-->
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
<!-- API 14 theme customizations can go here. -->
</style>
하고, manifest.xml에 :
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
어떤 권한 :
그래서, 당신의 난독-project.txt에 다음 줄을 포함? –
"ShareActionProvider"를 사용하려면 사용 권한이 필요합니까? –
확인은 여기 http://developer.android.com/training/sharing/shareaction.html –