谁能帮助我的问题?
我之前的android应用使用targetSdkVersion:19然后我改成26,但是出现了如下问题。
这是 MusicManager.java 代码的片段
private static Intent musicIntent = new Intent("onet.BGMUSIC");
public void play() {
if (isBgMisicEnabled()) {
musicIntent.putExtra("bgmusic", bgMusicRes);
ctx.startService(musicIntent);
}
}
public void stop() {
ctx.stopService(musicIntent);
}
这是 BaseActivity.java 代码的片段
public static MusicManager musicMgr = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initMusic();
}
private void initMusic() {
if (musicMgr == null) {
musicMgr = new MusicManager(this);
}
playMusic();
}
protected void playMusic() {
if (musicMgr != null) {
musicMgr.play();
}
}
protected void stopMusic() {
if (musicMgr != null) {
musicMgr.stop();
}
}
这是 WelcomeActivity.java 代码的片段
@Override
protected void playMusic() {
if (musicMgr != null) {
musicMgr.setBgMusicRes(R.raw.welcomebg);
musicMgr.play();
}
}
private void initMusicSetting() {
ivMusic = (TextView) findViewById(R.id.music);
setGameMusic();
if (musicMgr != null) {
musicMgr.setBgMisicEnabled(LevelCfg.globalCfg.isGameBgMusic());
}
}
这是 Manifest.xml 代码的片段
<service
android:name="onet.sound.MusicService"
android:exported="false" >
<intent-filter>
<action android:name="onet.BGMUSIC" />
<category android:name="android.intent.category.default" />
</intent-filter>
</service>