来自第一个活动代码
String value="7u1JgjTqaYo";
Intent loginintent = new Intent(MainActivity.this, Main2Activity.class).putExtra("VIDEO_KEY",value);
startActivity(loginintent);
此处有第二个活动代码
public class Main2Activity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {
Intent intent = getIntent();
String VIDEO_ID = intent.getStringExtra("VIDEO_KEY");
YouTubePlayerView youTubePlayerView;
Button btnPlay;
YouTubePlayer.OnInitializedListener onInitializedListener;
}
答案 0 :(得分:0)
这是我的MainActivity意图:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String value="7u1JgjTqaYo";
Intent loginintent = new Intent(MainActivity.this, SecondActivity.class)
.putExtra("VIDEO_KEY",value);
startActivity(loginintent);
}
这是我获得捆绑软件的SecondActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
String apiKey = getIntent().getStringExtra("VIDEO_KEY");
Toast.makeText(this, apiKey, Toast.LENGTH_SHORT).show();
}
此代码正常工作。您是否在onCreate方法中获得了捆绑软件?
希望对您有帮助