所以我知道 myIntent
是未定义的,与此类的构造函数有关,但我对 Java 太陌生,无法找出问题所在,也许你能帮忙?
serviceIntent = new Intent(this, myPlayService.class);
编码:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
podcastPlayerLayout = inflater.inflate(R.layout.activity_podcast_player, container, false);
try {
serviceIntent = new Intent(this, myPlayService.class);
// --- set up seekbar intent for broadcasting new position to service ---
intent = new Intent(BROADCAST_SEEKBAR);
initViews();
setListeners();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
e.getClass().getName() + " " + e.getMessage(),
Toast.LENGTH_LONG).show();
}
//Adding Listener to button
streamSetButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
fileStreamAdress = streamSetButton.getText().toString();
playPauseButtonClicked();
}
});
playPauseButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
fileStreamAdress = streamSetButton.getText().toString();
playPauseButtonClicked();
}
});
// Inflate the layout for this fragment
return podcastPlayerLayout;
}