在BroadcastReceive里得到的参数,比如内容,地址(号码),时间等,怎么将他们传到另一个Activity中去??

解决方案 »

  1.   

    方法有很多!
    一:简单的,把该变量定义为static变量,其它类直接通过类调用!
    二:将数据通过键值对通过SharedPreference保存到xml文件,Activity读取
    三:将数据保存到sqlite数据库,Activity读取
    四:定义一个数据类,添加这些数据的get set方法,通过intent传递
    五:将数据添加到Bundle,通过intent传递
    六:直接通过intent传递楼主试试吧!
      

  2.   


    很全哦!如果数据就几个的话!就用把数据添加到Bundle中,然后通过Intent传递了!
      

  3.   


    //放在Bundle里卖弄传递过去
                                    Bundle b1 = new Bundle();
    b1.putString("choosed", choosed);
    intent.putExtras(b1);
                                    Intent intent = new Intent();
    intent.setClass(MyConste.this, SubConste.class);
    startActivityForResult(intent, 0);
      

  4.   

    楼上说得很对我在补充一点                //在这里把username放在bundle中 在用intent传递到下一个activity中
                    Intent intent = new Intent();
    intent.setClass(now.this, your.class);
    Bundle mBundle = new Bundle();
    mBundle.String("username", "你的名子");
    intent.putExtras(mBundle);
                    startActivity(intent);                //在新的activity中接收
                    Bundle bundle = getIntent().getExtras();
    String name = bundle.getString("username");//这个string就是从上一个activity中传递过来的值
      

  5.   

    lz为什么不直接在目标Activity中注册广播,然后在BroadcastReceive中得到内容,地址(号码),时间等参数
      

  6.   


    比较全呀,小数据时就通过Bundle或Intent直接传递好了,大数据时用sqlite