broadcastreceiver

Close application from broadcast receiver

£可爱£侵袭症+ 提交于 2019-12-01 05:40:41
问题 I'm new in android programming. I've tried registering broadcast receiver in activity, but my receiver not working when apps onPause. So i found that i need to registering my receiver in manifest. My objective is to close my application for some time after user turn off Wifi. This is my code but its not working. public class ReceiverWifi extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Handler handler = new Handler(); Runnable runnable = new

Obtaining usb cable plugged IN/OUT event using EXTRA_PLUGGED does not work

给你一囗甜甜゛ 提交于 2019-12-01 05:22:22
My intention is to have saved in Preferences current status of Android device usb/power cable: connected/disconnected. From Developer site I see that there are two Intent for obtaining that status: ACTION_POWER_CONNECTED / DISCONNECTED. So I used same code as published at Developers: http://developer.android.com/training/monitoring-device-state/battery-monitoring.html in section Monitor Changes in Charging State. Manifest <receiver android:name=".PowerConnectionReceiver"> <intent-filter> <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/> <action android:name="android.intent

GCM push notifications on android 3.1 : disable broadcast receiver

我怕爱的太早我们不能终老 提交于 2019-12-01 05:21:32
There is the problem with android push notifications (GCM) on android 3.1 : when my app is CLOSED - broadcast receiver which should handle GCM push messages (Intents) is never called. In lower versions of android everything works just fine. Broadcast reciever is always called (even when app is closed). I know that from Android 3.1 there is new concept: when application is not running it is in "stopped" state: http://developer.android.com/about/versions/android-3.1.html#launchcontrols So if you want to start "stopped" application via Intent - you should add FLAG_INCLUDE_STOPPED_PACKAGES flag to

Broadcast receiver and pending intent : Show a toast

孤者浪人 提交于 2019-12-01 05:17:11
问题 The following is the code for an alarm that has to hit the BroadCast Receiver : Intent intentWithData = new Intent(context, TokenActivity.class); intentWithData.putExtra(Constants.ID,id); intentWithData.putExtra(Constants.POSITION, finalI); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 007, intentWithData, 0); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() +

Broadcast Receivers in Delphi XE5 Android

妖精的绣舞 提交于 2019-12-01 04:58:15
问题 How to use broadcast receivers in Delphi XE5 Android? The documentation is very poor about the Delphi XE5 and Android integration. 回答1: Currently there is no support in XE5 for broadcast receivers. It is needed in order to get the BlueTooth API implemented, for example. Some attempts can be found here. Update: Markus Humm filed two QC requests to get this working. QC 118435 Provide the ability to inherit from a Java class and QC 118683 Provide Delphi side implementation for Android

Check if Service is running from a Broadcast Receiver

怎甘沉沦 提交于 2019-12-01 04:13:38
I'll like to ask if it's possible to check a service is running from Broadcast receiver. I know that it's possible in Activity. Thanks for your precious help yes' it's possible to detect if service is running from anywhere you have available Context object: private boolean isMyServiceRunning(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (MyService.class.getName().equals(service.service.getClassName())) { return true; } } return false; }

Intercept INSTALL_REFERRER and then forward on to Google AnalyticsReceiver

吃可爱长大的小学妹 提交于 2019-12-01 04:10:36
I have written an install receiver to determine when an app has been installed via the Market. However, I also want to pass the INSTALL_REFERRER broadcast onto other receivers such as the Google Analytics AnalyticsReceiver if it is installed within the app. Importantly, I do NOT know if other receivers are installed as my receiver will be used by other developers within their apps. Currently, I receive the broadcast and when complete I call: AnalyticsReceiver receiver = new AnalyticsReceiver(); receiver.onReceive(context, intent); The issue is the AnalyticsReceiver class may not be present. So

NEW_OUTGOING_CALL not being called on Samsung Galaxy S

北战南征 提交于 2019-12-01 03:42:26
问题 Trying to intercept outgoing calls, and have a solution working well on nexus 1 stock android 2.2 HTC desire 2.2 Moto defy 2.1 But not on the Samsung Galaxy S running 2.1, anyone seen this? <receiver android:name="com.mypackge.OutGoingCallDetection" android:exported="true"> <intent-filter> <action android:name="android.intent.action.NEW_OUTGOING_CALL" android:priority="0" /> </intent-filter> </receiver> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> Update: the

Can't register receiver dynamically

孤街醉人 提交于 2019-12-01 03:41:17
Can't register receiver dynamically at boot. I have no activity. And I do not want to register it in the service. Boot Receiver where I register another receiver: package zzz.zzz.zzz; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; public class AutoStart extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if ((intent.getAction() != null) && (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))) { IntentFilter filter = new IntentFilter(Intent

Obtaining usb cable plugged IN/OUT event using EXTRA_PLUGGED does not work

徘徊边缘 提交于 2019-12-01 03:16:59
问题 My intention is to have saved in Preferences current status of Android device usb/power cable: connected/disconnected. From Developer site I see that there are two Intent for obtaining that status: ACTION_POWER_CONNECTED / DISCONNECTED. So I used same code as published at Developers: http://developer.android.com/training/monitoring-device-state/battery-monitoring.html in section Monitor Changes in Charging State. Manifest <receiver android:name=".PowerConnectionReceiver"> <intent-filter>