public boolean startBusytone(final String busytoneUriType){
  if (busytoneUriType.isEmpty()) {
    return false;
  }
  try {
    Log.d(TAG,"startBusytone(): UriType=" + busytoneUriType);
    if (mBusytone != null) {
      if (mBusytone.isPlaying()) {
        Log.d(TAG,"startBusytone(): is already playing");
        return false;
      }
 else {
        stopBusytone();
      }
    }
    Uri busytoneUri;
    Map data=new HashMap<String,Object>();
    data.put("name","mBusytone");
    if (busytoneUriType.equals("_DTMF_")) {
      mBusytone=new myToneGenerator(myToneGenerator.BUSY);
      mBusytone.startPlay(data);
      return true;
    }
 else {
      busytoneUri=getBusytoneUri(busytoneUriType);
      if (busytoneUri == null) {
        Log.d(TAG,"startBusytone(): no available media");
        return false;
      }
    }
    mBusytone=new myMediaPlayer();
    data.put("sourceUri",busytoneUri);
    data.put("setLooping",false);
    data.put("audioStream",AudioManager.STREAM_VOICE_CALL);
    setMediaPlayerEvents((MediaPlayer)mBusytone,"mBusytone");
    mBusytone.startPlay(data);
    return true;
  }
 catch (  Exception e) {
    Log.d(TAG,"startBusytone() failed");
    Log.d(TAG,e.getMessage());
    return false;
  }
}

public boolean startBusytone ( final String busytoneUriType ) { if ( busytoneUriType . isEmpty ( ) ) { return false ; } try { Log . d ( TAG , "startBusytone(): UriType=" + busytoneUriType ) ; if ( mBusytone != null ) { if ( mBusytone . isPlaying ( ) ) { Log . d ( TAG , "startBusytone(): is already playing" ) ; return false ; } else { stopBusytone ( ) ; } } Uri busytoneUri ; Map data = new HashMap < String , Object > ( ) ; data . put ( "name" , "mBusytone" ) ; if ( busytoneUriType . equals ( "_DTMF_" ) ) { mBusytone = new myToneGenerator ( myToneGenerator . BUSY ) ; mBusytone . startPlay ( data ) ; return true ; } else { busytoneUri = getBusytoneUri ( busytoneUriType ) ; if ( busytoneUri == null ) { Log . d ( TAG , "startBusytone(): no available media" ) ; return false ; } } mBusytone = new myMediaPlayer ( ) ; data . put ( "sourceUri" , busytoneUri ) ; data . put ( "setLooping" , false ) ; data . put ( "audioStream" , AudioManager . STREAM_VOICE_CALL ) ; setMediaPlayerEvents ( ( MediaPlayer ) mBusytone , "mBusytone" ) ; mBusytone . startPlay ( data ) ; return true ; } catch ( Exception e ) { Log . d ( TAG , "startBusytone() failed" ) ; Log . d ( TAG , e . getMessage ( ) ) ; return false ; } }
this is part of start ( ) process . busytoneuritype must not empty . empty means do not play . return false to indicate play tone failed and should be stop ( ) immediately otherwise , it will stop ( ) after a tone completed .
