?yb? 2010-11-20 16:59 采纳率: 100%
浏览 386
已采纳

如何从 Android 上获得额外的数据?

How can I send data from one activity (intent) to another?

I use this code to send data:

Intent i=new Intent(context,SendMessage.class);
i.putExtra("id", user.getUserAccountId()+"");
i.putExtra("name", user.getUserFullName());
context.startActivity(i);

转载于:https://stackoverflow.com/questions/4233873/how-do-i-get-extra-data-from-intent-on-android

  • 写回答

14条回答 默认 最新

  • 胖鸭 2010-11-20 17:04
    关注

    First, get the intent which has started your activity using the getIntent() method:

    Intent intent = getIntent();
    

    If your extra data is represented as strings, then you can use intent.getStringExtra(String name) method. In your case:

    String id = intent.getStringExtra("id");
    String name = intent.getStringExtra("name");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(13条)

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波