linphone-android/src/org/linphone/OutgoingCallReceiver.java
2010-07-09 12:19:53 +02:00

61 lines
2.1 KiB
Java

/*
OutgoingCallReceiver.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.preference.PreferenceManager;
public class OutgoingCallReceiver extends BroadcastReceiver {
public static String TAG = ";0000000";
@Override
public void onReceive(Context context, Intent intent) {
String to = intent.getStringExtra("android.intent.extra.PHONE_NUMBER");
//do not catch ussd codes
if (to.contains("#"))
return;
if (!to.contains(TAG)) {
if (LinphoneService.isready() && LinphoneService.instance().getLinphoneCore().getDefaultProxyConfig()==null) {
//just return
return;
}
setResult(Activity.RESULT_OK,null, null);
Intent lIntent = new Intent();
// 1 check config
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.pref_handle_outcall_key), false)) {
//start linphone directly
lIntent.setClass(context, LinphoneActivity.class);
} else {
//start activity chooser
lIntent.setAction(Intent.ACTION_CALL);
}
lIntent.setData(Uri.parse("tel://"+to+TAG));
lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(lIntent);
} else {
setResult(Activity.RESULT_OK,to.replace(TAG, ""),null);
}
}
}