android-broadcast

How do I implement a BroadcastReceiver in a Service Class in Android?

寵の児 提交于 2019-12-03 09:20:31
问题 I need to implement BroadcastReceiver in a Service class I have created: public class MyService extends Service in this class I have to implement a Simulation of Download by using Thread - Sleep when the user presses the button in the MyActivity Class which implements sendBroadcas(). I cannot extends the Service class to BroadcastReceiver as it is already extendes to Service. Can anyone help me to figure it out how to implement this mechanism? thanks 回答1: Have the BroadcastReceiver as a top

How to fire an event like launch an application when a text is selected

假如想象 提交于 2019-12-03 07:48:37
问题 I was wondering if i can launch an activity or application when a text is selected in any application like browser, messages etc. Like when we select a text at any where a small pop-up appears mentioning cut, copy, paste option. can i add another button there? to launch my application? if i can please guide me how can i do that and send data to my application.. Thank you ! protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window

Is it good to replace broadcast receiver with Greenrobot Eventbus for triggering event based functions and data transfer from service to activity?

谁都会走 提交于 2019-12-03 05:05:44
问题 I have implemented a service, where I handle the state changes(connect, disconnect, onServiceDiscoverd, onCharacteristicChange etc) and receiving data from another device through gatt Server. My question is, Can the events be handled efficiently using Greenrobot Eventbus replacing broadcast receiver between service and Activity ? 回答1: Unlike LocalBroadcastManager, EventBus is more simple to use. You only go via 3 steps: 1- Create an event class. A simple Java class that represent the response

Listen incoming calls through BroadcastReceiver, without PhoneStateIntentReceiver or PhoneStateListener

我只是一个虾纸丫 提交于 2019-12-03 04:39:00
问题 Is there any way to listen to incoming calls by extending BroadcastReceiver to listen to OS's broadcast,without using PhoneStateIntentReceiver or PhoneStateListener. Also please tell me what will be action and permissions in manifest. I've tried with as follows but it is not working for incoming calls but working for outgoing The only one .java file of app is as follows(the app only one .java file and one manifest file) package com.crsardar.media.audio; import android.content

Listen for new calendar events

守給你的承諾、 提交于 2019-12-03 01:38:46
Mainly what I need is to react depending on the events in the default android calendar (Google). It's fairly easy to query the provider and get the events at any given time but my data has to be consistent all the time. What I want is to avoid querying the provider each x min to check for new events. I couldn't find any system broadcast for when the app stores the new event (only when the event gets triggered). Just to be clear, I don't want to create, delete, etc events from my app, I just want to monitorize them, I need the moment of the creation of a new event so I can requery the provider.

How do I implement a BroadcastReceiver in a Service Class in Android?

大城市里の小女人 提交于 2019-12-03 00:53:08
I need to implement BroadcastReceiver in a Service class I have created: public class MyService extends Service in this class I have to implement a Simulation of Download by using Thread - Sleep when the user presses the button in the MyActivity Class which implements sendBroadcas(). I cannot extends the Service class to BroadcastReceiver as it is already extendes to Service. Can anyone help me to figure it out how to implement this mechanism? thanks Have the BroadcastReceiver as a top-level class or as an inner class in your service. And get a reference of the receiver in your service. Like

How to fire an event like launch an application when a text is selected

拈花ヽ惹草 提交于 2019-12-02 21:14:58
I was wondering if i can launch an activity or application when a text is selected in any application like browser, messages etc. Like when we select a text at any where a small pop-up appears mentioning cut, copy, paste option. can i add another button there? to launch my application? if i can please guide me how can i do that and send data to my application.. Thank you ! protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE

Listen incoming calls through BroadcastReceiver, without PhoneStateIntentReceiver or PhoneStateListener

99封情书 提交于 2019-12-02 17:47:13
Is there any way to listen to incoming calls by extending BroadcastReceiver to listen to OS's broadcast,without using PhoneStateIntentReceiver or PhoneStateListener. Also please tell me what will be action and permissions in manifest. I've tried with as follows but it is not working for incoming calls but working for outgoing The only one .java file of app is as follows(the app only one .java file and one manifest file) package com.crsardar.media.audio; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class

How to make my SMS App is highest Priority to receive Broadcast Receiver

只愿长相守 提交于 2019-12-02 17:07:30
问题 At First, I am sorry for my English is not good enough ! My problem is i am writting a Block SMS Application and i want to receive sms with my app and then i abort broadcast to make default sms app can't receive SMS, so i set my app have a highest priority (1000), but my app still receive broadcast after default sms app of android. I print all of my Android Phone SMS's broadcast received signal in order when my phone receive a SMS and i recognize that The System SMS App alway receive SMS

Do I need to acquire wake lock when invoking a BroadcastReceiver

不羁岁月 提交于 2019-12-02 15:21:45
问题 In the book Pro Android 4 By Satya Komatineni , Dave MacLean I've found: Android acquires a partial wake lock when invoking a broadcast service and releases it when it returns from the service in the main thread Does it mean that the Android OS ensures that the device will wake up for the time of going through onReceive of BroadcastReceiver ? In my case the BroadcastReceiver should get an intent from Google Play Services (GoogleLocationServices and to be precise Geofences api). Where is it