broadcastreceiver

When to unregister BroadcastReceiver? In onPause(), onDestroy(), or onStop()?

不想你离开。 提交于 2019-11-28 21:08:33
When should I use unregisterReceiver? In onPause() , onDestroy() , or onStop() ? Note: I need the service to run in the background. Update: I get an exception releasing receivers null . Activity has leaked intent receivers are you missing call to unregisterReceiver(); Please tell me if there's something wrong, here's my code: private boolean processedObstacleReceiverStarted; private boolean mainNotificationReceiverStarted; protected void onResume() { super.onResume(); try { registerReceivers(); } catch (Exception e) { Log.e(MatabbatManager.TAG, "MAINActivity: could not register receiver for

Android DownloadManager get filename

点点圈 提交于 2019-11-28 20:24:34
In my app you can download some files. I used the Android DownloadManager class for downloading. After the download is completed, it should show me a message that the file was downloaded. The problem is, there could be 2,3 or 4 downloads at the same time. My BroadcastReceiver code looks like this: receiver_complete = new BroadcastReceiver(){ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE) ){ Toast.makeText(MainActivity.this, MainActivity.this.getString(R.string.download_finished,

What triggers the BluetoothDevice.ACTION_ACL broadcasts?

眉间皱痕 提交于 2019-11-28 20:03:15
问题 I would like to know what events in remote physical devices trigger ACTION_ACL_CONNECTED and ACTION_ACL_DISCONNECTED in a listening device. My test results make no sense. I have gathered several devices within a few decimeters of each other: a Galaxy Tab P7500 running Android 3.1 an i5500 phone running Android 2.2 a WinXP PC with a bluetooth USB dongle two headsets with on/off buttons First, I pair manually with all devices from the Tab. Neither the PC nor the phone are paired with any other

Activity has leaked IntentReceiver

我只是一个虾纸丫 提交于 2019-11-28 20:02:31
I am trying to send sms amd mail together. There are no issues with sending mail, but when i send sms I receive this Exception: End has leaked IntentReceiver Are you missing a call to unregisterReceiver()? Here is my code for sms method: public class End extends Activity { Button btnSendSMS; EditText txtPhoneNo; EditText txtMessage; public EditText Details; public String user; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.end); Details = (EditText)findViewById(R.id

How to set an alarm to fire properly at fixed time?

安稳与你 提交于 2019-11-28 19:56:30
I have this code Calendar c = new GregorianCalendar(); c.add(Calendar.DAY_OF_YEAR, 1); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 22); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); // We want the alarm to go off 30 seconds from now. long firstTime = SystemClock.elapsedRealtime(); firstTime += 30*1000; long a=c.getTimeInMillis(); // Schedule the alarm! AlarmManager am = (AlarmManager)ctx.getSystemService(Context.ALARM_SERVICE); am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, c.getTimeInMillis(), 1*60*60*1000, sender); It is not executed at 23:22h What I am doing

BroadcastReceiver: can't instantiate class; no empty constructor

核能气质少年 提交于 2019-11-28 19:08:10
I have inner class as broadcast receiver: public class ManualBacklightReceiver extends BroadcastReceiver { public static final String ACTION_MANUAL_BACKLIGHT = "com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT"; public ManualBacklightReceiver() { } @Override public void onReceive(Context context, Intent intent) { Log.d("ManualBacklightReceiver", intent.getAction()); } }; AndroidManifest: <receiver android:name=".statusbar.powerwidget.PowerWidgetGrid$ManualBacklightReceiver"> <intent-filter> <action android:name="com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT"/> </intent

Screen on/off broadcast listener for a widget on Android Oreo

拟墨画扇 提交于 2019-11-28 18:52:29
I have a clock widget Android app which I am now trying to update to API 26 requirements. Up to now I used a background service which registered upon start in its onCreate method a BroadcastReceiver to receive system broadcasts, such as android.intent.action.SCREEN_ON, android.intent.action.SCREEN_OFF, android.intent.action.TIME_SET, android.intent.action.TIMEZONE_CHANGED . This service was then pausing the clock while screen is off and waking it up when screen is back on to save the battery. In Oreo a service of this kind does not seem to be an option, because it would have to run in the

how to start my application when ever mobile restart or turn on

点点圈 提交于 2019-11-28 14:39:45
How do i set my application as startup application, so when ever mobile restarts or turned ON, my application starts. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.installedapps22" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" /> <application android:icon="@drawable/cherry_icon" android:label="@string/app_name"> <activity android:name=".MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action

Android Service Listener for the wakelock screen

感情迁移 提交于 2019-11-28 14:37:37
Hii all, Im developing an emergency calling application. What i want is when some person uses this specific code the phone will unlock and then only my application would be running. Im juz thinking i need a reciever for it and just wondering wether i will have to create my own Home screen and a lock screen for my application. any ideas on this please??? many thanks in advance :) Jake Basile There is no sanctioned way to replace the lock screen. See Is there a way to override the lock pattern screen? The previous answer was to another question that got merged with this one: I would look into

How do I register in manifest an *inner* MEDIA_BUTTON BroadcastReceiver?

ε祈祈猫儿з 提交于 2019-11-28 14:04:20
I managed to get my headset buttons get recognized by my app when pressed, but one of the buttons needs to call a method that's in MyCustomActivity. The problem is onReceive's 1st parameter is a Context that cannot be cast to Activity and so I am forced to implement my BroadcastReceiver as an inner class inside MyCustomActivity. So far so good but how do I register this inner MediaButtonEventReceiver in the manifest? For the independent class, this was simple: <receiver android:name=".RemoteControlReceiver"> <intent-filter> <action android:name="android.intent.action.MEDIA_BUTTON" /> </intent