0

I am new in Android and facing problem in passing intent my main activity class is passing intent to the class which implements broadcast receiver and intent contains 2 dimensional array

//here curDts is my 2-dimensional array

Bundle b=new Bundle();
        b.putSerializable("dates", curDts );
        Intent intent = new Intent(this, AlarmReceiver.class);
        intent.putExtras(b);

public void onReceive(Context arg0, Intent arg1) {
    Bundle b = arg1.getExtras();
    //Log.v("hahahha","curDts");
        String[][] my_date = (String[][])b.getSerializable("dates");
        Log.v("dates",my_date+"--");
    }

here my_date is showing null

Cœur
  • 37,241
  • 25
  • 195
  • 267
user2750762
  • 419
  • 2
  • 6
  • 24

1 Answers1

0

like this. but i never compile and run it.

Bundle b=new Bundle();   
Intent intent = new Intent(this, AlarmReceiver.class);         
intent.putExtra("len", curDts.length);
    for(int i = 0; i < curDts.length; i++){
       intent.putExtra("item" + i, curDts[i]);
    }

public void onReceive(Context arg0, Intent arg1) {
//Log.v("hahahha","curDts");
    String[][] my_date = new String[][arg1.getIntExtra("len")];
    for(int i = 0; i < arg1.getIntExtra("len"); i++){
         my_date[i] = arg1.getStringArrayExtra("item"+i, null);
    }
    Log.v("dates",my_date+"--");
}
Jiang YD
  • 3,205
  • 1
  • 14
  • 20