GovDic
이라는 응용 프로그램에서 공유 기능을 만들었습니다. 그러나 공유 목록에서 응용 프로그램 자체가 나타났습니다. 공유에서 제외하는 방법은 무엇입니까?Android 공유 (ShareActionProvider)에서 응용 프로그램 자체를 제외하는 방법
다른 애플 리케이션에 공유 text/plain
콘텐츠가 필요, 다른 애플 리케이션이이 애플 리케이션에 text/plain
콘텐츠를 공유 할 수 있습니다.
매니페스트 :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.comp548.govdic">
...
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
...
<activity android:name=".OrgDetailActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>
</application>
</manifest>
메뉴 :
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_item_share"
app:showAsAction="ifRoom"
android:title="@string/share"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
</menu>
활동
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate menu resource file.
getMenuInflater().inflate(R.menu.detail_menu, menu);
// Locate MenuItem with ShareActionProvider
MenuItem menuItem = menu.findItem(R.id.menu_item_share);
// Fetch and store ShareActionProvider
ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType(Constant.MIME_TYPE_TEXT_PLAIN);
shareIntent.putExtra(Intent.EXTRA_TEXT, etDescription.getText().toString());
shareActionProvider.setShareIntent(shareIntent);
// Return true to display menu
return true;
}