broadcastreceiver

Broadcast receiver for GPS state?

元气小坏坏 提交于 2019-12-20 03:17:27
问题 Is there a way to be notified when the GPS is switched on/off? I noticed that when the device is switched off an then on again, getLastKnownLocation(provider) is null. So I want to save the location when the GPS is switched off to a database. 回答1: Register a BroadcastReceiver to listen for the LocationManager's PROVIDERS_CHANGED_ACTION Intent. This will be broadcast when the GPS provider (and other providers) is enabled / disabled. 来源: https://stackoverflow.com/questions/11446428/broadcast

How to make Android BroadcastReceiver work with AlarmManager?

走远了吗. 提交于 2019-12-20 02:57:19
问题 I have the following code to post intents: alarmMgr = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent("myLog"); intent.putExtra("message", new Date().toString()); alarmIntent = PendingIntent.getBroadcast(this, 0, intent, 0); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME,System.currentTimeMillis()+1000,5000,alarmIntent); And the following receiver: public class

How to make my ios app reactive to wifi change events

南笙酒味 提交于 2019-12-20 02:11:55
问题 Can an ios app (possibly not active) be notified if there is a change in wifi network connected to(getting disconnected from, or getting connected to new ntwk)? I am to build an app that (even in inactive state) should get notified when connected to a particular wifi network and do some stuff. In android i was able to achieve it using BroadcastReceiver is there any such facility in ios? Thanks, Praneeth. 回答1: We have a class called Reachability in iOS for detecting any network flicker

Android: BroadcastReceiver to restart killed/crashed app

ε祈祈猫儿з 提交于 2019-12-20 01:03:58
问题 I have an application and I would like to be able to restart it on the event of an error or a crash/app shutdown. I am familiar with how to register BroadcastReceivers , use alarms, etc. Is there any signal I could intercept that the app sends out when it shuts down? Or that the OS sends out when any app shuts down? 回答1: Is there any signal I could intercept that the app sends out when it shuts down? Or that the > OS sends out when any app shuts down? No and no, AFAIK. 来源: https:/

Android - Listening to NFC Adapter State Changed

有些话、适合烂在心里 提交于 2019-12-19 21:23:08
问题 I am trying to build an application which uses NFC. The goal is to display a DialogFragment containing a button link to go the settings and change it manually and when the feature is enabled, disable the DialogFragment. Problem: If the user enables/disables NFC using the icon in the pull down notifications tray , then the onPause/onResume doesn't get called and misses the condition entirely. I am sure there is a receiver that I can register to instead and respond appropriately in real time.

Cannot receive broadcast in ICS

只谈情不闲聊 提交于 2019-12-19 21:17:10
问题 I writing 1 app for Android 4.0, and it's started via broadcastreceiver. My code is below: In AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <receiver android:name="com.Android.Exercise.StartUpReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> <!--<action android:name=

PendingIntent get requestCode

你说的曾经没有我的故事 提交于 2019-12-19 16:54:54
问题 I use an AlarmManager to start a service. When i set up the AlarmManager i use the PendingIntent and use a unique requestCode which is equal to a id row in my database. PendingIntent pendingIntent = PendingIntent.getBroadcast(SettingsActivity.this, lecture.getId(), myIntent, 0); How can I retrieve that id in my service when it starts? I basically need only the requestCode parameter. I want to use that id to retrieve data from my database and show it in a notification. I have implemented all

How to programmatically answer a call in Android 4.0.3?

*爱你&永不变心* 提交于 2019-12-19 12:08:11
问题 So as the subject states I need to be able to answer a phone call programmatically in Android 4.0.3 on an HTC OneX. I have read several places that the MODIFY_PHONE_STATE permission has been revoked by Google so to do this task you need a work around. I have looked into two avenues so far: (1) Following Guy's post here and using a BroadcastReceiver (2) Using the following code to try and hit a key event through a shell command. final Runtime r = Runtime.getRuntime(); try { Process process = r

Can't call a Bluetooth BroadcastReceiver method in a Service

本小妞迷上赌 提交于 2019-12-19 11:44:12
问题 I have this Service class: public class BluetoothService extends Service { private static Activity mActivity; @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); this.registerReceiver(bluetoothReceiver, intentFilter); } @Override public void onDestroy() { if (bluetoothReceiver != null) { this.unregisterReceiver(bluetoothReceiver); } }

Restrict Broadcast Receiver to application

懵懂的女人 提交于 2019-12-19 10:24:11
问题 I am working on broadcast receiver and stuck in a problem. I am receiving a broadcast receiver in Manifest file. <receiver class=".MyClass" android:name=".MyClass"> <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> <action android:name="android.net.ConnectivityManager.CONNECTIVITY_ACTION" /> <action android:name="android.net.wifi.WIFI_STATE_CHANGED" /> </intent-filter> </receiver> this is working fine and it is calling MyClass whenever there is change in