android


Android: one handler for all runnables?


Can I use one handler in my Activity for all runnables or should I have multiple instances of Handler, each for one runnable?
You can use only one handler and to specify from where your are coming use different message.
handler.sendEmptyMessage(messagevalue); //use this to send message from different place
Now handle message
private Handler handler=new Handler(){
#Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
//specify msg value
if(msg.what==10){
//do this
}else if(msg.what==20){
// do this
}else{
//so on....
}
}
};
I would say, that you should have one handler per thread (not per runnable), unless you do not need completely different behavior for different kinds of runnables.

Related Links

error in android studio log cat need help..open gl FBO not found
Android - Run/debug background service [duplicate]
Can findViewById(android.R.id.content) ever return null for Snackbars?
How to delete shadow of ball in opencv android
Swedish letters missing in google-vision Api response
Firebase Android Response code: 400
Set flags to interact with system overlay window?
Android values in Nexus 4 and 5X
Video streaming doesn't work on Android but works on iOS
What is MatOfPoint and List<MatOfPoint> in opencv android
Android: Need help in accurate position of shape drawing
TextView modifies Linearlayout proportions when using ellipsize
Checkboxes not getting clicked
SqliteStudio AndroidDb: successful setup but fails to connect
How to hide ImageView in ListView correctly?
How to create a file available to other apps in android?

Categories

HOME
algorithm
xml
pagination
angular-formly
interface
obfuscation
r-googlesheets
jetty
recordrtc
computer-science
arangodb
openstreetmap
project-intu
alamofire
xcodebuild
job-scheduling
firefox-addon
dreamweaver
google-picker
pyramid
cfml
connector
ksh
tosca
anki
left-join
r-grid
card.io
browser-extension
getlasterror
dm-script
tex
dbnull
install.packages
congestion-control
file-sharing
apache-directory
fwrite
ntvs
dtsearch
launchctl
twilio-click-to-call
amq
context-switch
qtranslate
azure-cli
java-bytecode-asm
sundials
java-websocket
d3-force-directed
offline.js
android-instrumentation
omxplayer
winusb
nikeplus-api
wso2developerstudio
cassia
tfs-workitem
terracotta
google-books
rubaxa-sortable
opserver
eoferror
git-ftp
structuremap3
spy++
parallel-testing
reflector
accesscontrolexception
ecslidingviewcontroller
openargs
model-driven-development
beaker-testing
workitem
nebula
node-blade
windows-98
objectquery
usertype
workflow-services
winmain
automationelement
nhprof
photolibrary
globals
drupal-fivestar
rowlex
cldc
alsb
fdf
flvplayback

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