broadcastreceiver

Android: Update bluetooth rssi every second

强颜欢笑 提交于 2019-12-13 14:20:06
问题 I'm trying to display the bluetooth signal strength (rssi) evry second ( Timer() ) from detected device but i couldn't call onRecive() multiple times because Receiver Lifecycle. I need a way(idea) to refresh the RSSI, or some other way to measure a signal every second? Is it easier if the device is connected? App gives a constant value always: DeviceName 2b:3c:d5:6c:3x:0X 40 db Part of the app stored in Timer() method: BroadcastReceiver mReceiver = new BroadcastReceiver() { public void

Android BroadcastReceiver on BOOT_COMPLETED does not start alarm

为君一笑 提交于 2019-12-13 14:09:52
问题 I'm trying to use a relatively simple solution to execute some code on boot. Basically I want to schedule/reschedule an Alarm at boot to execute a certain task in the future. In my manifest I have: <uses-permission android:name="com.android.alarm.permission.SET_ALARM"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <receiver android:name="com.cswt.lcyairport.alarm.AlarmReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> <

Android pausing a broadcast receiver

帅比萌擦擦* 提交于 2019-12-13 12:51:59
问题 I've a Broadcast Receiver into my application that waits for the screen to go on/off. What I want to do is: public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { pause some seconds... ...do something } } How can I stop the current thread into the onReceive method? 回答1: You can't and you shouldn't pause the BrodcastReceiver neither postDelayed to a Handler(); You shouldn't stop it because that thread needs to do other stuff, so don't

How do I set a broadcast receiver

狂风中的少年 提交于 2019-12-13 12:24:04
问题 I want to set a broadcast receiver to run some function when it gets the broadcast message, in this example, I want to catch the download's manager intent: DownloadManager.ACTION_DOWNLOAD_COMPLETE I looked at the Android API examples and haven't found a way to do this 回答1: You should read this first: http://developer.android.com/reference/android/content/BroadcastReceiver.html Then look here for examples. Android Samples: http://developer.android.com/resources/samples/ApiDemos/src/com/example

Best approach for inter-app communcation without foregrounding them?

大憨熊 提交于 2019-12-13 12:06:58
问题 I have been struggling on how what would be the best approach for inter-app communication without foregrounding each app. I thought about using BroadcastReceivers to communicate between the two apps, but it appears that they must be registered in the manifest, making it difficult to bring the data to the activities. An example would be that one app would send its status to another indicating that it is ready to start running a session. However, I would like to keep the other app in the

How to create a notification that always run even after phone reboot?

不打扰是莪最后的温柔 提交于 2019-12-13 10:23:17
问题 I have set an alarm manager at a method setAlarm() at MainActivity that contain a date from firebase database and set an alarm based on that. This is pretty good when I try to run this. But when I try to reboot my phone before the alarm times up, nothing have been happened. I also have tried to create a Receiver that refer to a service. And from this service onHandleIntent(Intent intent) , I call MainActivity.setAlarm() . Also i have been added a permission boot complete at android manifest.

automatically sms read not working in android

…衆ロ難τιáo~ 提交于 2019-12-13 09:23:28
问题 public class SmsReceiver extends BroadcastReceiver { private static SmsListener mListener; @Override public void onReceive(Context context, Intent intent) { final Bundle data = intent.getExtras(); final Object[] pdus = (Object[]) data.get("pdus"); for (int i = 0; i < pdus.length; i++) { SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) pdus[i]); String sender = smsMessage.getDisplayOriginatingAddress(); //You must check here if the sender is your provider and not another one with same

android.net.WifiManager cannot be resolved to a variable

折月煮酒 提交于 2019-12-13 09:04:46
问题 I have this class in my MainActivity to detect Internet Connection and wifi scanning result. I am getting at the Moment this error "android.net.wifi.SCAN_RESULTS cannot be resolved to a type" at this inner MainActivity: class Receiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals( android.net.ConnectivityManager.CONNECTIVITY_ACTION)) { } else if(intent.getAction().equals(android.net.WifiManager.SCAN_RESULTS

how to catch and block unknown incoming calls

风格不统一 提交于 2019-12-13 09:04:00
问题 I have a problem. My receiver is run very succesfull but when on private numbers not work my code. private class MyPhoneStateListener extends PhoneStateListener { public void onCallStateChanged(int state, String incomingNumber) { Log.d("MyPhoneListener", state + " incoming no:" + incomingNumber); if (state == 1) { Cursor numaralar = NumaralariGetir(); while (numaralar.moveToNext()) { String numara = numaralar.getString(numaralar .getColumnIndex("numara")); if (incomingNumber.equals(numara)) {

Android - Saving location updates (using LocationServices API) from a Service

喜你入骨 提交于 2019-12-13 08:50:03
问题 I have set up an environment where the app receives location updates, which is handle on the onLocationChanged callback. // Setup the client. mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } // Register the location update. LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this); // Interface callback. Called every 5 seconds. @Override