Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Media button BroadcastReceiver Android

$
0
0

Hi,

I want to add support for remote control the audioPlayer in my Android app. In my player window I added this code:

var androidMediaButtonBR = Ti.Android.createBroadcastReceiver({
                onReceived: function(e) {
                    Ti.API.info('Handling broadcast.');
                }
            });
            Ti.Android.registerBroadcastReceiver(androidMediaButtonBR, [Ti.Android.ACTION_MEDIA_BUTTON]);

The relevant part of my tiapp.xml looks like this:

<application android:theme="@android:style/Theme.Holo.Light">
                <receiver android:name=".TiBroadcastReceiver">
                     <intent-filter android:priority="2147483647">
                        <action android:name="Ti.Android.ACTION_MEDIA_BUTTON"/>
                    </intent-filter>
                </receiver>
                <activity
                    android:configChanges="keyboardHidden|orientation"
                    android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="portrait"/>
            </application>
Although a test with a broadcastreceiver on Ti.Android.ACTION_AIRPLANE_MODE_CHANGED workes fine, I am not able to catch the button events of my headset. There isn't much information available on how to implement this in Titanium. I tested with SDK 3.1.3 and 3.2.0 on a Galaxy S3 with Android 4.1.2, without any luck. I hope some of you can point me in the right direction.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>