broadcastreceiver

Is it possible to call onReceive method from a dialog?

霸气de小男生 提交于 2019-12-22 10:06:27
问题 I have a custom dialog with editText and save button . When button clicked, I want it call MyReceiver . But the log and Toast in MyReceiver never get displayed. Reminder final AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inflater = LayoutInflater.from(this); View promptView = getLayoutInflater().inflate(R.layout.dialog_with_edittext, null); Button save = (Button) promptView.findViewById(R.id.okBtn); final EditText task = (EditText) promptView.findViewById(R.id

best practice where to register broadcast receiver?

一笑奈何 提交于 2019-12-22 09:52:45
问题 quick opinion question on where its 'best' to register a receiver? In my case my service sends a broadcast each time the UI needs updating. Options as i understand them . Manifest . Oncreate . Onstart . Onresume With the corresponding unregister of course. I think for a UI update scenario makes sense to put in onresume and onpause... your thoughts? 回答1: If the receiver is only to receive events that would cause you to update the GUI then there are two options. Register to receive them in

Does AlarmManager require the PendingIntent to be of Type BroadcastReceiver?

眉间皱痕 提交于 2019-12-22 09:24:21
问题 The documentation for AlarmManager seems to imply (but does not outright explicitly require) that the PendingIntent you pass in to any of the set() methods should be of the type BroadcastReceiver, but I tested passing in other component types (like an IntentService) and it seemed to work fine. Is it safe to use non-BroadcastReceiver Intents with AlarmManager? 回答1: Yes, and it has always worked, but I suspect not in the way that you're thinking. You can use any PendingIntent with an alarm;

How to use NFC ACTIONS

倖福魔咒の 提交于 2019-12-22 09:01:03
问题 I am trying to register a receiver programmatically to get notified once an NFC tag is detected. As shown in my code I registered for the desired action and I created the broadcast receiver programmatically. I also added the required permission in the manifest file but the problem is that onReceive is never called. Please let me know what I am doing wrong and how to fix it. IntentFilter intentFilter1 = new IntentFilter(); intentFilter1.addAction("android.nfc.action.TAG_DISCOVERED");

Mobile Number verification for dual SIM devices in Android

房东的猫 提交于 2019-12-22 08:48:59
问题 I have done the sim/mobile number verification (same like Whats APP) part in my app. something like: Send Message Part: SmsManager sm = SmsManager.getDefault(); sm.sendTextMessage(mobileNumber, null, "Welcome", null, null); Check the message received by the same/current device through BroadcastReceiver: private class SMSReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { if(intent.getAction() != null && intent.getAction().equals("android

ContentObserver vs. BroadCastReceiver : Battery Usage, Ram, CPU?

三世轮回 提交于 2019-12-22 08:47:24
问题 Since there is such a needed concern for an application's battery usage, ram and cpu usage, what is the expense of multiple contentobservers vs. multiple broadcastreceivers? Example 1: A service running with START_STICKY using 5 contentobservers registered/unregistered properly. Example 2: A service being fired from 5 broadcastreceivers set in the manifest. Example 3: A service running with START_STICKY using 5 registered broadcastreceivers. What is the true difference in battery usage/ram

Android BootReceiver does not work

廉价感情. 提交于 2019-12-22 08:26:28
问题 I'm trying to listen for reboot event. I'v created the following class: import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class OnBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.i("MYBOOTRECEIVER", "HELLO!"); } } and then in the manifest file I've putted the following xml: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http:/

Permission Denial , even after adding the correct permission in the manifest

无人久伴 提交于 2019-12-22 08:08:16
问题 I am developing an app which listens to incoming sms. I have added the permission: <uses-permission android:name="android.permission.RECEIVE_SMS" /> to my app manifest. And yes, it is not inside the receiver tag. I am trying to test the app by sending a sms from one emulator to another. My logcat gets the following entry : WARN/ActivityManager(66): Permission Denial: receiving Intent { act=android.provider.Telephony.SMS_RECEIVED (has extras) } to com.android.LUC requires android.permission

Android - BroadcastReceiver unregisterReceiver issue (not registered)

蹲街弑〆低调 提交于 2019-12-22 06:49:02
问题 I'm having some problems unregistering a BroadcastReceiver . I'm first registering it but then when I want to unregister it by using unregisterReceiver(); command gives me tons of errors. The error says that I've not registered my BroadcastReceiver . Code: public class Receiver extends BroadcastReceiver implements Variables { CheckConexion cc; @Override public void onReceive(Context contxt, Intent intent) { // Cuando hay un evento, lo diferenciamos y hacemos una acción. if (intent.getAction()

Dynamic register of C2DM receiver using registerReceiver

故事扮演 提交于 2019-12-22 06:25:04
问题 I can register my android app with C2DM successfully using a <receiver> in my manifest. However, if I delete the <receiver> from the manifest and register my receiver using the method registerReceiver of the context, I receive a SERVICE_NOT_AVAILABLE error response. I have reproduced this behaviour in the emulator and in a real device. Is dynamically registering a C2DM receiver possible? This is the fragment of the manifest I deleted: <receiver android:name=".service.C2DM.C2DMReceiver"