Android Question Java return AudioManager

Robert Valentino

Well-Known Member
Licensed User
Longtime User
how do I return a javaobject of the type AudioManager

I need to get back AudioManager so I can pass it into a routine to create a RemoteControlClient


B4X:
     Dim jo                      As JavaObject
     Dim joAudioManager As JavaObject
       
     jo.InitializeContext   

     joAudioManager =  jo.RunMethod("GetAudioManager", Null)


#If JAVA
import android.app.PendingIntent;
import android.content.*;
import android.media.*;
import android.media.RemoteControlClient;

public AudioManager GetAudioManager {
       AudioManager mAudioManager;
       
       mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
       
       return mAudioManager;
}
#end if

I've tried

B4X:
public JavaObject GetAudioManager

Public JavaObject GetAudioManager(void)

Public GetAudioManager(void) as JavaObject

ALL fail at compile time

BobVal
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Finally figured it out

public AudioManager MakeAudioManager() {
AudioManager mAudioManager;

mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

return mAudioManager;
}
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…