3

이클립스를 사용하여 장치에 내 응용 프로그램을 디버깅 할 때,이 결과는, 즉 내가 원하는입니다 :안드로이드 ShareActionProvider 디버깅 모드에서 작동하지만,하지 않습니다 실제 장치에서

App image from debug mode

'공유 아이콘 '이 잘 작동합니다!

여기

문제 !!!!

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" > 

답변

10

당신은 당신의 릴리스 Proguard와를 사용하고 있습니까?

내가 할, 내가 클래스 ShareActionProvider가 Proguard와에 의해 엉망이됩니다 실현 때문에 내가 Proguard와-맹 글링에서 그것을 취할 때까지 동일한 문제가 있었다.

-keep class android.support.v7.widget.ShareActionProvider { *; } 
1

매니페스트에 올바른 권한이 있습니까?

http://developer.android.com/guide/topics/security/permissions.html

+0

어떤 권한 :

그래서, 당신의 난독-project.txt에 다음 줄을 포함? –

+0

"ShareActionProvider"를 사용하려면 사용 권한이 필요합니까? –

+0

확인은 여기 http://developer.android.com/training/sharing/shareaction.html –

관련 문제