根据Android文档,如果我不希望我的 ShareActionProvider 保留我应该调用的共享历史记录
mShareActionProvider.setShareHistoryFileName(null)
但是,当我这样做时,在选择共享选项时会出现以下崩溃:
11-15 10:06:34.848: E/AndroidRuntime(22461): java.lang.IllegalStateException: No preceding call to #readHistoricalData
11-15 10:06:34.848: E/AndroidRuntime(22461): at android.widget.ActivityChooserModel.persistHistoricalDataIfNeeded(ActivityChooserModel.java:573)
11-15 10:06:34.848: E/AndroidRuntime(22461): at android.widget.ActivityChooserModel.addHisoricalRecord(ActivityChooserModel.java:743)
11-15 10:06:34.848: E/AndroidRuntime(22461): at android.widget.ActivityChooserModel.chooseActivity(ActivityChooserModel.java:491)
11-15 10:06:34.848: E/AndroidRuntime(22461): at android.widget.ActivityChooserView$Callbacks.onItemClick(ActivityChooserView.java:547)
下面是设置 ShareActionProvider 的代码:
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.article_pager_menu, menu);
// mShareActionProvider is a field in the Activity
mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.menu_share)
.getActionProvider();
mShareActionProvider
.setShareHistoryFileName(null);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
mShareActionProvider.setShareIntent(shareIntent);
mShareActionProvider.onCreateActionView();
return true;
}
有什么想法可以解决这个问题吗?