으로 의도에서 텍스트를 공유하지 않습니다. Gmail, WhatsApp 등에서는 Facebook에서는 작동하지 않지만 괜찮습니다.ShareActionProvider 내가 간단한 텍스트를 공유 할 ShareActionProvider (android.widget.ShareActionProvider)를 사용하고 페이스 북
Intent에 첨부 된 텍스트를 공유하지 않고 대신 사용자에게 새 게시물을 작성하도록 요청합니다.
해결 방법?
여기 내 코드입니다 :
XML :
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
>
<item android:id="@+id/action_share"
android:title="@string/action_share"
android:showAsAction="always"
android:actionProviderClass="android.widget.ShareActionProvider" />
</menu>
자바 :
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Inflate the menu; this adds items to the action bar if it is present.
inflater.inflate(R.menu.detailfragment, menu);
// Retrieve the share menu item
MenuItem share = menu.findItem(R.id.action_share);
// Get the provider and hold onto it to set/change the share intent.
mShareActionProvider = (ShareActionProvider) share.getActionProvider();
// Attach an intent to this ShareActionProvider. You can update this at any time,
// like when the user selects a new piece of data they might like to share.
if (mShareActionProvider != null && mForecastStr != null) {
mShareActionProvider.setShareIntent(createShareIntent());
Log.v(LOG_TAG, "mForecast: " + mForecastStr);
Log.v(LOG_TAG, "Intent: " + mShareActionProvider);
} else {
Log.d(LOG_TAG, "Share Action Provider is null?");
}
}
public Intent createShareIntent() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, mForecastStr);
return shareIntent;
}
감사합니다!
"페이스 북에서 작동하지 않는 것"을 완전하고 정확하게 설명하십시오. – CommonsWare
죄송합니다. 죄송합니다. 고마워!! – Makoto