can anyone help my problem?
My previous android application used targetSdkVersion: 19 then I changed to 26, but there was a problem like the following.
This is the snippet of the MusicManager.java code
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);
}
This is the snippet of the BaseActivity.java code
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();
}
}
This is the snippet of the WelcomeActivity.java code
@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());
}
}
This is the snippet of the Manifest.xml code
<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>
I believe you must set the package beforehand like :
or create the intent like:
as illustrated here: Service Intent must be explicit: Intent