broadcastreceiver

Android - Create a background service to receive PubNub messages

。_饼干妹妹 提交于 2019-12-10 11:06:48
问题 I am using PubNub API to get real time messages. I have implemented code to subscribe to my channel and receive ongoing messages. I just want these messages to receive in background even if my application is not open. I have learned about services and broadcast receiver in android but I am not understanding the how to use this with PubNub. Is there any proper way to achieve this? PubNub Subscribe Code public static final String GLOBAL_CHANNEL = "NAME_OF_MY_CHANNEL"; public void subscribe() {

Android: Is there a way to stop AlarmReceiver fired in BootReceiver

╄→尐↘猪︶ㄣ 提交于 2019-12-10 10:58:10
问题 I am using a Boot receiver to fire AlarmManager,so that it repeats it's task every minute. I'd like the user to have in app option to enable/disable action that is done in every repeat of AlarmManager. So far I only used only a lame solution. I set user's preference in SharedPreferences and in every repeat of AlarmManager I check for user's preference in SharedPreferences and based on this preference the functionality is either executed or ignored. So far to my best knowledge, there is no way

Why does my Activity leak?

混江龙づ霸主 提交于 2019-12-10 10:54:44
问题 I have an Activity that has an IntentFilter and a BroadcastReceiver, and I register them in my onCreate() . IntentFilter filter = new IntentFilter(ACTION_RCV_MESSAGE); filter.addCategory(Intent.CATEGORY_DEFAULT); receiver = new MessageReceiver(); registerReceiver(receiver, filter); But upon ending my app, Logcat says: 07-03 01:38:19.567: ERROR/ActivityThread(304): android.app.IntentReceiverLeaked: Activity com.intentservicetest5.IntentServiceTest5Activity has leaked IntentReceiver com

Broadcast receiver stop triggering when swipe clear the app

杀马特。学长 韩版系。学妹 提交于 2019-12-10 10:51:22
问题 Broadcast receiver stop triggering "onReceive(Context context, Intent intent)" method after clear(swipe) app from recent list , how to solve this issue ? Manifest code <receiver android:name="*.receiver.TestReceiver" android:enabled="true" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <action android

Monitoring MMS_RECEIVED like SMS_RECEIVED on android

谁说胖子不能爱 提交于 2019-12-10 10:45:38
问题 So I'm setting up a program that plays a sound that is set when you receive a message, mms or sms. I got it to work with SMS but MMS doesn't do anything. Here is the code for the class that runs the BroadcastReceiver: /** * This class overrides the main BroadcastReceiver to play the tone * at the given textSoundPath. * @author Jesse Stewart * */ public class TextMonitor extends BroadcastReceiver { public static String textSoundPath; //this is the sound set to play when //sms or mms is

Getting notification endlessly from GCM Intent Service in android

半腔热情 提交于 2019-12-10 10:34:34
问题 I have created a activity which got refreshes while a notification occurs but I am facing one problem which is that when a notification came it continues to send endless same notification. Earlier it was working fine but I made some changes and this had done. Please help me. I am attaching my code with it. Code for GCM IntentService class @Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); String msgg = intent.getStringExtra("message"); final

Receiving Android Google Play Music broadcast twice

最后都变了- 提交于 2019-12-10 10:31:46
问题 I hope you're having a good day :) Let's get to the point... In my manifest file I have added a receiver like this : <receiver android:name="com.example.app.AndroidMusicBroadcastReceiver" android:exported="false"> <intent-filter> <action android:name="com.android.music.metachanged" /> </intent-filter> </receiver> I've also created the class com.example.app.AndroidMusicBroadcastReceiver . public class AndroidMusicBroadcastReceiver extends BroadcastReceiver { public

What Firebase-cloud-messaging Intent-filter to use for a BroadcastReceiver?

柔情痞子 提交于 2019-12-10 10:16:14
问题 I am trying to get the Android BroadcastReceiver to run when a Firebase Cloud message notification is received by the Android system. public class MyBroadcastReceiver extends BroadcastReceiver { private static final String TAG = "MyBroadcastReceiver"; @Override public void onReceive(final Context context, Intent intent) { Toast.makeText(context, "EVENT OCCURED", Toast.LENGTH_LONG).show(); } } It is required in the AndroidManifest to specify receiver tags as such: <receiver android:name="

Android - Run a service in background even when app is killed or device rebooted

余生长醉 提交于 2019-12-10 10:09:40
问题 I want to keep a service running in background, even when my app is killed. I'm using android.intent.action.USER_PRESENT event but the service only runs when the screen is unlocked. I tried android.intent.action.BOOT_COMPLETED but it needs to restarts the phone at least once after downloading the app. Ideally I would start my service all X minutes, using ACTION_TIME_TICK for instance. Then check conditions (battery level, network connections...) before starting the service. The problem is

Android: Shut down / loss of bluetooth connection or file receive -> Do something

大城市里の小女人 提交于 2019-12-10 10:00:59
问题 I want to write an App that monitors my paired bluetooth connection in the following way: If a file comes from a paired source it should be stored. If no file was passed and the bluetooth connection breaks down, my app shall store a dummy file. Storing a file works great, my main issue is how to run this whole thing without having an activity on my display.... I read much about services, but mostly it is said that a service is depending on an activity/app...is that right? Is there any other