Date: Fri, 29 Mar 2024 16:15:37 +0100 (CET) Message-ID: <673728207.3731.1711725337941@teamwork> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3730_653878008.1711725337940" ------=_Part_3730_653878008.1711725337940 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
In order to use the off/on hook events of the handset for 3rd pa= rty Applications, please check out codes below:
Maxwell Phone app is using com.maxwell.action.CMBS.CRADLE.EVENT for on/o= ff hook events.
private= static final String ACTION_CRADLE_EVENT =3D "com.maxwell.action.CMBS.CRADL= E.EVENT";=20 private static final int EVENT_OFF_HOOK =3D 1;=20 private static final int EVENT_ON_HOOK =3D 2; public void onResume() { IntentFilter intentFilter =3D new IntentFilter(ACTION_CRADLE_EVENT); registerReceiver(mMyHandsetObserver, intentFilter); super.onResume();=20 } =20 public void onDestroy() { unregisterReceiver(mMyHandsetObserver); super.onDestroy();=20 } =20 private class MyHandsetObserver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(ACTION_CRADLE_EVENT)) { int state =3D intent.getIntExtra("EXTRA_CRADLE_EVENT_TYPE", -1= ); switch (state) { case EVENT_ON_HOOK: mTextView.setText("Handset: Disconnected"); break; case EVENT_OFF_HOOK: mTextView.setText("Handset: Connected"); break; } } } } In AndroidManifest.xml <uses-permission android:name=3D"android.permission.MODIFY_AUDIO_SETTING= S" />
Remark: If problems raising up after the update to a Android-5.1 based f= irmware, please be aware, that the virtual machine was changed from "dalvik= " (in jellybean) to "art" (in lollipop) which is more strict in case of nat= ive code (https://developer= .android.com/guide/practices/verifying-apps-art.html). Unfortunately it= is not possible to switch back to dalvik in Lollipop.