Earset Connectivity Broadcast Processing
This commit is contained in:
parent
1981caf7c3
commit
3f33835f15
1 changed files with 34 additions and 0 deletions
|
@ -24,8 +24,10 @@ import android.app.Activity;
|
|||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
|
@ -115,6 +117,7 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
|
|||
private boolean isVideoCallPaused = false;
|
||||
private Dialog dialog = null;
|
||||
private static long TimeRemind = 0;
|
||||
private HeadsetReceiver headsetReceiver;
|
||||
|
||||
private LinearLayout callsList, conferenceList;
|
||||
private LayoutInflater inflater;
|
||||
|
@ -149,6 +152,12 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
|
|||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
setContentView(R.layout.call);
|
||||
|
||||
//Earset Connectivity Broadcast Processing
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction("android.intent.action.HEADSET_PLUG");
|
||||
headsetReceiver = new HeadsetReceiver();
|
||||
registerReceiver(headsetReceiver, intentFilter);
|
||||
|
||||
isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
|
||||
|
||||
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
|
||||
|
@ -1748,4 +1757,29 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
|
|||
};
|
||||
mTimer.scheduleAtFixedRate(mTask, 0, 1000);
|
||||
}
|
||||
|
||||
////Earset Connectivity Broadcast innerClass
|
||||
public class HeadsetReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) {
|
||||
if (intent.hasExtra("state")) {
|
||||
switch (intent.getIntExtra("state", 0)) {
|
||||
case 0:
|
||||
LinphoneManager.getInstance().routeAudioToSpeaker();
|
||||
isSpeakerEnabled = true;
|
||||
speaker.setEnabled(true);
|
||||
refreshInCallActions();
|
||||
break;
|
||||
case 1:
|
||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||
isSpeakerEnabled = false;
|
||||
speaker.setEnabled(false);
|
||||
break;
|
||||
}
|
||||
refreshInCallActions();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue