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

Android Studio Widget influence In main acitivty
Dialog being called from listview adapter throwing Unable to add window — token null is not for an application
How could I change this hardcoded data to data from my database?
How to copy an image file in android studio by code
Get extra from child activity
JSON structure for a chat based on the official example is missing something
appcompat-v7 abc_alert_dialog_material.xml Lint error
What tools are available to test JobScheduler?
Android, Attempting to view a PDF within my Xamarin android application using muPDF
Command 'react-native run-android' got error
Get Persistable SD Cad write Permission using SAF
android RxJava Observable.from to post to a service
Android two way binding with Integer type causes databinding does not exist
Soft Keyboard disable
How to set the datepicker date with a certain date
how to get account type when login spotify with android sdk

Categories

HOME
batch-file
notepad++
eclipse
google-cloud-platform
polymer
apache-flink
github-for-windows
formal-languages
mysql-workbench
carousel
google-cloud-datalab
nstableheaderview
pattern-matching
syntaxnet
pcl-crypto
openstreetmap
enthought
watson-conversation
endpoint
gource
parameter-passing
screen-readers
glyphicons
esoteric-languages
nim
guzzle
question2answer
react-toolbox
interpreter
tiki-wiki
mat
twiml
finagle
corenlp-server
aws-codecommit
weather
testbed
r-grid
gojs
installshield-le
pdw-file-browser
browser-extension
numpy-broadcasting
salesforce-communities
z-notation
preloader
procfile
snapchat
optimizely
lampp
tinymce-3
colorbar
backbone-collections
pdf-conversion
reshape
universal-analytics
branch-prediction
stax
myspace
mongodb-php
hclust
dimension
fuzzywuzzy
relativelayout
xenomai
lazybones
opserver
visual-sourcesafe-2005
mod-proxy
iced-coffeescript
typemock
entity-framework-4.3
ssis-data-flow
sonarqube-5.0
formview
machine-instruction
paw
wcm
nsmenu
jqmodal
ignite-ui
ora-00904
codeplex
gnumeric
gae-quotas
amslidemenu
gwt-openlayers
notorm
gtm-oauth2
beaker-testing
fb.ui
wimax
expression-blend-4
u2netdk
clrstoredprocedure
w3c-geolocation
collectionviewsource
spread
windows-identity
wysiwym
wspbuilder

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App