Java 如何将类对象从mainActivity类传递到BroadCastReviever中
我正在制作一个flash应用程序,我想在通知栏中有一个开/关按钮,然后在该按钮上单击我想执行一些操作。我正在做的是Java 如何将类对象从mainActivity类传递到BroadCastReviever中,java,android,broadcastreceiver,android-notifications,android-broadcast,Java,Android,Broadcastreceiver,Android Notifications,Android Broadcast,我正在制作一个flash应用程序,我想在通知栏中有一个开/关按钮,然后在该按钮上单击我想执行一些操作。我正在做的是 Intent switchIntent = new Intent(this, switchOffButtonListener.class); PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0, switchIntent, 0); remot
Intent switchIntent = new Intent(this, switchOffButtonListener.class);
PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0,
switchIntent, 0);
remoteViews.setOnClickPendingIntent(R.id.closeOnFlash,
pendingSwitchIntent);
但我想这么做我怎么能这么做
//switchOffButtonListener notificationOnOff= new switchOffButtonListener(flash,soundFlashing,closeOnFlash);
Intent switchIntent = new Intent(this, notificationOnOff);
PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0,
switchIntent, 0);
remoteViews.setOnClickPendingIntent(R.id.closeOnFlash,
pendingSwitchIntent);
我知道intent只接受类而不是对象,但我想将类对象传递到OnReceive f广播接收器,并想使用它们。有人能帮我怎么做吗?我阅读了链接,但无法应用。抱歉,如果这是一个愚蠢的问题,我是Android编程新手,所以请帮助我解决这个问题,即使这样问很愚蠢。序列化对象在您的情况下可能会有所帮助。它将把你的对象转换成字符串。 只需序列化对象并传递它 下面的链接可能对您有所帮助。
让该类实现
Parceble
,并将其付诸实施?请您详细解释我将感谢您,或者给我一个链接,在那里我可以找到一些帮助。非常感谢。请尝试下面的答案链接?感谢您的帮助,我在父类中使用了静态变量,但它对我非常有用,所以非常感谢。