broadcastreceiver

Error in doing interval task using BroadcastReceiver and AlarmManager in Android

守給你的承諾、 提交于 2019-12-13 08:49:48
问题 I am absolute beginner to Android. So now I am trying to develop a to-do list app on my own to improve my skills. My app is offline. But in my app I need to notify the user of the to-do tasks everyday. So I need to fire event for it in the background even my app is not running. So I am trying to integrate AlarmManager with BroadcastReceiver by creating a simple project to show a simple toast message at every interval. But it is throwing error. This code is not the to-do app code. I am just

How to detect bluetooth call/media button press in android app

落花浮王杯 提交于 2019-12-13 07:15:42
问题 I need to detect the bluetooth device button click in my application. i followed many stackoverflow links, but doesn't seem to work for me. I am using the broadcast receiver as shown below: public class RemoteControlReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (KeyEvent.KEYCODE_MEDIA_PLAY ==

Android Alarm Manager and BroadcastReceiver

狂风中的少年 提交于 2019-12-13 06:36:33
问题 Im trying to set an alarm that will send an intent to a broadcast receiver. The reciever should then print a line in the logcat stating it has worked. However I'm getting no indication that the reciever is receiving anything. I've checked all the things I can think of. Can someone give me some guidance as I am at a loss? Alarm Method public void scheduleNextUpdate() { Intent intent = new Intent(MainActivity.this,AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast

Change output volume in BroadcastReceiver for Notification for non-streaming preference

折月煮酒 提交于 2019-12-13 06:30:24
问题 WhatsApp seems to always notify me with high volume when running in the background and one of my contacts (who has a custom notification sound) comes up. I'm trying to create a similar effect. I want to control the volume of the notification. The only example I could find on Stack Overflow is this. The differences here are that: My context is a BroadcastReceiver I am not streaming music but using a notification sound based on a list of default ringtones available on the phone (similar to

Android loop service every 5 seconds and boot on startup

情到浓时终转凉″ 提交于 2019-12-13 06:16:25
问题 I have the code below and I want to loop this every 5 seconds. I have tried to use broadcastreceiver and alarm manager but without success . I want my service to loop for 5 times and after that stop permanently .This is the second question I post . Please somebody help me to fix the code, I am stacked on my mac for 2 days. Any help will be appreciated. Code to loop every 5 seconds File key = new File(Environment.getExternalStorageDirectory(),"newfile"+Math.random()+".txt"); try { key

Android. Reboot my BroadCast receiver. Not working.

a 夏天 提交于 2019-12-13 05:23:58
问题 How to start a service in android using nested class when mobile is switched ON? I have the package contains nested class. package Name com.android MainActivity BroadCastReceiver I am trying to reboot my BroadCast receiver. But it doesn't work (getting Failed). I don't know if the reason is, because of any problems for nested classes. <receiver android:name="ConnectionReceiver"></receiver> <receiver android:name="com.android.MainActivity .BroadCastReceiver "> <intent-filter> <action android

Broadcast receivers and Fragments

痞子三分冷 提交于 2019-12-13 05:22:22
问题 I have this scenario implemented where I have a navigation drawer with nested fragments that are added to the back stack with tag. Every fragment has the following implemented: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (rootView == null) { rootView = inflater.inflate(R.layout.fragment_feed, container, false); // Doing initialisaion here } else { ((ViewGroup) rootView.getParent()).removeView(rootView); } return rootView;

adb shell am broadcast - BroadcastReceiver throws nullpointer

杀马特。学长 韩版系。学妹 提交于 2019-12-13 05:10:01
问题 I'm trying to launch this command: adb shell am broadcast -a android.provider.Telephony.SMS_RECEIVED --es sms_body "TEXTTEXTTEXT" -n com.example.name/.receivers.SmsReceiver And this code throws null pointer exception: public class SmsReceiver extends BroadcastReceiver { ... private Context mContext; private Intent mIntent; public void onReceive(Context context, Intent intent) { mContext = context; mIntent = intent; String action = intent.getAction(); if (action.equals(Const.ACTION_SMS

How to optimize sms background service for battery and resources

喜你入骨 提交于 2019-12-13 04:58:59
问题 I have an app in store, and a few users said that the app uses either too much battery, or it his hig mb in resources(10 or 20mb+). In my device its fine and on a few devices if seen it its fine. I use an sms broadcast receiver to read all the incomming sms, and if i see any message i want to process i read it etc. So basically the service needs to run all the time so i dont lose any message that might come. Is there a way to optimize this or to make the code lighter if its possible so that

BroadcastReceiver from AlarmManager not getting called

自闭症网瘾萝莉.ら 提交于 2019-12-13 04:44:53
问题 I have a class that extends IntentService . The stuff in this class is called when my app reboots (and also on app startup). It loads some settings and does some stuff in the background (it's a productivity tool/utility). This IntentService , when loading my, let's call it "stuff" , decides whether or not to add some alarms via AlarmManager . I have a BroadcastReceiver that receives some different parameters and does some method based on those parameters. Here is the code in which I am