receiver

getting battery level at android widget

岁酱吖の 提交于 2019-12-04 02:55:21
I wrote a widget for Android and I'm trying to get the battery level. I've tried using Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); but I get the error: "IntentReceiver components are not allowed to register to receive intents" Why? the ACTION_BATTERY_CHANGED is a sticky intent and I don't register a receiver (null in the first parameter). Any workaround? Thanks. hackbod gave the solution at the comments: " use getApplicationContext().registerReciever() " Ummmm...that feels like a bug. They must be doing the is-a- BroadcastRecevier

WakefulBroadcastReceiver is deprecated

时间秒杀一切 提交于 2019-12-03 11:22:14
问题 For creating a receiver I'm extended WakefulBroadcastReceiver in my old project. But now it's deprecated . Instead of WakefulBroadcastReceiver which Receiver I should use now and how to convert below code with new method? Here is my code: public class TaskFinishReceiver extends WakefulBroadcastReceiver { private PowerManager mPowerManager; private PowerManager.WakeLock mWakeLock; @Override public void onReceive(Context context, Intent intent) { mPowerManager = (PowerManager) context

WakefulBroadcastReceiver is deprecated

℡╲_俬逩灬. 提交于 2019-12-03 01:54:36
For creating a receiver I'm extended WakefulBroadcastReceiver in my old project. But now it's deprecated . Instead of WakefulBroadcastReceiver which Receiver I should use now and how to convert below code with new method? Here is my code: public class TaskFinishReceiver extends WakefulBroadcastReceiver { private PowerManager mPowerManager; private PowerManager.WakeLock mWakeLock; @Override public void onReceive(Context context, Intent intent) { mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); turnOnScreen(); Intent wakeIntent = new Intent(); wakeIntent

Android - Bluetooth discovery doesn't find any device

半城伤御伤魂 提交于 2019-12-03 00:58:59
I'm currently working on a little app to get started with the services that the Bluetooth Android API can provide. Edit -> Answer: It seems that the issue was due to the specific Nexus 5 devices. Seems like their bluetooth receiver doesn't work well. Solution below should work for other devices Remark: I’ve read the documentation here: http://developer.android.com/guide/topics/connectivity/bluetooth.html as well as the following source code of this tutorial http://www.londatiga.net/it/programming/android/how-to-programmatically-scan-or-discover-android-bluetooth-device/ located on github under

Getting midi messages from Receiver in Java

给你一囗甜甜゛ 提交于 2019-12-02 22:26:21
问题 I am trying to use a receiver so that I can extract midi event information as it is playing. I want to listen for notes played and synchronise them was some event. I have read the documentation and I am not sure how to actually use the transmitter / receiver. If someone could help point me in the right direction on how I can grab midi events from the receiver I would be very grateful. Edit: The possible duplicate offered below doesn't explain how the receiver actually works. It offers source

Is it better code practice to register a receiver in manifest or in code?

寵の児 提交于 2019-12-01 16:09:47
问题 I'm writing a simple broadcast receiver. I've registered receivers in both the manifest and in the code before. For my purposes this is a simple receiver that doesn't need to do anything fancy. Is there a reason to choose one method over the other in this case? Is registering the receiver in the manifest more efficient (executes faster)? Or are they both basically the same? I'm asking because the application I'm writing needs to be very efficient, and I haven't been able to find good

BOOT_COMPLETED not called on Honeycomb after export

天大地大妈咪最大 提交于 2019-11-30 10:28:46
I have a very weird problem, and none of the questions already on the website have an answer or the same problem. I have an app that receives BOOT_COMPLETED. I made sure it could receive the intent by setting android:installLocation to internalOnly. I have a Log.Debug in my OnBoot class, confirming wether or not it was called. I have two devices, an Android 2.2, and a Honeycomb. On android 2.2, it works fine, but Honeycomb... If I install the application on the honeycomb tablet with eclipse's "run" button, onBoot is called when the tablet boots. If I install the application on the honeycomb

android:enable and services

守給你的承諾、 提交于 2019-11-29 23:59:53
I m currently learning how create and use services on android. I looked on the android SDK for further help and i found the android:enable=[true | false] . in the SDK is said that: The and attributes must both be "true" (as they both are by default) for the service to be enabled. If either is "false", the service is disabled; it cannot be instantiated. So i would like to know what is the interest of/ why (in general) setting the application enables as "false". setting the service enable as "false". I say that if we put service enable as false there is no way to call that service, so why we

BOOT_COMPLETED not called on Honeycomb after export

和自甴很熟 提交于 2019-11-29 15:16:36
问题 I have a very weird problem, and none of the questions already on the website have an answer or the same problem. I have an app that receives BOOT_COMPLETED. I made sure it could receive the intent by setting android:installLocation to internalOnly. I have a Log.Debug in my OnBoot class, confirming wether or not it was called. I have two devices, an Android 2.2, and a Honeycomb. On android 2.2, it works fine, but Honeycomb... If I install the application on the honeycomb tablet with eclipse's

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. file init

不打扰是莪最后的温柔 提交于 2019-11-29 11:50:39
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. Exception appeared when I added: import signals in init .py file (apps/application/init.py) from models import Review in signals.py file (apps/application/signals.py) I want to send an http request when there is an insert in the model Review. So I need to import Review model (in the __init.py__ file) to execute the following code: @receiver (pre_save, sender = Review) def my_handler (sender, ** kwargs): .... In the Django's source , this is where the exception is comming from: def check_apps_ready(self): """Raise an exception