Android :: How To Catch Screen On / Off Broadcasts?
Jul 17, 2009How can I catch SCREEN_ON/SCREEN_OFF broadcasts? I have tried for hours, but failed.
View 10 RepliesHow can I catch SCREEN_ON/SCREEN_OFF broadcasts? I have tried for hours, but failed.
View 10 RepliesSpecifically, I need a way of _not_ performing the onPause functionality I've implemented when it occurs because of a change in screen orientation.
View 9 Replies View RelatedIs it possible to write service that can catch any user's click on the touch screen and read text of the click no matter what application currently is active?
For example user click on browser or any other application and that service will know what word is written in the location of the screen.
I want to know whenever someone is called, calls, smsed or smses. I figured for the calls I'd use the phone state change to trigger when I should check the CallLog provider again. I couldn't see any direct way of getting broadcasts from the CallLog. Did I miss it?
For SMSes I'm having more trouble. I'd like to know whenever and SMS is sent or received. Being able to receive STATUS_ON_SIM_READ and STATUS_ON_SIM_SENT would be great, but from what I've read in the Sms Manager that would depend on the sending application. I can't seem to find any evidence of a default one that android places when it sends. I also couldn't find an sms log provider or anything similar.
App A has this Broadcast Receiver in its manifest (within <application>): Code...
View 1 Replies View RelatedI am trying to get the intent "android.intent.action.BOOT_COMPLETED" sent only to the receiver "com.android.mms.transaction.MmsSystemEventReceiver" as this triggers the sms notification to be updated and removed if there is no longer any unread sms's. The issue I have is I need to make sure the broadcast is only sent to the class above. If it goes to other receivers the phone could end up in an unknown state or something strange. The code below does not seem to work.
Intent intent = new Intent(); intent.setAction("android.intent.action.BOOT_COMPLETED");
intent.setClassName("com.android.mms", ".transaction.MmsSystemEventReceiver");
activity.sendBroadcast(intent);
This code does work but since it goes to all receivers I have noticed some errors starting to show up in logs etc.
Intent intent = new Intent();
intent.setAction("android.intent.action.BOOT_COMPLETED");
activity.sendBroadcast(intent);
I have started developing a tool, which should react on an outgoing call or sms and also to be started at boot time. The start at boot time does work properly, but I'm not able to receive the broadcasts for the outgoing calls.
Who can tell me, what is wrong with my code? For this, I added two receivers in my manifest and implemented the broadcast receivers:
manifest.xml: <receiver android:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver>
<receiver android:name=".TelephoneViewer" android:enabled="true" android:exported="true"
android:permission=""> <intent-filter> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.intent.action.PHONE_STATE" />
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter> </receiver>
TelephoneViewer.java: public class TelephoneViewer extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
Log.d(this.getClass().getSimpleName(), "Telephoneviewer.onReceive()");
Toast.makeText(context,"TelephoneViewer.onReceive()", Toast.LENGTH_SHORT).show(); }
I have two applications, one of which (B) implements a broadcast receiver. The application (A) which sends the broadcast, binds a permission to it which the receiver (B) shall possess. The problem is now: If I install the receiver (B) first and the sender (A) afterwards, the receiver will never receive the broadcast. I assume this happens because the installation of the receiver somewhere fails when it comes to the "uses permission" part of the manifest (because this permission is not yet registered/defined).
However, this issue should be resolved as soon as the sender (which defines the permission in the manifest) is installed, but unfortunately isn't. It does not even help to re-install the receiver. The only way to resolve the issue is to completely uninstall the receiver application and do a fresh install. Is this behaviour intended ("not a bug, a feature")?
Does the Alarm Clock broadcast any intents? I would like to be able to have my application automatically launch after a person's alarm clock goes off, and they press "dismiss" (rather than "sleep"). I assume that would require a receiver looking for a broadcast of some kind.
View 2 Replies View RelatedI am trying to register a Broadcast Receiver to receive broadcast events for the package events. Following is the code and my receiver in the manifest file. The log statment never happens, but I can clearly see the same broadcast firing for "HomeLoaders" (the Launcher) debug statements.
public class IntentListener extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.i("INTENT LISTNER:", intent.getAction()); } }
<receiver android:name="IntentListener" android:enabled="true" android:exported="true">
<intent-filter> <data android:scheme="package"></data>
<action android:name="android.intent.action.PACKAGE_ADDED"></action>
<action android:name="android.intent.action.PACKAGE_ADDED"></action>
<action android:name="android.intent.action.PACKAGE_CHANGED"></action>
</intent-filter> </receiver>
I have the following broadcast receiver:
public class MyRingModeReceiver extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
Logger.iLog("In my Receiver"); } }
I then have a service that onCreate does the following:
IntentFilter filter = new IntentFilter();
filter.addAction("android.media.RINGER_MODE_CHANGED");
registerReceiver(new MyRingModeReceiver() , filter);
When I place a call to the emulator and use the volume keys to modify (silence) the ringer
nothing happens.
We are designing a system with a PC base station and 100 Android mobiles communicating over WiFi. They will use XLM-RPC as the method of mobile to base station communication. However, sometimes the base station needs to broadcast a message to all mobiles. Should we use "http server push" for this, i.e., have the base station leave the connections open to all the mobiles? Is there a better way? Publish-subscribe is possible, but doesn't seem mature on Android yet.
View 1 Replies View RelatedI have custom view and once some action occur in it (say touch/key event) I'd like to call some code in my activity. My question is if broadcasts (intent filters/broadcast receivers) are good communication mechanism for such thing? If not, what is normal/android preferred way to do it?
View 5 Replies View RelatedI have two BroadcastReceiver registered. When the app is closed they both fire at the appropriate times and do the appropriate things. If the app is closed then killed (say with an AppKiller), the receivers never receive their broadcasts, and nothing happens. Presumably the same thing happens if the parent app is killed due to low memory, so how do I ensure those broadcasts are fired/received. The API states that even if the app is killed it should fire, does anyone else have experience with this situation? If it helps my manifest is:
<!-- receivers for AlarmManager -->
<receiver android:exported="true" android:label="Shift roster updating calendar."
android:name="com.skooter.shiftroster.backend.service.UpdateCalendar" >
</receiver> <receiver android:exported="true" android:label="Shift roster checking alarm."
android:name="com.skooter.shiftroster.backend.service.SetWakeup" >
</receiver>
and nothing esoteric is going on in the AlarmManager/BroadcastReceivers
public class SMSWidget extends AppWidgetProvider {
private static final String queryString = "@inpion";
private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
@Override
public void onReceive(Context context, Intent intent) {
//get SMS Message
if(intent.getAction().equals(SMS_RECEIVED)){
Bundle bundle = intent.getExtras();...............
in my app,i send sms but in home screen ,AppWidget cannot receive it,only notification can notify me,i want to the message frist was received in my AppWidget not appear in notification bar?
I'm writing an app dealing with JPEG pictures. The main Activity let the user slide between a set of pictures, but if these pictures are too large (imagine a set of pictures taken with a 12Mpix camera, not resized), the pre-loading of the second picture throws an OutOfMemoryException that leads to an immediate app VM shutdown whereas I surrounded my calls to BitmapFactory.decodeXXX() whit a try/ catch(Exception). So, the user gets an error message making him think the app is unstable, and the app didn't have any chance of telling him what really happened. How can I handle this a more "user friendly" way? Can I predict the memory size that will be necessary to load a compressed JPEG picture?
View 3 Replies View RelatedI can't seem to catch SQLiteConstraintException from SQLiteDatabase. Has anyone else encountered this?
View 2 Replies View RelatedI was in my jeep the other day when I heard a ad for some song and a itagging...That got me thinking. Now before the fanboy name calling starts, this is not a comparison to iPhone. I have never owned one, nor shall I ever. I think for the android based phone to compete more with the whole iphone market, I think we need to develop our own brand of iTagging, our own brand of iPhone docks, and our own version of iTunes. I understand that the iPhone has been out for a long time and has had the media market to back it up. Heres the thing. There are way more versions of android based phones that there will be of iPhones. I know that there are a lot of variations of the phones, but its nothing adapters cant fix for the docks. as for the itagging, and the itunes apps, its nothing a dev cant handle. I am not a Dev, nor am I a manufacturer, but Im sure some of us can find a friend of a friend who knows this guy that lives down the street to help out our cause...
View 9 Replies View RelatedThis would be some excellent support for the faithful Android developers. I have eight apps but live in Canada so I haven't been permitted to post them on the Market yet. Still I'm hoping Google might take this into account for Canadian developers who can't yet meet the sales criteria. I applied anyway and hope Google will respond so I can begin mobile testing.
View 2 Replies View RelatedI've tried, but couldn't find anything. Is there any way to determine that the key is longpressed?
View 2 Replies View RelatedThere is a site in the uk called m.catchuptv.com that steams live tv on to the phone. it was originally an iphone thing, but now works on android. The last couple of days it has stopped working where it times out and cant connect to the server. I dont know if its my phone (htc desire) or its the site. it works best over wi-fi.
View 3 Replies View Relatedi need to start a background deamon not just when an application need to bind with, i have searched a way to auto-start it. One interesting reply was given in this maillist and i wanna more explanation on the way to catch BOOT_COMPLETED_ACTION from an IntentReceiver? The previous thread that i have found on this maillist was this one:
" Use an IntentReceiver and catch the BOOT_COMPLETED_ACTION. Then in the IntentReceiver call Context.startService() (but use carefully, only when you really need a background service to run all the time). "
I want is that android phone catch sound and pictures,and I need get the sound and pictures data. I'm a rookie.
View 2 Replies View RelatedI want to listen the android standard exceptions to manage it. But I don't put try/cath in all my code. Anyone knows if i can redirect the error output to my code. I've seen this System.setErr method, but It doens't works for this purpouse.
View 2 Replies View Relatedhow can I catch a HTTP 403 error? I use the HttpURLConnection to establish a HTTP connection with Base Authentication. When the authentication fails I get a FileNotFoundException :-( Why I doesn't get a HttpResponseException?
View 2 Replies View RelatedMy application uses WebView to load javascript which calls into Java class (through webview javascript iterface). Can the JavaScript catch exceptions thrown from Java?
View 4 Replies View RelatedI have five screen in my application. While in performing one action in fifth screen I encountered with Stop Application message. On which, I am getting 3 times "Stop Application" msg box, which covers 3 previous screen and comes back to the first screen. I understand I must have encountered with Error may be IndexOutOfBoundException which I have not addressed it in my code. I was wondering why it asks for extra 3 times "Stop Application" system message. It is fine to display an "Stop Application" system message if I encountered an error in any screen it should stop that particular screen and should come to the next screen on. How can I trap/catch such incidents not to occur in the consecutive screen. If the above description is not clear at any place please let me know that I be more clear to you.
View 4 Replies View RelatedHow can I catch a phone keypress with the android SDK? I've been looking around for hours without finding anything.For example:
In some cases, I want to catch the message when a user presses the "hang up" button on the phone, and then discard the message before it reaches the OS.
Does anybody know how to catch the map zoom in/out event for Android 1.5?Before Android 1.5, I can use ZoomControls which has a setOnZoomInClickListener(). In order to get zoom controls, I can write like this:ZoomControls mZoom = (ZoomControls) mMapView. getZoom Controls(); But, since 1.5, the mMapView.getZoomControls() is deprecated. Instead of this, the documentation suggests using mMapView.setBuiltInZoomControls.Since 1.6, I can use ZoomButtonsController, which has a set OnZoomListener(). In order to get zoom button controls, I can write like this:ZoomButtonsController mZoom = (ZoomButtonsController) mMapView.getZoomButtonsController().setOnZoomListener(this);So, how can I get map zoom in/out event without using mMapView.getZoomControls() for Android 1.5 ?
View 3 Replies View RelatedI'm clearly a newb, and I was wondering if anyone knows how I can detect a "ring" event on my cellphone through the android sdk? Generally I want to do something with the phone when it begins ringing! Any thoughts? If you want to simply point me to a page in the api documents that would be a good answer for me, I just don't know how to start my research!
View 1 Replies View Related