如何通过2维数组广播reciver类 [英] how to pass 2 dimensional array to broadcast reciver class
本文介绍了如何通过2维数组广播reciver类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在路过我的意图主要活动类传递意图,它实现广播reciver和意图包含2维数组
I am new in android and facing problem in passing intent my main activity class is passing intent to the class which implements broadcast reciver and intent contains 2 dimensional array
//这里curDts是我的2维数组
//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+"--");
}
这里my_date正显示出空
请帮我..
推荐答案
这样。但我从来没有编译并运行它。
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+"--");
}
这篇关于如何通过2维数组广播reciver类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文