Android : Preventing WakeLock Under-Locked Exception
Feb 4, 2010
I'm trying to implement a times WakeLock in my Application, so this is not a Service.
I want the wakelock to simply prevent screen dimming for 3 min. Looking through the docs, this seems simple enough, but I seem to randomly encounter a Under-Locked exception that I cannot pinpoint.
Here is my WakeLock-related code:
in onCreate: PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG); // Adjust time to include user's setting int timeout = WAKELOCK_TIME - Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, 0); if (timeout > 0) {mWakeLock.acquire(timeout);} ...
in onDestroy: if (mWakeLock != null && mWakeLock.isHeld() == true) { try { As you can see, I wrap the release and try to only execute it when necessary as a clean up only. I'm assuming that since I'm aquiring with a timeout, the PowerManager will handle the release in most cases when the timeout expires.
I don't have a copy of the logcat at the moment, but what seems to happen is I get the Under-Locked exception randomly, and at random times (it's not always when WAKELOCK_TIME elapses). The strange thing is that the exception does not point to my code - all the entries point to "internal" Android code.
It's hard to find examples of other people using aquire with timeouts. Any ideas what I could be doing wrong here?
View 6 Replies
Jul 7, 2010
I have a service that acts a download manager, downloading files in the background. I have aquired a partial wake lock while the downloads are going. When the downloads finish, I manually release the wakelock. Because I am paranoid, I acquired the wakelock also with a timeout. The problem I am seeing is that if I have already manually released my wakelock, when the timeout period expires an error is presented to the user (and adb logcat shows an under-locked wakelock exception).
Is there any way to use a timeout (as backup wakelock release in case the app force closes for some reason) without getting this error?
View 4 Replies
View Related
Jul 14, 2010
I created a sql lite database with the following columns:
static final String dbName="demoDB";
static final String tableName="Employees";
static final String colID="EmployeeID";
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("CREATE TABLE "+tableName+" ("+colID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+
colName+" TEXT, "+colAge+" Integer);");
I want to select all the records in the database like this and display them in a gridview:SQLiteDatabase db=this.getWritableDatabase();Cursor cur= db.rawQuery("Select "+colName+", "+colAge+" from "+tableName, new String [] {});String [] from=new String []{DatabaseHelper.colName,DatabaseHelper.colAge};
int [] to=new int [] {R.id.colName,R.id.colAge};
SimpleCursorAdapter sca=new SimpleCursorAdapter(this,R.layout.gridrow,c,from,to);
GridView grid=(GridView)findViewById(R.id.grid);
grid.setAdapter(sca);but i receive the following exception:java.lang.IllegalArgumentException: column '_id' does not exist.the db table does not have a column with name '_id'so what is wrong with this code
View 3 Replies
View Related
Aug 7, 2010
I have a sony ericsson X10, it has a security pattern lock on the phone. However this has gone off in my pocket and now the phone is locked. I can not remember the google email address for the phone and now i can not access the phone. Orange customer service has told me to get in touch with google, in order to delete the old account [whatever that may be] but there is no number for google customer service.
View 4 Replies
View Related
Sep 1, 2010
I have a problem with acquiring a WakeLock. It seems not to work. I am trying to acquire a FULL_WAKE_LOCK but neither the display gets enabled nor is my app able to perform tasks.
I am using the following permission: android.permission.WAKE_LOCK
My acquire code looks like this:
CODE:...........
What am i doing wrong?
Added another flag ACQUIRE_CAUSES_WAKEUP ... but no changes in behavior
All i am trying to do is, to play music and to wake my device up upon a certain event. The music is working perfectrly but the device stays black.
View 2 Replies
View Related
May 24, 2009
The new IntentService in Android 1.5 looks excellent for handling AlarmManager-initiated broadcasts for scheduled WAKEUP work...except I can't see that it uses a WakeLock anywhere, either in itself or Looper/MessageQueue.
Does this implicitly hold a WakeLock that I'm not seeing? Or would I need to create a WakingIntentService that has an active WakeLock so long as there are messages in the queue?
View 2 Replies
View Related
Jan 11, 2010
My WakeLock isn't keeping my device awake.
In OnCreate() I've got:
CODE:...............
Then:
CODE:........
The screen turns off before the timer finishes, how can I make the screen stay visible?
mWakeLock is a field previously declared like so: private PowerManager.WakeLock mWakeLock;
My device uses Android 1.6. I would really appreciate any help to resolve this.
View 2 Replies
View Related
Jun 7, 2010
I'm just wondering if I do this correctly; I'm programming a notification app which can display a notification when the phone is sleeping
Disable keyguard lock. Aquire a wake lock. show notification. Set alarm for timeout and reenabling keyguard and release wakelock is the user dont touches the screen. 4.1 User touches the screen, and I disable the timer. Do nothing more. Done and done 4.2 User dont touch the screen, so reenable keyguard and release wakelock. Phone sleeps again
Basically I'm wondering about point 4.1 the most. cancel the pendingintent for the alarm, and do nothing more? or should the keyguard and wakelock that are set be dealt with in some way?
View 1 Replies
View Related
Jun 14, 2009
I am trying to use a service to control a wakelock so I can permanently leave the screen on when my application is running. I create the wakelock and activate it in onCreate() and release it in onDestroy() however I get the error "wl cannot be resolved".
Can someone explain how I can get over this? Code below:
CODE:..................
View 2 Replies
View Related
Sep 11, 2010
I have a signal that puts my app to sleep for a given number of minutes (using AlarmManager) and then wakes it back up.Everything is working except the screen doesn't ever come on.I then release the wakelock when I'm sure that my app is up and running and connected again. However, the screen never comes on! The app only actually comes back to life when I hit the power button to wake up the screen manually.I'm developing on an HTC Hero.
View 1 Replies
View Related
Mar 26, 2010
I have a terrible bug in my widget. The widget is waken up using an AlarmManager (the update interval is chosen by users, ranging from 30 mins to 2 hours) to grab some data from the Internet and display it on the widget. I do not hold a wakelock since if the phone sleeps, just let it sleeps. There's no way to update the information since nobody will see it. If I put the phone in the basement (has no wi-fi or cell signal) for about an hour. the phone will definitely not update anything. However, when I get it back from the basement, the cell network could never be recovered again no matter how long I have waited (it just get an X on the cell signal icon on the notification bar) that I must restart the phone. May I know if a partial wake lock must be held on checking network availability?
Find the code skeleton as below:
CODE:.................
View 8 Replies
View Related
Apr 13, 2010
I have a service which, when started, does some stuff (like downloading files) typically taking about 2-3 minutes.
If I start this service and then immediately use the power button to switch off the screen, then I would expect the phone, at some point, to fall asleep. But it never seems to fall asleep while the service is still doing its stuff. At least, not on my Nexus One.
I'm not using a wake lock (though I do use WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON in the activity that monitors the service progress).
So is it true that I don't need to use a wake lock?
View 14 Replies
View Related
Oct 20, 2009
I have the following code in Oncreate of my activity:
CODE:.......................
View 15 Replies
View Related
Oct 18, 2010
I have a service that needs to write some data to the internal storage using RandomAccessFile. Do I need to use a WakeLock to make sure the data won't get corrupted if the service process gets killed?
View 14 Replies
View Related
Nov 19, 2008
what apps are you guys using to dial or speed dial. i am having a problem as if i use the log or dialer and when done with the call i have a tendendcy to accidently hit the screen and place a call unknowingly...at least untill my wife calls back about the conversation she overheard
View 17 Replies
View Related
Jun 13, 2009
I have an Android (1.5) application which needs to be constantly running when a button is pressed. So, when a button is pressed I would like the phone to remain on and not want the screen or CPU to time-out.
When another button is pressed I would like the phone to be back to normal and time-out as per user settings.
View 1 Replies
View Related
Jun 16, 2010
I have a timer that schedule a task to run every 5 minutes. This task send a request to a server, so I need to be sure that CPU is on so that wifi or 3g can be used.
So the first thing I do in my run() method is :
CODE:.........
And the last thing I do in the run() is : wl.release() ;
I would like not to release here to be sure my service will run in the next 5 minutes :
The question is : if the device is already in a sleep state, can I wake up it with my wl.acquire() ?
View 3 Replies
View Related
Aug 23, 2010
I have a static library, Foo, that is used by a shared library, Bar. Bar is the native shared library loaded by my Android app. Foo contains JNI functions that are only called by Java code and not by any C++ code in Bar. Because of this, those JNI functions get stripped out of the static library (Foo) when the shared library (Bar) is built. I'm currently using a slightly hacky method to prevent that from happening.So, in this case, is there a way to tell the compiler to not strip the JNI (or any) functions out when linking?
View 1 Replies
View Related
Aug 13, 2010
I've written a web-app in HTML and Javascript for iPhone and Android which involves the dragging and dropping images.You initiate the drag by holding your finger over the image for about a second. However, Android then pops up the message giving me the option to save the image, set it as wallpaper etc.How can I prevent Android from doing this? Is there a metatag I can use? Some javascript?
View 2 Replies
View Related
Feb 22, 2010
I have a Nexus One and while using Google Listen to listen to podcasts my screen lock will go into effect. Unfortunately, when this happens, the podcast audio pauses. I can set the screen timeout to a maximum of 30 minutes but some of the podcasts are longer than that.
Is there anyway to have Listen suspend the screen timeout while it is running?
View 1 Replies
View Related
Apr 26, 2010
I am workin on a video player app in which I want only the landscape orientation active coz right now when the user tilts the phone during video runtime, it restarts playback in that orientation.
How can I easily avoid this?
You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
View 4 Replies
View Related
Oct 6, 2010
Is it possible for a program to effectively and efficiently use partial wakelock without burning through a lot of battery? Tango, for example? I'm trying to decide if the partial wakelock usage is worth the video call ability.
View 1 Replies
View Related
Mar 20, 2010
Is there any way (the best way) to avoid this happening? I am using a ProgressDialog which has one cancel button. On clicking the cancel button I want to disable the cancel button and change the message to "Canceling...". That bit's easy. Only once the cancellation has been fully processed do I want to dismiss the dialog. The only way I can think of is to use a custom layout but I would rather keep the default dialog look and feel (rather than trying to simulate it with my own code).
View 4 Replies
View Related
Nov 22, 2010
I have read into the finish(); commands and the FLAG_ACTIVITY_CLEAR_TOP commands and also checked out Common Ware's answer on killing app, but I am not sure how to put this into my app.
Basically, I have a user click a button that takes them to the camera. The user then snaps a photo and it brings them to a layout view. The user then clicks a button that takes them to one of 2 views, depending on a some conditions.
The user is then allowed to either retake a photo, or go to the main menu (depending). My problem is, if the user goes back to the main menu, and snaps another, then another, etc...the activities stack, so when I click the 'Main Menu' button the app goes back through eached stack activity until finally it goes back to the main menu. Is there a way to kill each activity with one of these lines, so even if a user retakes a photo, they will only need to go back once to get to the main menu?
View 1 Replies
View Related
Sep 23, 2010
I have a ImageView acting as a top banner on top of a webview. The image of this banner is created in execution time dependending on the resolution of the device. The height of the banner is always the same for each resolution. The only thing that changes is the width, which changes according to the orientation. But, since the width changes and the height doesn't, I end up having sort of 2 images with different proportion. And this is way the scale down/up won't work out for me.
Another problem is that everytime the user rotates the screen, the banner image is created again but Android seems not to update the image and thus I have a banner missing part of it.
I thought about having a real big image that will fit for both landscape and portrait orientation. But this seems not to be a good idea since Android keeps resizing the image everytime so it will fit on the space of the ImageView.
I'm running out of ideas here. Can someone suggest something?
View 1 Replies
View Related
Jun 9, 2010
All activities in my application require a user to be logged-in to view. Users can log out from almost any activity. This is a requirement of the application. At any point if the user logs-out, I want to send the user to the Login Activity. At this point I want this activity to be at the bottom of the history stack so that pressing the "back" button returns the user to Android's home screen.
I've seen this question asked a few different places, all answered with similar answers (that I outline here), but I want to pose it here to collect feedback. I've tried opening the Login activity by setting its Intent flags to FLAG_ACTIVITY_CLEAR_TOP which seems to do as is outlined in the documentation, but does not achieve my goal of placing the Login activity at the bottom of the history stack, and preventing the user from navigating back to previously-seen logged-in activities. I also tried using android: launchMode ="singleTop" for the Login activity in the manifest, but this does not accomplish my goal either (and seems to have no effect anyway). I believe I need to either clear the history stack, or finish all previously- opened activities. One option is to have each activity's onCreate check logged-in status, and finish() if not logged-in. I do not like this option, as the back button will still be available for use, navigating back as activities close themselves. The next option is to maintain a LinkedList of references to all open activities that is statically accessible from everywhere (perhaps using weak references). On logout I will access this list and iterate over all previously-opened activities, invoking finish() on each one. I'll probably begin implementing this method soon.
I'd rather use some Intent flag trickery to accomplish this, however. I'd be beyond happy to find that I can fulfill my application's requirements without having to use either of the two methods that I've outlined above. Is there a way to accomplish this by using Intent or manifest settings, or is my second option, maintaining a LinkedList of opened activities the best option? Or is there another option that I'm completely overlooking?
View 2 Replies
View Related
Nov 18, 2010
As I say in the topic, I want my WebView to prevent from reloading the webpage when another activity comes to the foreground or just when the orientation is changed. The reason why is because the WebView content is generated by Javascript/AJAX almost completely. After searching on a couple of forums, I found out many people suggested to use "saveState" and "restoreState" methods, but when I look the documentation, it says:Please note that this method no longer restores the display data for this WebView. See savePicture(Bundle, File) and restorePicture(Bundle, File) for saving and restoring the display data.So, here I was using that savePicture and restorePicture as it follows:protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); some other lines
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
if (savedInstanceState == null){
loadInicialWebUi();
}else{ mWebView.restoreState(savedInstanceState);
boolean restoredPic = mWebView.restorePicture(savedInstanceState, new File("savedDisplayWebView.temp"));
Log.d(TAG, "restored Picture:" + restoredPic);
@Override protected void onSaveInstanceState(Bundle savedInstanceState) {
mWebView.saveState(savedInstanceState);
boolean savedPic = mWebView.savePicture(savedInstanceState, "savedDisplayWebView.temp");
Log.d(TAG, "saved Picture:" + savedPic);
super.onSaveInstanceState(savedInstanceState);
}And well, those logs were revealing that it saves the picture, but it couldn't restore it. I suspect there might be something about the File references, but I couldn't think of a better way of getting the reference of the File I created when saving the state.Anyone thrilled?
View 2 Replies
View Related
Sep 10, 2010
I'm developing an sms receiver, and i have included a KeyguardManager and a PowerManager to be able to disable the keyguard and turn on the screen if user would like to. This works great, but only once.
When a message is received, the keyguard gets unlocked and the screen is turned on, and it gives out a sound and vibration. But if i don't read the message right away, but let the device power off by screen time out, and i then receive another message while the last one is not read, the device does not turn the screen on again, and it does not give out a sound or vibration, until i turn on the screen manually, then the sound and vibration comes.
If i close all received messages, then my app is able to disable the keyguard and turn on the screen and give out a sound and vibration when a new message is received.Here is my code that is run when the keyguard should be unlocked and the screen should be turned on.
Code:
private void disableKeyGuard()
{
KeyguardManager km = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
kl = km.newKeyguardLock("SMSHandler");[code].....
View 11 Replies
View Related
Dec 6, 2013
I have a N7 2013 on stock KRT16S, and my biggest wake lock is AudioMix.
I'm rooted, using Greenify, and I even have Google Search uninstalled. I am not using GEL. People suggested turning touch sounds off, and I tried that too, but it didn't work.
what is this AudioMix wakelock? Is this like Audio_Out2 on the Nexus 4? Keyboard sounds or any sounds = wakelock? I also find it odd that considering I use my phone on vibrate 98% of the time, that the on my Nexus 4 and older phones, the speaker turns on when I press any button my phone. I thought system sounds wouldn't turn on? Quite interesting. Even in silent mode, the speaker turns on. I know this because my Nexus 4 speaker used to crack everytime it would turn on. To me that's an unnecessary wakelock that should ONLY happen if you're not in silent or vibrate."
View 6 Replies
View Related
Sep 3, 2010
I did an OS update this am and since doing so, I've noticed that all the apps are starting on their own. I'll run task killer to stop them. However, when I check my phone 5 mins later, another 6 have started. What's the best way to prevent apps from starting on their own?
View 1 Replies
View Related