broadcastreceiver

How I can receive hardware key events in sleep mode?

一世执手 提交于 2019-12-04 13:12:37
I'm writing an application that allows people in danger to call 911. This is how it should work: He (or she) feels danger. He pushes the volume-down key three times. My app calls 911. But I'm facing the following problem: how can I receive a hardward key event in sleep mode ? I've searched Google and other search engines, but can't find anything related. public class YourBoardcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_CAMERA_BUTTON.equals(intent.getAction())) { Intent main = new Intent();// } } } And in your

Android: why did the Alarm notification stop after system reboot

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 12:54:42
问题 I am developing an android application that should fire an alarm five times a day: - the times in each day is not constant - after the alarm is fired I will schedule the next alarm. My problem is : the alarm notification works for 1 day then it stops and also when the device is rebooted twice the notification doesn't work , I don't now if there is another way to do that , any help will be very appreciated! Code: I have this function to call the broadcast reciever public static void Start

how to Get a list of applications being download?

旧时模样 提交于 2019-12-04 11:55:44
In my application, I need to know if a particular app is being downloaded from the android market or not. How Do I achieve this functionality? Is it possible to get a list of all the downloads that are in progress?Does the android market broadcast any intents that can be caught? Note:Since my target application is on android 3.0+ devices therefore, I have no issues with using the DownloadManager class(which is 2.3 onwards). I found an API that will accomplish what you want but you need to have an API of 9 or higher to use it. You can get all the downloads that have been requested for download

Trying to have a Broadcast Receiver with No filter

 ̄綄美尐妖づ 提交于 2019-12-04 11:48:32
IntentFilter intentFilter = new IntentFilter("test"); registerReceiver(mReceiver, intentFilter); I would like to have no filter like registerReceiver(mReceiver, null) but my app crashes as a result of that. Can I have new IntentFiler() as an empty filer? Because the BroadcastReceiver returns null when there is no match via the criteria from the IntentFilter , it is not possible with the API to accomplish what you hope to accomplish (which I'm assuming is sending any and all Broadcasts to mReceiver ). You can certainly specify an empty IntentFilter , but this will be pretty useless as

Android - Network State broadcast receiver does not receive intent

只愿长相守 提交于 2019-12-04 11:35:31
I have a broadcast receiver that needs to listen to network changes - BroadcastReceiver networkStateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false); if(!noConnectivity) { //some stuff } } }; I register it using - public void startListening() { IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); context.registerReceiver(networkStateReceiver, filter); } I have added the following permission in the

preventing a crash when someone mounts an Android SD card

你离开我真会死。 提交于 2019-12-04 11:11:46
I have a file open on the SD card. When someone mounts the SD card, it winds up crashing my application. I am trying to register for the ACTION_MEDIA_EJECT broadcast event, and i receive that, but it seems like i'm getting that too late. By the time I get that, it's already crashed my application. Is there any way to get notified before crashing my application? Added some very simple sample code. When I do this, it winds up crashing the service when I turn on USB (MSC mode). Test.java /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) {

How to add Snackbars in a BroadcastReceiver?

て烟熏妆下的殇ゞ 提交于 2019-12-04 10:05:05
Snackbars provide lightweight feedback about an operation by showing a brief message at the bottom of the screen. Snackbars can contain an action. Android also provides a toast, primarily used for system messaging. Toasts are similar to snackbars but do not contain actions and cannot be swiped off screen. My question import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class TestReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { Toast.makeText

XMPP events on Android

99封情书 提交于 2019-12-04 10:00:00
I'm trying to develop a background process that intercepts a XMPP message and performs an action, I'm using asmack as the main XMPP library. I presume I need a broadcastReciever that responds to a specific intent. The question is how to raise the intent? It must be possible as this functionality is present in the google talk client. many thanks in advance. If you really want to achieve this behavior, you might think about a persistent background service running the asmack XMPP client. The listener method (i.e. processPacket) of your XMPP client could raise an intent. You could then catch this

Android WifiP2p - Get notified when a discovered device goes unavailable

ぐ巨炮叔叔 提交于 2019-12-04 08:35:15
I'm developing a Wifi-direct app in which i'm listing the devices that are available and when the device goes to "unavailble" status i have to remove it from the list. I tried with the WifiDirectDemo sample, it successfully adds discovered devices in the list but when the device goes unavailable it is not getting notified. "WIFI_P2P_PEERS_CHANGED_ACTION" intent is not fired when device goes unavailable. When i try "discoverPeers" again, "onPeersAvailable" method gets the device list that are already discovered. It is not removing the unavailble devices. Is there any way to get notified when

How to create BroadcastReceiver without Activity

做~自己de王妃 提交于 2019-12-04 08:25:55
I would like to create a application that would respond to receiving SMS messages and display a dialog. How can I register the receiver in the manifest without defining within an activity? I tried to keep the receiver/intent-filter tags in the manifest out of the activity tag but the emulator will not install the apk since there is no launch activity. Keeping the BroadcastReceiver as the main activity results in an "Unable to instantiate activity" error in the Logcat. Any help? Thanks, Sunny Receiver class public class SMSReceiver extends BroadcastReceiver { // onCreat is invoked when an sms