Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Well, I haven't had much time the last couple days, between work, Star Wars, and some family time. Finally today I got back into coding. One of the parts of this game is faking out the player, trying to make it seem like they're getting a particular phone call. I took some screenshots of the phone call UI on my phone, but one of the most important pieces is getting it to play the player's actual ringtone (as an aside: my game isn't going to work very well on the desktop!).

I had to use an adapter (similar to the suggestions on this page) to get platform-specific code for android, and tried about 15 different suggestions from Stack Overflow to get a repeating ringtone. None of them ended working, but this did:


public void playRingtone() {
 Uri defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(
           activity.getApplicationContext(), RingtoneManager.TYPE_RINGTONE);
 defaultRingtone = RingtoneManager.getRingtone(activity, defaultRingtoneUri);
 defaultRingtone.play();
}
public void keepPlayingRingtone() {
 if (defaultRingtone != null && !defaultRingtone.isPlaying()) {
 defaultRingtone.play();
 }
}

(Wow, this editor sucks)

Anyway, with the fake graphic for an incoming call, and the actual ringtone, it definitely feels like a real incoming call. We're getting somewhere!