Keep Screen On & Change Orientation

by naxtek » Thu, 12 Feb 2009 00:19:10 GMT


Sponsored Links
 Hi - After some help with this.

I am making an Android app which is currently coming along nicely -
I've hit upon a couple of stumbling blocks.


1) How do I stop the screen from going dim/off and the phone locking
while the application is running?

2) Can I force the phone to enter landscape mode on running my
application?

Thanks,
Andrew :)
--~--~---------~--~----~------------~-------~--~----~



Keep Screen On & Change Orientation

by Dianne Hackborn » Thu, 12 Feb 2009 01:57:35 GMT


 There is a flag in WindowManager.LayoutParams you can set to keep the screen
on.  (Please do NOT use the lower-level PowerManager class for this.)

Use android:screenOrientation on the activity in your manifest to force a
particular orientation mode.






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Is it possible to over-ride the Refund button on the Android app store ?

Hi,

This is very urgent:

Is it possible to over-ride the Refund button on the Android app
store ?

Thanks in advance.

Praful Bhatnagar

--~--~---------~--~----~------------~-------~--~----~

2. VM crash

Android VM crash in a Samsung Galaxy running a code good working with emulator.
My code call facebook rest service to get my friends info. But when I
get server response VM crash.
And I really need help.

Log is down here :
D/UiHandler( 1488): executeMethodForMessage mFacebook.execute AFTER
I/global  ( 1488): Default buffer size used in BufferedInputStream
constructor. It would be better to be explicit if an 8k buffer is
required.
D/UiHandler( 1488): executeMethodForMessage finally AFTER CharArrayBuffer
D/UiHandler( 1488): executeMethodForMessage buffer length256
D/UiHandler( 1488): executeMethodForMessage buffer length512
D/UiHandler( 1488): executeMethodForMessage buffer length768
D/UiHandler( 1488): executeMethodForMessage buffer length1024
D/UiHandler( 1488): executeMethodForMessage buffer length1134
D/UiHandler( 1488): executeMethodForMessage buffer length1390
D/UiHandler( 1488): executeMethodForMessage buffer length1646
D/UiHandler( 1488): executeMethodForMessage buffer length1902
D/UiHandler( 1488): executeMethodForMessage buffer length2158
D/UiHandler( 1488): executeMethodForMessage buffer length2414
D/UiHandler( 1488): executeMethodForMessage buffer length2670
D/UiHandler( 1488): executeMethodForMessage buffer length2926
D/UiHandler( 1488): executeMethodForMessage buffer length3182
D/UiHandler( 1488): executeMethodForMessage buffer length3438
D/UiHandler( 1488): executeMethodForMessage buffer length3694
D/UiHandler( 1488): executeMethodForMessage buffer length3950
D/UiHandler( 1488): executeMethodForMessage buffer length4206
D/UiHandler( 1488):
D/UiHandler( 1488):
D/UiHandler( 1488): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/UiHandler( 1488):
D/UiHandler( 1488):
D/UiHandler( 1488): (
logcat read: Invalid argument

Code is down here


HttpEntity entity = response.getEntity();
int i = (int)entity.getContentLength();
if (i < 0) {
   i = 1024;
}
String charset = getContentCharSet(entity);
if (charset == null) {
   charset = DEFAULT_CONTENT_CHARSET;
}
Reader reader = new InputStreamReader(new
BufferedInputStream(entity.getContent()));
CharArrayBuffer buffer = new CharArrayBuffer(i);
Log.d(LOG, "executeMethodForMessage finally AFTER CharArrayBuffer");
try {
  char[] tmp = new char[256];
  int l;
  while((l = reader.read(tmp)) != -1) {
      buffer.append(tmp, 0, l);
       Log.d(LOG, "executeMethodForMessage buffer length" + buffer.length());
   }
} finally {
   reader.close();
}
Log.d(LOG, "executeMethodForMessage finally AFTER close");

--~--~---------~--~----~------------~-------~--~----~

3. Status bar notifications only for touch screens ?

4. Relationship between Activities & Dialogs: Recommended usage suggestions.

5. Is it possible for me to create a custom window like android:windowNoTitle

6. Does anyone has the documentation of window manager?

7. Relationship between Activities & Dialogs: Recommended usage suggestions.