「android開発」Activityから別のActivityを起動させるデータ(IntentとBundle)を渡す方法

方法1
intent = new Intent(MainActivity.this,Second.class);
bundle = new Bundle();
bundle.putString(“startnews24", ed_content.getText().toString());
intent.putExtras(bundle);
startActivity(intent);
//受信処理
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
tv_show.setText(bundle.getString(“startnews24"));

方法2
intent = new Intent();
intent.setClass(MainActivity.this,Second.class);
intent.putExtra(“key", “dash");
startActivity(intent);
//受信処理
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
String name = bundle.getString(“key");
tv_show.setText(name);

Android

Posted by arkgame