List of usage examples for android.content Intent ACTION_NEW_OUTGOING_CALL
String ACTION_NEW_OUTGOING_CALL
To view the source code for android.content Intent ACTION_NEW_OUTGOING_CALL.
Click Source Link
From source file:com.doplgangr.secrecy.OutgoingCallReceiver.java
@Override public void onReceive(final Context context, Intent intent) { // Gets the intent, check if it matches our secret code if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction()) && intent.getExtras() != null) { Intent launcher = new Intent(context, MainActivity_.class); //These flags are added to make the new mainActivity in the home stack. //i.e. back button returns to home not dialer. launcher.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME); String phoneNumber = intent.getExtras().getString(android.content.Intent.EXTRA_PHONE_NUMBER); if (Pref.OpenPIN().exists()) if (("*#" + Pref.OpenPIN().get()).equals(phoneNumber)) // Launch the main app!! launchActivity(context, launcher); }/*w w w . j a va2s . c om*/ }
From source file:org.easyaccess.phonedialer.CallStateService.java
@Override public void onCreate() { telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); callStateListener = new CallStateListener(); callState = telephonyManager.getCallState(); telephonyManager.listen(callStateListener, PhoneStateListener.LISTEN_CALL_STATE); callState = telephonyManager.getCallState(); broadcaster = LocalBroadcastManager.getInstance(this); tts = new TextToSpeech(this, this); this.bReceiver = new BroadcastReceiver() { @Override//from w w w . jav a 2 s. c o m public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Utils.INCOMING_CALL)) { /** * Extentia : * As per the security guidelines third party apps can't receive/answer call programmatically * unless its a system app. So user must need to use default app to receive/answer call. * Hiding below piece of code to display default app to answer call. * * */ // cxt = context; // String number = intent.getStringExtra("message"); // callingDetails = new ContactManager(getBaseContext()) // .getNameFromNumber(number); // // play ringtone // // get custom ringtone // playRingtone(number); // // announce number // // Display Calling Activity in order to receive key events // Utils.callingDetails = callingDetails; // myIntent = new Intent(getBaseContext(), CallingScreen.class); // myIntent.putExtra("type", Utils.INCOMING); // myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // // new Handler().postDelayed(new Runnable() { // @Override // public void run() { // startActivity(myIntent); // } // }, 2000); } else if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction())) { // new outgoing call final String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); callingDetails = new ContactManager(getBaseContext()).getNameFromNumber(number); Utils.callingDetails = callingDetails; } } }; LocalBroadcastManager.getInstance(this).registerReceiver((this.bReceiver), new IntentFilter(Utils.INCOMING_CALL)); LocalBroadcastManager.getInstance(this).registerReceiver((this.bReceiver), new IntentFilter("android.intent.action.PHONE_STATE")); if (Accelerometer.isSupported(this)) { // Start Accelerometer Listening Accelerometer.startListening(this); } MediaButton_Receiver mediaReceiver = new MediaButton_Receiver(); IntentFilter filterVolume = new IntentFilter(Intent.ACTION_MEDIA_BUTTON); registerReceiver(mediaReceiver, filterVolume); SettingsContentObserver mSettingsContentObserver = new SettingsContentObserver(this, new Handler()); getApplicationContext().getContentResolver().registerContentObserver( android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserver); }
From source file:org.linphone.LinphoneService.java
public void initFromConf() throws LinphoneConfigException, LinphoneException { // traces//from w w w. j a v a 2 s . co m boolean lIsDebug = mPref.getBoolean(getString(R.string.pref_debug_key), false); LinphoneCoreFactory.instance().setDebugMode(lIsDebug); try { // Configure audio codecs enableDisableAudioCodec("speex", 32000, R.string.pref_codec_speex32_key); enableDisableAudioCodec("speex", 16000, R.string.pref_codec_speex16_key); enableDisableAudioCodec("speex", 8000, R.string.pref_codec_speex8_key); enableDisableAudioCodec("iLBC", 8000, R.string.pref_codec_ilbc_key); enableDisableAudioCodec("GSM", 8000, R.string.pref_codec_gsm_key); enableDisableAudioCodec("PCMU", 8000, R.string.pref_codec_pcmu_key); enableDisableAudioCodec("PCMA", 8000, R.string.pref_codec_pcma_key); // Configure video codecs for (PayloadType videoCodec : mLinphoneCore.listVideoCodecs()) { enableDisableVideoCodecs(videoCodec); } if (!mPref.getString(getString(R.string.pref_handle_outcall_key), OutgoingCallReceiver.key_on_demand) .equalsIgnoreCase(OutgoingCallReceiver.key_off)) { IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); lFilter.setPriority(0); lFilter.addAction(Intent.ACTION_NEW_OUTGOING_CALL); if (mOutgoingCallReceiver == null) { mOutgoingCallReceiver = new OutgoingCallReceiver(); } registerReceiver(mOutgoingCallReceiver, lFilter); } else if (mOutgoingCallReceiver != null) { unregisterReceiver(mOutgoingCallReceiver); mOutgoingCallReceiver = null; } mLinphoneCore.enableEchoCancellation( mPref.getBoolean(getString(R.string.pref_echo_cancellation_key), false)); } catch (LinphoneCoreException e) { throw new LinphoneConfigException(getString(R.string.wrong_settings), e); } boolean isVideoEnabled = mPref.getBoolean(getString(R.string.pref_video_enable_key), false); mLinphoneCore.enableVideo(isVideoEnabled, isVideoEnabled); // 1 read proxy config from preferences String lUserName = mPref.getString(getString(R.string.pref_username_key), null); lUserName = username; if (lUserName == null || lUserName.length() == 0) { throw new LinphoneConfigException(getString(R.string.wrong_username)); } String lPasswd = mPref.getString(getString(R.string.pref_passwd_key), null); lPasswd = password; if (lPasswd == null || lPasswd.length() == 0) { throw new LinphoneConfigException(getString(R.string.wrong_passwd)); } String lDomain = mPref.getString(getString(R.string.pref_domain_key), null); lDomain = domain; if (lDomain == null || lDomain.length() == 0) { throw new LinphoneConfigException(getString(R.string.wrong_domain)); } String lStun = mPref.getString(getString(R.string.pref_stun_server_key), null); // stun server mLinphoneCore.setStunServer(lStun); mLinphoneCore.setFirewallPolicy( (lStun != null && lStun.length() > 0) ? FirewallPolicy.UseStun : FirewallPolicy.NoFirewall); // auth mLinphoneCore.clearAuthInfos(); LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(lUserName, lPasswd, null); mLinphoneCore.addAuthInfo(lAuthInfo); // proxy mLinphoneCore.clearProxyConfigs(); String lProxy = mPref.getString(getString(R.string.pref_proxy_key), null); if (lProxy == null || lProxy.length() == 0) { lProxy = "sip:" + lDomain; } if (!lProxy.startsWith("sip:")) { lProxy = "sip:" + lProxy; } // get Default proxy if any LinphoneProxyConfig lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig(); String lIdentity = "sip:" + lUserName + "@" + lDomain; try { if (lDefaultProxyConfig == null) { lDefaultProxyConfig = LinphoneCoreFactory.instance().createProxyConfig(lIdentity, lProxy, null, true); mLinphoneCore.addProxyConfig(lDefaultProxyConfig); mLinphoneCore.setDefaultProxyConfig(lDefaultProxyConfig); } else { lDefaultProxyConfig.edit(); lDefaultProxyConfig.setIdentity(lIdentity); lDefaultProxyConfig.setProxy(lProxy); lDefaultProxyConfig.enableRegister(true); lDefaultProxyConfig.done(); } lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig(); if (lDefaultProxyConfig != null) { // prefix String lPrefix = mPref.getString(getString(R.string.pref_prefix_key), null); if (lPrefix != null) { lDefaultProxyConfig.setDialPrefix(lPrefix); } // escape + lDefaultProxyConfig .setDialEscapePlus(mPref.getBoolean(getString(R.string.pref_escape_plus_key), false)); // outbound proxy if (mPref.getBoolean(getString(R.string.pref_enable_outbound_proxy_key), false)) { lDefaultProxyConfig.setRoute(lProxy); } else { lDefaultProxyConfig.setRoute(null); } } // init network state ConnectivityManager lConnectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo lInfo = lConnectivityManager.getActiveNetworkInfo(); mLinphoneCore.setNetworkReachable(lInfo != null ? lConnectivityManager.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED : false); } catch (LinphoneCoreException e) { throw new LinphoneConfigException(getString(R.string.wrong_settings), e); } }