private static void set_share_data(OAuthV2 oAuth) throws IOException {
SharedPreferences sharedPreferences = globle_activity
.getSharedPreferences("qq_author", Activity.MODE_PRIVATE);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(oAuth);
String productBase64 = new String(Base64.encodeBase64(baos
.toByteArray()));
Editor editor = sharedPreferences.edit();
editor.putString("qq_auth", productBase64);
editor.commit();
}
private static OAuthV2 get_share_data() throws StreamCorruptedException,
IOException, ClassNotFoundException {
SharedPreferences sharedPreferences = globle_activity
.getSharedPreferences("qq_author", Activity.MODE_PRIVATE);
String productBase64 = sharedPreferences.getString("qq_auth", "");
// 对Base64格式的字符串进行解码
Log.i("get_share_data productBase64", "productBase64:" + productBase64);
byte[] base64Bytes = Base64.decodeBase64(productBase64.getBytes());
ByteArrayInputStream bais = new ByteArrayInputStream(base64Bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
// 从ObjectInputStream中读取Product对象
OAuthV2 oAuth = (OAuthV2) ois.readObject();
return oAuth;
}