broadcastreceiver

Android - How to receive the BOOT signal with an application installed on sdcard?

爱⌒轻易说出口 提交于 2019-12-22 16:45:02
问题 I need to start a notification service for an application when the device boots. I have implemented a BroadcastReceiver that listens to the boot signal in order to start the service. However, this works only if the application is not installed on sdcard (because the signal is received before the sdcard is mounted). Is there any solution to keep installing the application on sdcard and yet still receive that signal? Any hack for this? Let me know! Thanks! 回答1: You could either: Register an

Android - How to receive the BOOT signal with an application installed on sdcard?

爱⌒轻易说出口 提交于 2019-12-22 16:44:23
问题 I need to start a notification service for an application when the device boots. I have implemented a BroadcastReceiver that listens to the boot signal in order to start the service. However, this works only if the application is not installed on sdcard (because the signal is received before the sdcard is mounted). Is there any solution to keep installing the application on sdcard and yet still receive that signal? Any hack for this? Let me know! Thanks! 回答1: You could either: Register an

Alarm Manager is not activating broadcast receiver?

試著忘記壹切 提交于 2019-12-22 14:59:30
问题 I am working on an application inwhich I am using AlarmManager for scheduling things. My Alarm is set. But this Alarm does not invoke BroadcastReceiver written to catch the event. I have searched a great deal but I have not found anything that solves the issue. I am posting my code, please have a look and see if I am missing something. AlarmManagerClass: public class ScheduleMessageManager { Context context; PendingIntent sender; AlarmManager am; public ScheduleMessageManager(Context context)

Android notifications multiple times

核能气质少年 提交于 2019-12-22 14:01:01
问题 I have notifications that remind user to take the medicine. When I add new times for taking medicines, for example, at 9:00 pm and 9:01 pm, only last notification is active. Here is my code: AddTime.java: (part) Cursor cursor2 = sqdb.rawQuery("SELECT Name FROM Medicine WHERE _id = " + mId, null); while(cursor2.moveToNext()) { med = cursor2.getString(cursor2.getColumnIndex("Name")); } //med - Name of medicine String sql = "SELECT _id FROM Time WHERE mId = "+mId+" AND Year = "+year+" AND Month

sms BroadcastReceiver doesn't receive SMS after app killed OR device restart on MI devices only

和自甴很熟 提交于 2019-12-22 12:24:08
问题 My SMS receiving code works good on all devices except Xiomi Redmi devices On Xiomi Redmi devices , my app(Broadcast Receiver) not able to receive SMS when app gets killed by swiping from recent app list OR after device restart until I start the app manually. (Tested on Mi Marshmallow and MI Lollipop devices). This issue happens only on MI devices. App works good on other devices like Samsung, HTC, Sony, Motorola, Micromax etc. my code in manifest: <uses-permission android:name="android

sendOrderedBroadcast setPackage requirement in Oreo

非 Y 不嫁゛ 提交于 2019-12-22 11:14:10
问题 Why would the following Ordered Broadcast fail in Android Oreo, unless I specifically set the package name? final Intent vrIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS); // Setting the package it will work. Omitting, it will fail // vrIntent.setPackage("com.google.android.googlequicksearchbox"); getContext().sendOrderedBroadcast(vrIntent, null, new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { // final Bundle bundle =

How to Autostart an AlarmManager to start a Scheduled Activity?

我的梦境 提交于 2019-12-22 10:38:11
问题 This tutorial come from android-er, The main activity(AndroidScheduledActivity.java) start a AlarmManager to trigger BroadcastReceiver(MyScheduledReceiver.java) repeatly. In the onReceive() method of MyScheduledReceiver, it start another activity(MyScheduledActivity.java) indirectly. Such that the activity(MyScheduledActivity.java) will be start in scheduled interval. Now I would use AutoStart to start automatically, but I was not able to write the AutoStartNotifyReceiver . please can you

Android - can't enable BroadcastReceiver

社会主义新天地 提交于 2019-12-22 10:37:42
问题 I got back to the widget development after upgrading to the latest SDK and all of the sudden my widget is failing on startup with this message: ERROR/AndroidRuntime(5296): java.lang.RuntimeException: Unable to start receiver topjob.widget.SearchWidget: java.lang.SecurityException: Permission Denial: attempt to change component state from pid=5296, uid=10057, package uid=10048 Here's two lines of code where exception occurs: @Override public void onEnabled(Context context) { PackageManager pm

StartActivity in android broadcast receiver

徘徊边缘 提交于 2019-12-22 10:35:49
问题 I registered receiving SMS broadcast in manifest.xml. How can I start new Activity in receive() method of the broadcast. is there any flags of Intent to set or anything? 回答1: use FLAG_ACTIVITY_NEW_TASK like this @Override public void onReceive(Context context, Intent intent) { Intent i = new Intent(context, AlarmDialog.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } 来源: https://stackoverflow.com/questions/8211754/startactivity-in-android-broadcast-receiver

peekService returns null even though startService does not

老子叫甜甜 提交于 2019-12-22 10:06:57
问题 I'm trying to use an Android Service from a BroadcastReceiver . The Service lives in a different application than the BroadcastReceiver . My understanding is that the right way to do this is to first call Context#startService , followed by BroadcastReceiver#peekService . The call to startService seems to work correctly, as it returns the expected ComponentName . However, when I make the call to peekService , null is returned. Any thoughts on what I'm doing wrong? Thank you! Here is a code