screen size of emulator?

by mmkr » Thu, 10 Sep 2009 11:04:56 GMT


Sponsored Links
 Hai,

How can i get the screen size of my emulator?
i used

Display display = ((WindowManager) getSystemService
(Context.WINDOW_SERVICE)).getDefaultDisplay();
        int width = display.getWidth();
        Log.i("width",""+width);

But it gives me different values each time. How to find the exact
value?
--~--~---------~--~----~------------~-------~--~----~



screen size of emulator?

by Dianne Hackborn » Thu, 10 Sep 2009 11:35:54 GMT


 You generally don't, your views get told the size they should be as part of
the view hierarchy layout.  Directly getting the size of the display is not
recommended, because it may have no relation to the actual space your UI has
available (such as if there are other screen decorations around, like a task
switcher or who knows what).






-- 
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, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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


Sponsored Links


Other Threads

1. Force Close on Edit Contact

If this isn't the correct group to post to, sorry ahead of time, just
let me know and I'll move it :)

Was trying to edit a contact on a G1 running Cupcake today, and could
reproduce a force close any time I would go to "Edit Contact".  Here's
a stacktrace from one of the crashes:


I/ActivityManager(   56): Starting activity: Intent
{ action=android.intent.action.EDIT data=content://contacts/people/2
comp={com.android.contacts/com.android.contacts.EditContactActivity} }
D/AndroidRuntime(21135): Shutting down VM
W/dalvikvm(21135): threadid=3: thread exiting with uncaught exception
(group=0x4000fe70)
E/AndroidRuntime(21135): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime(21135): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.android.contacts/
com.android.contacts.EditContactActivity}:
java.lang.ArrayIndexOutOfBoundsException
E/AndroidRuntime(21135):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2268)
E/AndroidRuntime(21135):        at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
E/AndroidRuntime(21135):        at android.app.ActivityThread.access$1800
(ActivityThread.java:112)
E/AndroidRuntime(21135):        at android.app.ActivityThread$H.handleMessage
(ActivityThread.java:1692)
E/AndroidRuntime(21135):        at android.os.Handler.dispatchMessage
(Handler.java:99)
E/AndroidRuntime(21135):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(21135):        at android.app.ActivityThread.main
(ActivityThread.java:3948)
E/AndroidRuntime(21135):        at java.lang.reflect.Method.invokeNative
(Native Method)
E/AndroidRuntime(21135):        at java.lang.reflect.Method.invoke
(Method.java:521)
E/AndroidRuntime(21135):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime(21135):        at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:540)
E/AndroidRuntime(21135):        at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime(21135): Caused by:
java.lang.ArrayIndexOutOfBoundsException
E/AndroidRuntime(21135):        at com.android.contacts.EditContactActivity
$EditEntry.bindLabel(EditContactActivity.java:1849)
E/AndroidRuntime(21135):        at
com.android.contacts.EditContactActivity.buildViewForEntry
(EditContactActivity.java:1597)
E/AndroidRuntime(21135):        at
com.android.contacts.EditContactActivity.buildViewsForSection
(EditContactActivity.java:1532)
E/AndroidRuntime(21135):        at
com.android.contacts.EditContactActivity.buildViews
(EditContactActivity.java:1468)
E/AndroidRuntime(21135):        at
com.android.contacts.EditContactActivity.onCreate
(EditContactActivity.java:365)
E/AndroidRuntime(21135):        at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
E/AndroidRuntime(21135):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
E/AndroidRuntime(21135):        ... 11 more

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

2. nullPointerException in android.webkit.WebView.onTouchEvent

I override dispatchTouchEvent() like this:

        public boolean dispatchTouchEvent(MotionEvent ev)
        {
                WebView v=findViewById(R.id.detail);
                return v.dispatchTouchEvent(ev);
        }

I am getting intermittent NullPointerException like this:

07-03 18:03:54.530: ERROR/AndroidRuntime(1681):
java.lang.NullPointerException
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
android.webkit.WebView.onTouchEvent(WebView.java:3566)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
android.view.View.dispatchTouchEvent(View.java:3368)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:831)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
com.wth.xxxView.dispatchTouchEvent(xxxView.java:118)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchTouchEvent(PhoneWindow.java:1691)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1525)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
android.os.Handler.dispatchMessage(Handler.java:99)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
android.os.Looper.loop(Looper.java:123)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
java.lang.reflect.Method.invokeNative(Native Method)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
java.lang.reflect.Method.invoke(Method.java:521)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
07-03 18:03:54.530: ERROR/AndroidRuntime(1681):     at
dalvik.system.NativeStart.main(Native Method)

I verify that the variable v is never null. How come there can be
nullpointer exception happening in
android.webkit.WebView.onTouchEvent????
--~--~---------~--~----~------------~-------~--~----~

3. IllegalStateException when calling Preference.setDependency()

4. How to build a particular project on the repo (patch the android os)

5. Question about GENERATING key strokes and DYNAMIC selection of list items.

6. VMWare Image of the Android Emulator

7. Compiling video - how to display video full screen?