android


detect outgoing/incoming number android 5.1.1 lollipop programmatically


Trying to detect outgoing or incoming number on (Lollipop 5.1.1) OnePlus two oxygen os
tried many ways with googling but cant success
String number = intent.getStringExtra("android.intent.extra.PHONE_NUMBER");
String number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Permission in manifest
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
using the bellow code for getting incoming or outgoing number
public class callRecorderReceiver extends BroadcastReceiver {
private static String TAG = "CallRecorderReceiver";
private Context mContext = null;
static long start_time, end_time;
String callType = "";
#Override
public void onReceive(Context context, Intent intent) {
this.mContext = context;
String action = intent.getAction();
String extraState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
Log.d(TAG, "Action:" + action);
Log.d(TAG, "ExtraState:" + extraState);
String number = intent.getStringExtra("android.intent.extra.PHONE_NUMBER");
if (number == null || number.equalsIgnoreCase("")) {
number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
}
if (extraState.equalsIgnoreCase("OFFHOOK")) {
if (number != null && !number.equalsIgnoreCase("")) {
number = number;
temp_data.current_number = "" + number;
}
} else if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) {
if (number != null && !number.equalsIgnoreCase("")) {
callType = "outgoing";
if (!((number.contains("*") && number.contains("#")) ))) {
Log.d("outgoing CallTo:", number);
}
}
} else if (action.equals("android.intent.action.PHONE_STATE")) {
try {
String incomingNumber = intent.getStringExtra("incoming_number");
if (intent.getStringExtra("state").equals(TelephonyManager.EXTRA_STATE_RINGING)) {
Log.d("ringing ", "incomingNumber " + incomingNumber);
} else if (intent.getStringExtra("state").equals(TelephonyManager.EXTRA_STATE_IDLE)) {
Log.d("idle ", incomingNumber);
} else if (intent.getStringExtra("state").equals(TelephonyManager.EXTRA_STATE_OFFHOOK)))) {
Log.d("State:", "current_state:" + temp_data.current_state);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
check this link....[http://bitgriff.blogspot.in/2013/01/detecting-incoming-and-outgoing-phone.html] i wish it will hwlp you

Related Links

how to remove the close button from popupkeyboard in android
Contact intent with multiple select
ImageButton is missing when drawable-v21 is added
Android: Is there a way to cache web content when offline?
Google Play - unable to deactivate older APK with lower API support
Android studio very slow gradle build
Inserting into wrong table database Android
How in Android Studio see the number of running services in the application?
Calabash android - HTTPClient::KeepAliveDisconnected
Android webview, responsive web page is not shown properly in some devices
Can't find the generated APK file
Dagger2 singleton annotation not working
How to properly clear the whole backstack ( without popping to the top element )?
how can i call fragment from listadapter
possible bug for Google play game service package name?
How to make a text center top and other text center of screen in LinearLayout?

Categories

HOME
fabricjs
facebook-oauth
c++11
youtube-data-api-v3
sh
sitecore
socket.io
gradient
rendering
onclick
gluon-mobile
character
vimdiff
github-enterprise
google-form
comsol
enterprise-architect
mongodb-csharp
google-picker
symfony-console
oledb
windows-xp
ag
kendo-mobile
moses
appirater
ceylon
paperjs
errbot
sqlpackage
sql-server-2000
fstream
reverse
getlasterror
numpy-broadcasting
protege4
python-pptx
opensmpp
android-softkeyboard
portforwarding
preloader
facebook-pixel
activeperl
modelsim
backbone-collections
git-flow
pdf-conversion
docpad
seek
preprocessor
segment-io
installshield-2010
refinerycms
mediametadataretriever
jbase
opserver
page.js
batik
jbake
filesplitting
sql-scripts
rcaller
alternate
dct
hibernate-entitymanager
gd-graph
windows-phone-8-sdk
model-driven-development
dtmf
hidapi
traceability
cascadingdropdown
idn
extreme-programming
mkv
fragmenttransaction
os.system
objectquery
stress
entity-attribute-value
workflow-services
tournament
cgbitmapcontextcreate
uipagecontrol
diagrams
folding
echo3
skype4java
feasibility
alsb
information-management
movieplayer
commercial-application

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App