Android Question android.intent.action.MEDIA_BUTTON again...

lemonisdead

Well-Known Member
Licensed User
Hello,

I have made some tests trying to detect a press on the small button included on some wired headsets.

When the activity is not paused, I get the activity keypress with value 79 each time. But when trying to detect it from a service using the code below, the service never starts. I am sorry as I am not still understanding the intent process so perhaps my code is not for this button ?

B4X:
AddReceiverText(MyService, <intent-filter>
    <action android:name="android.intent.action.MEDIA_BUTTON" />
    </intent-filter>)

Many thanks :)
 

lemonisdead

Well-Known Member
Licensed User
Here is what I did (really nothing)..

I have noticed this too, reason why I have always thought to have found :
- uninstall your app
- compile it and install it => it won't work
- compile it and install it again => it works


sc.png
 

Attachments

  • Headset.zip
    10.1 KB · Views: 228
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Here is what I did (really nothing)..

I have noticed this too, reason why I have always thought to have found :
- uninstall your app
- compile it and install it => it won't work
- compile it and install it again => it works



Oh man, does not work on my sony experia, maybe my phone is too old. But you have it working now on your phone ?
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Yes I do (screenshot on the previous post). Your phone is not too old. Works on the WIKO Cink too.
The curious (odd ?) behavior is this one: when I first install the app after having uninstalled it, it takes a moment before to receive but when I install it over it then it works immediately).

But for now, even after having restarted, it works
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Yes I do (screenshot on the previous post). Your phone is not too old. Works on the WIKO Cink too.
The curious (odd ?) behavior is this one: when I first install the app after having uninstalled it, it takes a moment before to receive but when I install it over it then it works immediately).

But for now, even after having restarted, it works


WOW ! I am stumped that is does not work for me ???? I hope you can use the code in you other project that you mention earlier in the thread. :rolleyes:
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
You are kind John but it was for a specific client so that project is far behind :)
Please do you confirm that when you install KeyCut and your app is installed, your app immediately receives the intent ?
 
Upvote 0

stari

Active Member
Licensed User
Yes I do (screenshot on the previous post). Your phone is not too old. Works on the WIKO Cink too.
The curious (odd ?) behavior is this one: when I first install the app after having uninstalled it, it takes a moment before to receive but when I install it over it then it works immediately).

But for now, even after having restarted, it works
Yes I do (screenshot on the previous post). Your phone is not too old. Works on the WIKO Cink too.
The curious (odd ?) behavior is this one: when I first install the app after having uninstalled it, it takes a moment before to receive but when I install it over it then it works immediately).

But for now, even after having restarted, it works
Now uninstal KeyCut. I have the same situation, but without KeyCut media button is not received.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
You are kind John but it was for a specific client so that project is far behind :)
Please do you confirm that when you install KeyCut and your app is installed, your app immediately receives the intent ?

Even with Keycut installed I do not get the intent received, my phone does not like me !
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
It only works when keycut is installed ?
No : it was my first observation

Please could you try the one attached (my problem is that it works each time now) ?
 

Attachments

  • Headset.zip
    10.3 KB · Views: 302
Upvote 0

stari

Active Member
Licensed User
It only works when keycut is installed ?
Yes. If you restart phone, normaly, Keycut wil start on PWR ON. So you must uninstal and kill app with Advanced Task Killer, otherwise the service program keep runnung. You must also uninstal and stop your own service program.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
No : it was my first observation

Please could you try the one attached (my problem is that it works each time now) ?


Just tried that version, no KeyCut installed, phone restarted,uninstalled app, re-installed app, run app, click media button, no vibrate, no intent, and yet it works for you all the time ?

I see the additions in the manifest file.
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
and yet it works for you all the time ?
Yes even if I reboot the phone.

But, I would like to be the clearest as possible :
- no KeyCut installed, your app not installed, phone restarted
- I compile in Release(obfuscated) and install via USB : the app opens showing the Main Activity and it does not work immediately (it takes a while if I wait but I don't wait now)
- I compile in Realease(obfuscated) and install via USB over the just installed version. The Main Activity is shown, I press the MEDIA_BUTTON and it works
- I restart the phone and it works all the time. I have tried 10 times to be sure and tested on all the models I had listed previously.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
YESSSSS !!!! Got it working. I had to disable SmartConnect on Sony Phone and now I get the intents, thanks @lemonisdead and @star
Yes even if I reboot the phone.

But, I would like to be the clearest as possible :
- no KeyCut installed, your app not installed, phone restarted
- I compile in Release(obfuscated) and install via USB : the app opens showing the Main Activity and it does not work immediately (it takes a while if I wait but I don't wait now)
- I compile in Realease(obfuscated) and install via USB over the just installed version. The Main Activity is shown, I press the MEDIA_BUTTON and it works
- I restart the phone and it works all the time. I have tried 10 times to be sure and tested on all the models I had listed previously.

Just got it working, sort of, had to disable smart connect and some other apps on the Sony Phone, I managed 1 good click, then I did a long click and google search come up, at this point google now has control, I believe we need to register the intent via the audio_event, wich we are doing. Have you tried this ?
 
Upvote 0

stari

Active Member
Licensed User
YESSSSS !!!! Got it working. I had to disable SmartConnect on Sony Phone and now I get the intents, thanks @lemonisdead and @star


Just got it working, sort of, had to disable smart connect and some other apps on the Sony Phone, I managed 1 good click, then I did a long click and google search come up, at this point google now has control, I believe we need to register the intent via the audio_event, wich we are doing. Have you tried this ?
OK, i'm glad !
 
Upvote 0
Top