创建共享历史文件的一些方法可以解决此问题
这可以通过在应用安装时使用自定义共享历史文件来解决。
例如在 App Create() 上调用 CreateShareHisotryFile()
public class YourBrokenAPP extends Application {
public static SHARE_HISTORY_FILE_NAME = "c_share_hist.xml";
@Override
public void onCreate() {
super.onCreate();
CreateShareHisotryFile();
}
private void CreateShareHisotryFile() {
String data = "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?> "+
"<historical-records>" +
"<historical-record activity=\"com.google.android.apps.plus/com.google.android.libraries.social.gateway.GatewayActivity\" time=\"1426500217970\" weight=\"1.0\" />"+
"</historical-records>";
try {
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(openFileOutput(SHARE_HISTORY_FILE_NAME, Context.MODE_PRIVATE));
outputStreamWriter.write(data);
outputStreamWriter.close();
}
catch (IOException e) {
Log.e("Exception", "File write failed: " + e.toString());
}
}
然后在片段的 onCreateOptionsMenu 中使用我们刚刚创建的共享历史文件....
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
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.setShareHistoryFileName(c_share_hist.xml);
}
注意history-records需要在xml文件中@至少一个history-record子元素
那么这一切都很好 ENJOY.......