broadcastreceiver

Why is my BroadcastReceiver receiving ACTION_USER_PRESENT twice?

与世无争的帅哥 提交于 2020-01-03 17:22:37
问题 My application needs to make a toast when the user unlocks the screen, so I registered a BroadcastReceiver to pick up the intent ACTION_USER_PRESENT in the manifest, like so: <receiver android:name=".ScreenReceiver" > <intent-filter> <action android:name="android.intent.action.USER_PRESENT"/> </intent-filter> </receiver> And then I defined a class like this: package com.patmahoneyjr.toastr; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent

Registering Static Broadcast receiver in Oreo

懵懂的女人 提交于 2020-01-03 16:00:08
问题 I'm Working on a project which records incoming calls and outgoing calls, but with Oreo static broadcast receivers (Broadcast receivers which are registered in the manifest) are not getting triggered. if I register with context, the broadcast will not be triggered once app gets killed. I want the broadcast receiver to work even if app is closed. is there any possible way to achieve this Oreo? or any other alternative approach to achieve this? any help will be appreciated. I'm registering in

Broadcast Receiver in fragment not receive intent from service

我与影子孤独终老i 提交于 2020-01-03 08:40:15
问题 I have a fragment and a service as below: I register and unregister LocalbroadcastManager in file Fragment.java Fragment.java @Override public void onStart() { // TODO Auto-generated method stub super.onStart(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ffmpegService.PROGRESS); intentFilter.addAction(ffmpegService.DONE); LocalBroadcastManager.getInstance(getActivity()). registerReceiver(receiver, intentFilter); } @Override public void onStop() {

How do I sendBroadcast(intent) from myDialog and receive in myActivity?

一世执手 提交于 2020-01-03 07:19:27
问题 So, I'm trying to get a handle on BroadcastReceivers and Intent filters. I have a custom Dialog that I create in MyActivity. In the Dialog, I have a Button. When the button gets clicked, I want to send a broadcast that MyActivity's receiver will pick up. Here's what I have right now: //MyActivity.java class myActivity extends Activity { //MyDialog dialog initialized in onCreate ... private class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent

Connect my Activity, Service and BroadcastListener

烈酒焚心 提交于 2020-01-03 05:21:14
问题 Developing my first Android app at the moment. I'm new to Android, but did a bit of Java in University. PHP, JavaScript, C# and my employers proprietary language (not unlike BASIC) are my background so I do have a good programming understanding. The plan is: An Acticity with a toggle button - when on it starts the service (below). A Service that will sit in the background and listen for data on a specific TCP port. A BroadcastReceiver that will monitor the WiFi status. I have all three in

WiFi changed status affecting my app

放肆的年华 提交于 2020-01-03 04:47:09
问题 I'm using WiFiManager through my app, at some level in the starting of the app it displays all the available WiFi networks to the user and enables him to choose one of them and make a connection to it, I'm making this by registering the CONNECTIVITY_CHANGE receiver through my manifest.xml : <receiver android:name="com.automation.standards.WifiReceiver" > <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver> and then dealing with the

Start Activity from a Broadcast Receiver

僤鯓⒐⒋嵵緔 提交于 2020-01-02 16:17:58
问题 I've got the following scenario for Android: I have an app that when launched starts a service . That service checks a url every 30 minutes. If it gets a specific response, it sends a Broadcast which the app receives and processes. That scenario is working great for me. I'd also like my service to continue running after the user has stopped running the application (app out of foreground.) Which I've got working as well. The problem that I'm facing is that when the Activity receives the

What is the Context passed into onReceive() of a BroadcastReceiver?

蹲街弑〆低调 提交于 2020-01-02 08:04:33
问题 What is the context that is passed int the onReceive method of a BroadcastReciver : public void onReceive (Context context, Intent intent) According to the official documentation: The Context in which the receiver is running. 回答1: A little research gives below result... For static receiver public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.e("PANKAJ", "Context class " + context.getClass().getName()); Log.e("PANKAJ",

Widget onUpdate is not setting pendingIntent on button click after reboot

∥☆過路亽.° 提交于 2020-01-02 05:13:10
问题 I'm creating a test widget that shows random number by clicking its button. everything is inside onUpdate of my Provider independently, including the pendingIntent . it works fine but after rebooting the phone views.setOnClickPendingIntent is not working although RemoteViews is recreated with no issue but the button becomes unresponsive. public class TestWidget extends AppWidgetProvider { static HashMap<Integer, BroadcastReceiver> br = new HashMap<>(); static void updateAppWidget(Context

how to end up my outgoing call.

心已入冬 提交于 2020-01-02 05:03:10
问题 with statrtActivity(callIntent) , call goes and then i have to wait for few seconds and end automatically. to end up my call i have taken mycalss extends Broadcastreceiver then in that onreceive() i implemented.in that method i got only to set old number and newnumber and toast is printing. What i want exactly is to end call what i need to write. and how to call onreceive method from my class? plase help me. i didnt get anywhere. @Override public void onReceive(Context context, Intent intent)