public class MediaPlayerActivity extends AppCompatActivity {
DatabaseReference mrootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference mlinkRef = mrootRef.child(link);
PlayerView playerView;
SimpleExoPlayer exoPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
if (extras != null) {
String link = extras.getString("key");
}
非常感谢您的帮助!
答案 0 :(得分:1)
变量链接在if语句的作用域中定义,并且只能在其中使用。
public class MediaPlayerActivity extends AppCompatActivity {
DatabaseReference mrootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference mlinkRef;
PlayerView playerView;
SimpleExoPlayer exoPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
if (extras != null) {
String link = extras.getString("key");
mlinkRef = mrootRef.child(link);
}