Android Question MediaSessions

Jmu5667

Well-Known Member
Licensed User
Longtime User

stevel05

Expert
Licensed User
Longtime User
I can't seem to find the MediaSessionCompat Class in the latest android-support-v4 jar file. Does anyone have any idea where it may be? The documentation doesn't say.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
OK that's because there is a new V4 file in the V7 folder! Now I've found it:)
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello
Thanks again for all the work and research you did. Please, don't take it bad it is not a request at all but, on the Nexus 7 and Wiko mentioned above, I don't get any more results (even after having used your latest code). As I wasn't really working on it (but more testing for John), I will wait to see if he has got the same results.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Just tried it again, it's still working here. Did you add the line:
B4X:
session.RunMethod("setFlags",Array(3))
in service create?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I just tried it on my Sony Experia (Android 5.1.1) it work's intermittently in Debug mode, but seems OK in release mode.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Good Morning all,

I picked up a HTC ONE M7 yesterday, it has Lillipop 5.02 (21) in it. attached is a simple program using steve's sample code. I have MiKey in the headphone socket and the intents are being captured. It appears to work quite well in release mode. Please try it on your devices. There is no entry in the manifest file for the media which is nice.

I had a look at which discuss's the mediaSessionComat class. As steve mentioned there is a JAR for this and it will enabled backward campatability for API < 21 to handle the media button capture. This is the ideal solution. I am not too sure how to work with the additionalJar etc.

Regards

John

@lemonisdead
@Erel
@stevel05
 

Attachments

  • headphone.zip
    11.2 KB · Views: 398
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Hi John. I have looked at this today, and it is working with compat, but it's very unreliable. I'll have a look tomorrow and see if it can be improved. I think something may be stealing the clicks. Sometimes it records all of them, sometimes one or two and othertimes none.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Can you try this out, I don't think it's my hardware that is causing the issue, but I don't want to be chasing it down if it is.
 

Attachments

  • MSC.zip
    9.7 KB · Views: 386
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Morning Steve

I get the following when I compile. Which jar file are you using ?

B4X:
B4A version: 5.50
Parsing code.  (0.00s)
Compiling code.  (0.04s)
   
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.  (0.07s)
Generating R file.  (0.69s)
Compiling generated Java code.  Error
javac 1.8.0_40-ea
src\com\stevel05\msc\starter.java:3: error: package android.support.v4.media.session.MediaSessionCompat does not exist
import android.support.v4.media.session.MediaSessionCompat.*;
^
Note: src\com\stevel05\msc\starter.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

upload_2016-1-23_9-7-20.png


This is the one that I have and I have it in in 'C:\Users\John Murphy\Documents\B4A\Additional Libraries'

Regards

John.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Sorry, yes I forgot to say, it the android-support-v4.jar that will be in the v7 support directory of your SDK.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Hi John, It's in the Android support library V23.1.1, you'll need to update it through the SDK manager, It should then be there.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi Steve

Thanks for the update. I did find a support-v4-23.1.1-sources.jar (google search) buried in the SDK folders. This is what I get when I compile:

B4X:
B4A version: 5.50
Parsing code.  (0.00s)
Compiling code.  (0.02s)
   
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.  (0.00s)
Generating R file.  (0.03s)
Compiling generated Java code.  Error
javac 1.8.0_40-ea
C:\Users\John Murphy\Documents\B4A\Additional Libraries\support-v4-23.1.1-sources.jar(android/support/v4/media/session/MediaSessionCompat.java):41: error: package android.support.annotation does not exist
import android.support.annotation.IntDef;
  ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

Regards

John.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Hi John,

It's not the -sources jar you need. On my system it's in the SDK folder: android-sdk\extras\android\support\v7\appcompat\libs\android-support-v4.jar.

Steve
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi Steve

Tried that, still the same result

B4A version: 5.50
Parsing code. (0.00s)
Compiling code. (0.10s)
Compiling layouts code. (0.03s)
Generating R file. (0.30s)
Compiling debugger engine code. (1.03s)
Compiling generated Java code. Error
javac 1.8.0_40-ea
src\com\stevel05\msc\starter.java:3: error: package android.support.v4.media.session.MediaSessionCompat does not exist
import android.support.v4.media.session.MediaSessionCompat.*;
^
Note: src\com\stevel05\msc\starter.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

upload_2016-1-25_13-9-11.png



This is the folder that you are referring, are yours the same ?

Regards

John.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Yes looks the same size at least. Did you overwrite the previous one in your additional librariess folder?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Just a thought, do you have an android-support-v4.jar in your core libraries folder?
 
Upvote 0
Top