android


How to distinguish calls to onReceive


I have a class
public class Receiver extends BroadcastReceiver{
// with onReceive() method(overridden)
public void onReceive(Context context, Intent intent)
{...
}
}
In my activity, I am using Receiver class to listen for broadcast.
//Block1
Intent intent = new Intent(Test.this, Receiver.class);
PendingIntent pIntent = PendingIntent.getBroadcast(Test.this, 0, intent, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, 2000, pIntent);
//Block2
IntentFilter filter= new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
mReceiver = new Receiver();
registerReceiver(mReceiver, filter);
Now, the problem is both the blocks from my activity are using same Receiver class for broadcast.
I planned to use Intent.putExtra() to detect which intent is calling to onReceive() but it is only available for Intents and not for IntentFilter .
So how do i distinguish the calls to onReceive() within onReceive() method?

Related Links

Ionic push notifications how to trigger onNotification event if app is in the background?
Cannot open activity as Dialog in Andorid
Unity Android run in background
Farsi Layout in run-time and change gravity
Implement Youtube player fragment inside other fragment
Watch emulator size of phone, how to resize?
Getting false positive while checking whether alarm manager is set
GoogleApiClient - Connected / Selected User Account
Eyes and mouth are not detected in photos captured by camera in android
React Native maps drawing directions
SugarORM : While instrumentation testing, No such table Exception
Getting updated data from realm
Fragment do not work correct after recreate process
EditText is being rendered incorrectly
Changing order in viewholder
Bonjour(IPP) vs Jetdirect-Socket Printer

Categories

HOME
oracle12c
paraview
codenvy
merge
wakanda
mstest
oracle-apex-5
composite-primary-key
package
replace
google-cloud-functions
switch-statement
iis-6
title
jquery-ui-sortable
dkim
endeca
redis-sentinel
rtf
dynatrace
zerobrane
mongodb-csharp
gruntfile
standards
mathprog
pyramid
charles
solrcloud
jquery-ias
comparator
draft-js-plugins
mount
xcode-ui-testing
ms-access-2003
handler
iis-express
boost-asio
google-cast
dotspatial
complex-numbers
zend-debugger
wacom
code-snippets
contacts
fossil
hibernate-search
graphhopper
xdocreport
metawidget
signals-slots
stringtokenizer
bindingnavigator
apollostack
builder
linter
openblas
tinkerpop
wpas
colorbar
android-testing
quicktime
d3-force-directed
filenet
pocketsphinx-android
custom-lists
envi
mongodb-php
dimension
firebase-security
observablecollection
swizzling
qiime
upx
dynamics-nav-2016
custom-errors
rewrite
roadkill-wiki
zscript
nutiteq
fits
phpldapadmin
java-security
bcache
webmatrix-3
sonarqube-5.0
teaspoon
named-parameters
personalization
mvc-editor-templates
nebula
merb
device-width
frameworkelementfactory
qtconcurrent
zope.interface
thttpd
procedures
ikimagebrowserview
mysql-error-1205
globals
tabpanel
request-headers
pagemethods
visualj#
httpcookie

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