Swe*_*ect 3 java eclipse android android-intent
好的,我从用户输入的一些数据中创建了一个简单的字符串。我现在希望将此数据作为字符串(类似 CSV 的字符串)传递到下一个活动。在一个例子中,我看到了这一点:
intent.putExtra(EXTRA_MESSAGE, string_to_be_sent)
Run Code Online (Sandbox Code Playgroud)
但这会引发错误,指出 EXTRA_MESSAGE 不是值 - 即。它被意图识别。我认为这个例子已经过时了。我应该使用什么来发送字符串?我查看了文档并发现了这一点:
public Intent putExtra (String name, String value)
Run Code Online (Sandbox Code Playgroud)
但是我的值的名称是什么?我选择的任何东西,还是必须是包名?谢谢您的帮助 :)
第一个活动:
Intent intent = new Intent(getApplicationContext(), SecondActivity.class);
intent.putExtra("Variable Name",string_to_be_sent);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
第二个活动:
//Receiving data inside onCreate() method of Second Activity
String value = getIntent().getStringExtra("Variable Name");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10466 次 |
| 最近记录: |