[英]How can i pass the class object into the BroadCastReviever from the mainActivity class
我正在制作一个Flash应用程序,我想在通知栏中有一个“打开/关闭”按钮,然后在该按钮上单击“我要执行一些操作”。 我在做什么是这个...
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);
我知道意图只接受类而不是对象,但我想将类对象传递给onRecieve f BroadCast Reciever,并想使用它们,任何人都可以帮助我如何做到这一点,我阅读了链接但无法申请。 抱歉,这是一个愚蠢的问题,我是Android编程的新手,所以即使是愚蠢的问题也请帮我。
序列化对象可能对您有帮助。 它将您的对象转换为String。 只需序列化您的对象并传递它即可。
下面的链接可能会帮助您。 如何使用意图将对象从一个Android活动发送到另一个?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.