broadcastreceiver

AlertDialog in BroadcastReceiver

ε祈祈猫儿з 提交于 2019-11-28 14:01:52
I'm trying to create an application that can use the android as a fax machine, IE Send a picture as a fax or receive a fax and save as a picture. So far I'm starting from the ground up and making sure I can intercept a call at the users discretion. I have an Receiver registered in the Manifest of my program with a filter of Phone_State which flags when the state has changed(IE incoming call). So on my BroadcastReceiver I'm trying to have an AlertDialog popup prompting the user to either accept as fax or call but the AlertDialog seems to throw a android.view.WindowManager$BadTokenException

ReceiverRestrictedContext cannot be cast to android.app.Activity

爱⌒轻易说出口 提交于 2019-11-28 13:29:51
I need an Activity in my BroadcastReceiver, but when i try to cast the context to activity, it doesn't work. Caused by: java.lang.ClassCastException: android.app.ReceiverRestrictedContext cannot be cast to android.app.Activity How can I get Activity from BroadcastReceiver ? Thanks How can I get Activity from BroadcastReceiver ? Generally, you can't. A BroadcastReceiver is independent from an Activity. For example, you can have BroadcastReceiver which receive broadcasts when no Activity is running. You can, however, register/unregister a BroadcastReceiver in an Activity and use it to receive

WARN/ActivityManager(5038): Permission denied: checkComponentPermission

烈酒焚心 提交于 2019-11-28 13:26:55
From one application I am (broadcast) sending an intent to a broadcastreceiver of another one. I am getting the error: WARN/ActivityManager(5038): Permission denied: checkComponentPermission Vikalp Patel You need to add permission under your manifest file add these <receiver android:name=".YourBroadCastReceiverName" android:exported="true"></receiver> The solution is to add android:exported="true" to the activity that will be invoked by the intent. Adding it to the receiver, as suggested by another answer, did not work for me, but adding it to the activity did. Herschel said: " the problem was

BOOT COMPLETE is not working in Android (Redmi)

强颜欢笑 提交于 2019-11-28 12:54:43
I am currently working on a application which includes Boot_Completed Broadcast receiver concept. I have tested this app in my Motorola Moto G Phone. The app runs fine and shows the Toast message. But when I test this app in XIAOMI Redmi 1S phone it doesn't show the Toast message. I have already seen many questions similar to my issue (like these - Question 1 , Question 2 , etc.) ... But I haven't got any solution to this problem. My Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.demoapp" android

BroadcastReceiver Doesnt work if I close Recent Apps

99封情书 提交于 2019-11-28 12:54:05
问题 I am Trying to make an app which app will be called if a particular thing triggered. In my App this thing is sms.. When a new Sms Receiving I Read its contents and i Look for a Specific Content If it presents an alarm will goes on. If the App is opened its just working fine. The receiver triggers good... but when i clear recent apps receiver not triggering. I searched a lot here.. and Most of us saying that when an app in STOPPED_STATE it wont receive any notification that the particular

Best way to use TriggerEventListener in the background?

匆匆过客 提交于 2019-11-28 12:53:21
问题 I'm looking to make an application that runs in the background, logging location data without the user actually having to have the application in the foreground but at the same time doesn't use too much battery. I originally thought of setting a BroadcastReceiver for BOOT_COMPLETED and run a service which uses a Significant Motion sensor to log location data whenever the it fired off, but ever since Oreo, there are alot of limitations on background services. What is the best way to do this?

Alarmmanager not working after phone reboot

北城余情 提交于 2019-11-28 12:42:10
I had created alarmmanager on button click. but it not working after phone reboot. my AlarmbroadcastReceiver not call on phone reboot. it work when phone lock , application killed but not work after phone reboot i had created one progressbar which start on button click and stop after alarm broadcast fired but it not stop when phone reboot. i had added my button click event and broadcast receiver class Button click event b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pb1.setVisibility(View.VISIBLE); progress_edit.putBoolean("progress_one", true);

Android power button press not receiving by receiver

爱⌒轻易说出口 提交于 2019-11-28 12:36:10
I am trying to receive power button key press, But i unable to receive it. Receiver. public class PowerSendMessage extends BroadcastReceiver { public PowerSendMessage(Activity activity) { this.activity=activity; } static int countPowerOff = 0; private Activity activity = null; @Override public void onReceive(Context context, Intent intent) { Log.d("Power Button", "Click"); if(intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { countPowerOff++; } else if(intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { if(countPowerOff == 2) { Log.d("Power Click", "2 Times"); } } } Manifest Entry

Wifi scan results broadcast receiver not working

吃可爱长大的小学妹 提交于 2019-11-28 12:21:31
I have written a simple broadcast receiver to show a toast message when wifi scan is completed. Nothing is showing. Here is my code: package com.wifi; import java.util.List; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.wifi.ScanResult; import android.net.wifi.WifiManager; import android.widget.Toast; public class wifiReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context,"Scan completed", Toast.LENGTH_LONG).show(); } } Here is the manifest file:

NullPointerException at sendBroadcast() from Service to Activity

孤街醉人 提交于 2019-11-28 11:28:00
问题 I have a Service class and an main Acitivity class which is supposed to receive broadcasts from the Service class with method sendBroadcast. It crashes when running the method sendBroadcast from my Service class. here is part of my Service class ( EDITED ): public static final int STATE_CONNECTING = 1; public static final String BT_CONNECTING = "com.android.mypackage.action.BTService.BT_CONNECTING"; private final IBinder mBinder = new LocalBinder(); public class LocalBinder extends Binder() {