broadcastreceiver

How to declare an intent-filter for a Receiver class which is present in an external library.

好久不见. 提交于 2019-12-11 07:39:49
问题 I've created a library one of whose class is public class SmsReceiver extends BroadcastReceiver{...} Now since this class extends BroadcaseReceiver so I need to declare intent-filter like this: <receiver android:name="SmsReceiver"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> But, now since the SmsReceiver class is a part of external library so, if I declare the intent-filter like above in the application (application package

Not sure if service onDestroy is called from BroadcastReceiver

不想你离开。 提交于 2019-12-11 06:49:08
问题 I have a service which I start using Intent serviceIntent = new Intent(getActivity().getApplicationContext(), LocationService.class); getActivity().startService(serviceIntent); When app is going into background, not closed , just not in foreground: i.e. press home button, I do: Notification notification = mBuilder.build(); service.startForeground(NOTIFICATION, notification); To bring the service to the foreground and show ongoing notification. I have a BroadcastReceiver which is fired when

Broadcast Receiver not receiving ACTION_BOOT_COMPLETED if app hasn't been run?

泪湿孤枕 提交于 2019-12-11 06:38:53
问题 I have been trying to create an app service that does not have an Activity and i ran into some issues. I want the service to run from boot, so naturally used a BroadcastReciever to catch ACTION_BOOT_COMPLETED this is no problem while testing. I used an Activity to start and stop the service to test it was working then rebooted to see if the boot receiver worked, it did, happy days. Removed the test Activity and from the application and used the below manifest. <manifest xmlns:android="http:/

How to register broadcast receiver inside instrumentation?

纵饮孤独 提交于 2019-12-11 06:38:26
问题 I am trying to get bluetooth discovery results through an apk which runs as android junit runner. Everything works fine but while registerReciever I get below error. What could be the reason ? java.lang.SecurityException: Given caller package com.ex.test is not running in process ProcessRecord{d740580 19462:com.ex/u0a302} Code- @Test public void demo() throws Exception { Context ctx = InstrumentationRegistry.getInstrumentation().getContext(); BluetoothAdapter mBtAdapter = BluetoothAdapter

dealing with received gcm push notification in different activities?

你离开我真会死。 提交于 2019-12-11 06:34:02
问题 I'm new to android development. I am able to push notification to devices. In my application, there are three different activities. I followed the google gcm client example to receive the notifications. Now i need to deal with the received push message differently according which activity is active. I understood that this can be solved with registering multiple receivers for push msgs. I dont know how to do that. Can you guys help me with this ? please/... 回答1: Register different broadcast

Incoming number is null after ending the call in android PIE 9

岁酱吖の 提交于 2019-12-11 06:10:52
问题 I have been working on this problem since weeks. I am making an app which picks the incoming number and shows it in a dialog box after the call is ended. Everything is working fine below android PIE 9.0. The number is always null in android PIE. I have given all permissions including READ_CALL_LOGS but same problem. The incoming number is null. So please anyone help me... Here is my manifest file : <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com

BroadcastReceiver's behaviour for ACTION_SHUTDOWN

試著忘記壹切 提交于 2019-12-11 06:06:09
问题 I have BroadcastReceiver which listens for ACTION_SHUTDOWN and some other actions. My problem is, when I shutdown my android device(2.3.6) BroadcastReceiver is catching ACTION_SHUTDOWN two times. Problem is only with ACTION_SHUTDOWN and not with other actions. When I run same code on emulator, it works fine. Guys please help me. Here is my code: my BootReceiver.java public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if

Why is my BroadCast Receiver not working?

醉酒当歌 提交于 2019-12-11 06:04:35
问题 I am learning about BroadCast Receivers. What I am trying to achieve with the following piece of code is, I would like to see a toast when I switch to airplane mode, where the app is on or not. What am I not doing / Doing wrong? Please Help. Thanks ConnectivityChangedReceiver.java class import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.widget.Toast;

Receive notification when app is closed

倾然丶 夕夏残阳落幕 提交于 2019-12-11 05:59:53
问题 I try to implement system to receive push notifications on my application. I use Firebase and everything is ok when the app is active or in background but nothing happen when the app is closed. I tried to create a WakefullBroadcastReceiver like that : public class NotificationReceiver extends WakefulBroadcastReceiver { public static final String action = "com.myapp.notification.RECEIVE"; private static final String KEY_PUSH_DATA = "com.parse.Data"; @Override public void onReceive(Context

Service stops on clearing data from settings

本秂侑毒 提交于 2019-12-11 05:29:42
问题 in my app i run a service in which i keep record of incoming and out going calls on text file(saved it on internal storage) using broadcastReciever . but when i press clear data button(settings=>apps=>Myapp=>clear data) my service also stops. i used Log.d() in onDestroy() method but it is not logged in logcat when i press clear data . i read this question having same problem but i didn't find any solution. then i went through Developer Guide. i am really confused. 回答1: The data associated the