[英]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.