You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Current »

Documentation related to Android-5.1 based Firmware releases 

 

Documentation related to Android-4.2.2 based Firmware releases 

 

 

In order to use the off/on hook events of the handset for 3rd party Applications, please check out codes below:

public void onResume() {
    IntentFilter intentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
    registerReceiver(mMyHeadsetObserver, intentFilter);
    super.onResume();
}

public void onDestroy() {
    unregisterReceiver(mMyHeadsetObserver);
    super.onDestroy();
}

private class MyHeadsetObserver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_HEADSET_PLUG)) {
            int state = intent.getIntExtra("state", -1);
            switch (state) {
                case 0:
                    mTextView.setText("Handset / Headset: Disconnected");
                    break;
                case 1:
                    mTextView.setText("Handset / Headset: Connected");
                    break;
            }
        }
    }
}

In AndroidManifest.xml
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

Remark: If problems raising up after the update to a Android-5.1 based firmware, please be aware, that the virtual machine was changed from "dalvik" (in jellybean) to "art" (in lollipop) which is more strict in case of native code (https://developer.android.com/guide/practices/verifying-apps-art.html). Unfortunately it is not possible to switch back to dalvik in Lollipop.

  • No labels