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

White screen partially covers my content in webview android
RadioButton vs Spinner
How to refresh the listview content in timely manner
google maps android api error authorization failure app displaying blank map
Image from container is going down on action
Different font width in #string of TextView
How to retrieve Bitmap with Picasso or Universal Android Loader?
Android parse many json arrays
Selecting notification in same activity as PendingIntent, but different ViewPage
Can't get upload dialog to work
google Analytics V4 cannot be imported?
Menus are not Showing up in ActionBar using AppCompat Library
How to set the row height of listview to fit the image size
Multiple ForeignCollection of same type in ORMLite
Unable to find explicit activity class that isn't a class
Is this a Digital Compass or Unity limitation?

Categories

HOME
embedded
swt
interface
components
graphics
knitr
r-googlesheets
newrelic
scripting
polling
google-admin-sdk
elasticsearch-5
augeas
dkim
mod-security
pybossa
altera
google-maps-autocomplete
ember-cli
flask-sqlalchemy
opentk
angularjs-components
asymptotic-complexity
spotipy
bringtofront
cppreference
realm-mobile-platform
livelink
paragraph
erb
android-gridview
hunspell
reason
google-knowledge-graph
gdata
ogc
movilizer
sharp-snmp
microsoft-metro
flask-login
facebook-social-plugins
double-click
fwrite
serde
semantic-logging
otp
payload
xcode-server
x-tag
cifilter
boost-serialization
halcon
contentcontrol
assertion
tfs-workitem
pax-exam
uncompress
liquid-layout
telepat
j-security-check
mass-assignment
document-repository
android-cookiemanager
primitive-types
deform
machine-instruction
unix-socket
jjaql
file-not-found
vbe
xmltodict
eclipse-kepler
ie8-compatibility-mode
oocss
gpars
workitem
jquery-1.9
diem
virtual-pc
android-sdk-2.3
resource-management
patricia-trie
midlet
dajaxice
pyunit
database-create
predicatebuilder
strsep
load-time
updatesourcetrigger
globals
opml
commercial-application

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