마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Parcelable로 arrayList를 intent에 넣어서 전달했는데 계속 null값만 ㅠㅜ

0 추천
package com.example.openapi;

import android.os.Parcel;
import android.os.Parcelable;

public class MyItemParcelable implements Parcelable{
private String name,id,arrive;
 
 public MyItemParcelable(){}

 public MyItemParcelable(String name,String id, String arrive){
  this.name=name;
  this.id=id;
  this.arrive=arrive;
 }
 
 public MyItemParcelable(Parcel in){
  readFromParcel(in);
 }
 
 public String getName(){
  return name;
 }
 
 public void setName(String name){
  this.name=name;
 }
 public String getId(){
  return id;
 }
 public void setId(String id){
  this.id=id;
 }
 public String getArrive(){
  return arrive;
 }
 public void setArrive(String arrive){
  this.arrive=arrive;
 }
 public int describeContents() {
  return 0;
 }
 @Override
 public void writeToParcel(Parcel dest, int flags) {
  // TODO Auto-generated method stub
  dest.writeString(name);
  dest.writeString(id);
  dest.writeString(arrive);
 }
 
 public void readFromParcel(Parcel in){
  name=in.readString();
  id=in.readString();
  arrive=in.readString();
 }
 
 public static final Parcelable.Creator<MyItemParcelable> CREATOR = new Parcelable.Creator<MyItemParcelable>() {

  @Override
  public MyItemParcelable createFromParcel(Parcel source) {
   // TODO Auto-generated method stub
   return new MyItemParcelable(source);
  }

  @Override
  public MyItemParcelable[] newArray(int size) {
   // TODO Auto-generated method stub
   return new MyItemParcelable[size];
  }
 };
 
}

parcelable구현한건 위와 같은데... 보내는부분과 받는 부분은 아래 댓글에 첨부할게요ㅠㅜ

보내는 arrayList에 값이 제대로 들어간 것은 확인을 했는데 보내는 부분이나 받는부분에서 문제가 생긴것 같습니다..

받는 부분이 broadcastReceiver이긴 한데... 무슨 차이가 있는걸까요ㅠㅜ

뇽뇽이 (440 포인트) 님이 2014년 12월 26일 질문
보내는 부분입니다
    AlarmManager am3 = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
        Intent intent3 = new Intent(NearBusStationSearch.this, BusArriveReceiver.class);
        intent3.putParcelableArrayListExtra("DATA", nearMatchingList);
        PendingIntent sender3 = PendingIntent.getBroadcast(NearBusStationSearch.this, 0, intent3, 0);
        am3.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), 10000, sender3);

받는부분입니다
public void onReceive(Context context, Intent intent) {
        mContext= context;
       
        matchingList= new ArrayList<MyItemParcelable>();
        matchingList=intent.getParcelableArrayListExtra("DATA");

       
        if(matchingList==null){
            Toast.makeText(mContext, "matchingList", 0).show();
        }else{
            Toast.makeText(mContext, ""+matchingList.size(), 0).show();
            for(int i=0;i<matchingList.size();i++){
                String arsId;
                arsId=matchingList.get(i).getId();

                Toast.makeText(mContext, "Completeeeeeeeee", 0).show();
            }
        }
}
여기서 toast메시지로 matchingList가 뜨는 것으로 보아 널값이라는 걸텐데.. 어떻게 된걸까요ㅠㅜㅠㅜ
알려주시면 감사합니다ㅠㅜ
해보니깐....어쩔때는 잘 받고 어떤때는 안되고 하는데....이유가 뭘까요ㅠ

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...