broadcastreceiver

How to get notified of each new image being visible to the gallery app?

半城伤御伤魂 提交于 2019-12-03 02:18:43
Background When the user downloads a new image or captures one using the camera, the gallery app will get updated to show the new images. I need to be notified of each new image as soon as it was created, no matter how it was created (camera, browser,...) , just as the gallery app shows. The problem As it turns out there is a mediaScanner Android component that is responsible for scanning all types of media files, and when it finishes, it's supposed to send an intent " MEDIA_SCANNER_FINISHED " (as shown on this example ) . So I've added the next code , hoping it will show a toast each time the

Android BroadcastReceiver or simple callback method?

白昼怎懂夜的黑 提交于 2019-12-03 01:43:37
问题 In my projects I am using BroadcastReceiver s as a callback from a long running thread (eg. notify the activity that a download was finished and send some response data from a Worker Thread so that the activity can display the appropriate message to the user..). To use BroadcastReceiver s I have to be careful to register and unregister the broadcast receiver each time I am using it and also have to care of what messages to send esspecialy when I am using this method for more different actions

android update widget from broadcast receiver

二次信任 提交于 2019-12-03 00:30:41
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 && appWidgetIds.length > 0) { for (int widgetId : appWidgetIds) { RemoteViews remoteViews = new

BroadcastReceiver not working when app is installed on sd card

自古美人都是妖i 提交于 2019-12-02 21:53:30
问题 I am creating a EventsManager app in which i have a BroadcastReciver which executes for BOOT_COMPLETED broadcast.this receiver has been used to re-register all the events with AlarmManager.If the app is installed on phone's memory the it works fine but in the case of sd card BOOT_COMPLETED broadcast is not being delivered to broadcast receiver. pls help.. 回答1: Quoting the documentation: In order for your application to consistently behave as expected, you should not allow your application to

Monitoring the Hotspot state in Android

不打扰是莪最后的温柔 提交于 2019-12-02 21:19:37
I'm new to android. I want to receive information via broadcastreceiver ( onReceive ) to know that if user enable/disable "Portable Wi-Fi Hotspot" (Settings->Wireless &Networks->Tethering & portable hotspot) . Check this link And I found that there is " android.net.wifi.WIFI_AP_STATE_CHANGED " but it was set to hidden. Any how I can use that ??? Thanks in advance to receive enable/disable "Portable Wi-Fi Hotspot" events you will need to register an Receiver for WIFI_AP_STATE_CHANGED as : mIntentFilter = new IntentFilter("android.net.wifi.WIFI_AP_STATE_CHANGED"); registerReceiver(mReceiver,

Difference between BOOT_COMPLETED and QUICKBOOT_POWERON on Android

纵饮孤独 提交于 2019-12-02 20:33:56
I have created BroadcastReceiver to schedule my Service execution every 30 seconds. This is what I have in AndroidManifest.xml : <receiver android:name="MyScheduleReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver> This is working great now, but only after I added QUICKBOOT_POWERON action. Before that I had only BOOT_COMPLETED and when I reboot emulator or phone while debugging, my service would never start. So my question is what is the difference between these

Broadcast receiver, check a checkbox preference state on bootup then send a notification

我的未来我决定 提交于 2019-12-02 20:14:08
问题 My problem is that when I try to read a checkbox preference state from a different activity on bootup then send a status bar notification. Then when the device boots the I get a force close error message popup then when I go into the error log I don't understand what happens. The code for the broadcast receiver is shown below: @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){ //this creates a reference to my

Is it possible to read the call cost history from dialogue raised after ending the prepaid call?

亡梦爱人 提交于 2019-12-02 18:29:54
Is there a possibility of handling the data displayed on call cost dialogue received by prepaid user. I want to save all the balance reduction for along with call duration in my sqlite db. As we learn from the already famous blog post As a start, look at the PhoneUtils class in the Android source code. [...] Specifically, looking at line 217, an intent with the name “com.android.ussd.IExtendedNetworkService” is being composed. So what you need to do is implement your own service that responds to that intent . The service needs to be implemented according to the IExtendedNetworkService.aidl

What is more efficient Broadcast Receiver or Handler?

白昼怎懂夜的黑 提交于 2019-12-02 18:21:38
I know that onReceive() of the Broadcast receiver and handleMessage() of Handler run on the same UI thread. Suppose I want to communicate between two services, within the same app (process) . I can extend a broadcast receiver class and register an event OR a Handler and then pass its instance to the other service to be used for sendMessage() calls. In both the cases I would need to add some new switch case. But which approach is more efficient ? Lets assume that the code is thread safe (no UI updations). I can extend a broadcast receiver class and register an event If you mean that you are

Broadcast receiver not receiving intent

女生的网名这么多〃 提交于 2019-12-02 18:17:23
I have two apps that I have complete control over. Both are signed with the same cert and both use the exact same intent filter. One sends the broadcast from a fragment, the other is suppose to receive it and do something. This however is not working: Strings.FILTER_INIT_REGISTER = "com.app.FILTER_INIT_REGISTER" Intent intent = new Intent(Strings.FILTER_INIT_REGISTER); getActivity().sendBroadcast(intent); I have registered the receiver in the Manifest app tag for the app containing the ReportingReceiver class: <receiver android:name=".receivers.ReportingReceiver" android:exported="true" >