0

플래시 응용 프로그램을 만들고 있는데 알림 표시 줄에서 켜기/끄기 버튼을 클릭하고 해당 버튼에서 액션을 수행하고 싶습니다. 내가 뭘하고 있는가하는 것은 이것이다 ...클래스 객체를 mainActivity 클래스의 BroadCastReviever에 전달하는 방법

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 프로그래밍에 익숙하지 않으므로 문의하는 것이 어리석은 일이라도 도와주세요.

+1

클래스가''Parceble''을 구현하고 그것을 의도에 넣으시겠습니까? – longkai

+0

자세히 설명해 주시겠습니까? 감사합니다. 또는 도움을 얻을 수있는 링크를 제공합니다. 고마워. –

+0

아래의 답변의 링크를 시도해보십시오. – longkai

답변

1

개체를 serialize하면 도움이 될 수 있습니다. 개체를 String으로 변환합니다. 개체를 직렬화하여 전달하십시오.

아래 링크는 도움이 될 수 있습니다. How to send an object from one Android Activity to another using Intents?

+0

부모 클래스에서 정적 변수를 사용하여 도움을 주셔서 감사합니다.하지만 그 덕분에 정말 감사합니다. –

관련 문제