我想序列化Item的arraylist 但它不起作用....
我的Item类扩展了Stuff类并且有一些子类.
我的所有类都实现了Serilalizable.
我有这个部分:
Run Code Online (Sandbox Code Playgroud)try{ // Serialize data object to a file ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("MyData.ser")); out.writeObject(myData); out.close(); // Serialize data object to a byte array ByteArrayOutputStream bos = new ByteArrayOutputStream() ; out = new ObjectOutputStream(bos) ; out.writeObject(myData); out.close(); // Get the bytes of the serialized object byte[] buf = bos.toByteArray(); } catch (IOException e) { }我的课程 :
Run Code Online (Sandbox Code Playgroud)public class Stuff implements Serializeable{ .... some protected fields . …
我点击通知时开始活动有问题...
public class MyNotification extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Toast.makeText(context, "notification", 25).show();
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
context).setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Test Notification")
.setContentText("This is test notification ");
Intent myIntent = new Intent(context, MainActivity.class);
PendingIntent intent2 = PendingIntent.getBroadcast(context, 1,
myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.setContentIntent(intent2);
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, notificationBuilder.build());
}
}
Run Code Online (Sandbox Code Playgroud)
怎么了 ???