broadcastreceiver

Kotlin: Unresolved local class when using BroadcastReceiver in Activity

柔情痞子 提交于 2019-12-03 10:01:53
From time to time when compiling the project I get this error: Error:java.lang.UnsupportedOperationException: Unresolved local class: com/myproject/activities/BaseActivity$broadcastReceiver$1 at org.jetbrains.kotlin.descriptors.NotFoundClasses$classes$1.invoke(NotFoundClasses.kt:44) at org.jetbrains.kotlin.descriptors.NotFoundClasses$classes$1.invoke(NotFoundClasses.kt:32) at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:408) at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke

android update widget from broadcast receiver

守給你的承諾、 提交于 2019-12-03 09:47:48
问题 I have an widget and I must update the widget when action android.media.RINGER_MODE_CHANGED occurs. I have the folowing broadcast receiver: public void onReceive(Context context, Intent intent) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context.getApplicationContext()); ComponentName thisWidget = new ComponentName(context.getApplicationContext(), ExampleAppWidgetProvider.class); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget); if (appWidgetIds != null

Android IntentService won't start on boot

陌路散爱 提交于 2019-12-03 09:10:25
I have an IntentService which starts on boot and stays running in the background. There is no launcher Activity, the IntentService is called by a broadcast receiver. It works on 2.3.4 and 4.0.4 devices but not on 4.2.2. Maybe my broadcast receiver isn't being triggered on the device? Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="br.com.xxx" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.ACCESS

How to detect new apps in an Android device

送分小仙女□ 提交于 2019-12-03 08:51:35
I want to detect when the user installs or deletes an app, and I didn't find a BroadcastReceiver that does this. In my app, I get the information about the installed apps with the class PackageManager , but I don't want to scan the apps periodically. Is there any BroadcastReceiver that does this? Or any ContentObserver ? Is it possible to get a notification that an app has been installed or removed? You can register a BroadcastReceiver using Intent.ACTION_PACKAGE_ADDED (and also Intent.ACTION_PACKAGE_REMOVED and/or Intent.ACTION_PACKAGE_CHANGED if necessary). For instance, void

How to send broadcast with permission from command line

北战南征 提交于 2019-12-03 08:44:57
I have a broadcast receiver in a app which uses my permission com.myexample.permission.MY_PERMISSION . I am able to send the broadcast using sendBroadcast(intent, "com.myexample.permission.MY_PERMISSION") from activities. To send a broadcast for action as com.com.myexample.MY_ACTION and extra data with key as MY_EXTRA below command can be used: $adb shell am broadcast -a com.com.myexample.MY_ACTION --ez MY_EXTRA true But how to send broadcast with permission com.myexample.permission.MY_PERMISSION to the app from command line using adb shell commands?? Swing If my answer here is not what you

Intercepting an intent from an external application

感情迁移 提交于 2019-12-03 08:14:07
Suppose I want to develop an application that extends in some way (let me say "cooperate with") a very popular application I obviously don't have control over. Let us also suppose, for sake of simplicity, that the very famous application author won't release an update to block my application. I studied the application's functionality and identified that it widely uses BroadcastReceiver s. I also know, from manifest, the com.famousvendor.intent.INTENT_NAME constants I might use. The question is straightforward: if I create an application, namely org.zighinetto.tinyapp with a broadcast receiver

ConnectivityManager.EXTRA_NO_CONNECTIVITY is always false on Android Lollipop

偶尔善良 提交于 2019-12-03 07:31:50
I am using this piece of code to detect Internet connection state changes. It works fine on Android<5.0, but on API 21 this: intent.getExtras().getBoolean(ConnectivityManager.EXTRA_NO_CONNECTIVITY) is always false. How to make this code to work on Android 5.0? My BroadcastReceiver: public class NetworkStateReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { if(intent.getExtras()!=null) { final ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo

Android : Check phone number present in Contact List ? (Phone number retrieve from phone call)

依然范特西╮ 提交于 2019-12-03 07:09:57
问题 I make a BroadcastReceiver to receive Phone number of the person who call me <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> How to check if the phone number receive is on my contact list ? Do you have a tip to know if this phone number exist on contact list with out loading contact list ? I don't want more information, just if this phone number exist. If it's not possible, and I must load contact list, how to do it on BroadcastReceiver ? When I

BroadcastReceiver onReceive timeout

北战南征 提交于 2019-12-03 06:55:57
I extend BroadcastReceiver , and in onReceive() I do whatever I need to do. onReceive() has a timeout, from the documentation: there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed This creates a problem when I am in debug mode. I need more than 10 seconds (sometimes). If I don't do all my debugging in 10 seconds my connection is closed and debugging is stopped. Can I increase the timeout or disable it for debugging purposes? Thanks. Eric Levine In order to prevent your app from force closing while you are paused on a

ACTION_USER_PRESENT in manifest with BroadcastReceiver

梦想的初衷 提交于 2019-12-03 06:37:04
There seems to be different opinions on whether it is possible to catch the ACTION_USER_PRESENT screen unlock through the manifest. This thread implies no it can't be done: Android Broadcast Receiver Not Working This thread implies yes it can be done: Broadcast Receiver for ACTION_USER_PRESENT,ACTION_SCREEN_ON,ACTION_BOOT_COMPLETED I'm not able to get the event working with either a 2.3.3 or 3.2 emulator. Does anyone else have recent experience with this? And perhaps a code sample to share? steo Use a receiver: public class Receive extends BroadcastReceiver { if (intent.getAction() != null) {