android-screen

How to detect 7" Android tablet in code

三世轮回 提交于 2019-12-21 22:36:39
问题 I am trying to detect 7" tablets in my code (i.e. Kindle Fire & Nook Color). However, simply testing for minimum dimensions 1024x600 is not good, because then the Galaxy Nexus would pass this test as well. Anybody has experience with detecting this kind of information? Thanks, Igor EDIT: I have found one way to detect Kindle Fire & Nook Color devices with the following code: Activity activity = (Activity) activityContext; activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

Android screen resolution

限于喜欢 提交于 2019-12-20 10:58:06
问题 There are some screen resolutions already defined in Android. They are: QVGA (240×320, low density, small screen) WQVGA (240×400, low density, normal screen) FWQVGA (240×432, low density, normal screen) HVGA (320×480, medium density, normal screen) WVGA800 (480×800, high density, normal screen) WVGA854 (480×854 high density, normal screen) How do I know which type my device screen resolution is? 回答1: Use DisplayMetrics to get screen info from your device. Sample code: DisplayMetrics dm = new

How to detect screen pressure on android?

让人想犯罪 __ 提交于 2019-12-20 04:19:40
问题 I want to get the pressure of the screen. When ill run the application displaying me a message Unfortunately, Application has stopped. I have another question when ill get the pressure of the screen does its possible to convert in a weigh ( grams ) with some math or physic ? Here is the code i have: EDIT: I'm running this application on tablet package com.realscale.stefanrafa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MotionEvent;

Freeze screen orientation

≯℡__Kan透↙ 提交于 2019-12-20 03:21:13
问题 There is CheckBox with following code: CheckBox cb = (CheckBox)findViewById(R.id.freezer); cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } } }); So, when i check it, screen is rotated to default system orientation

Freeze screen orientation

最后都变了- 提交于 2019-12-20 03:21:08
问题 There is CheckBox with following code: CheckBox cb = (CheckBox)findViewById(R.id.freezer); cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } } }); So, when i check it, screen is rotated to default system orientation

How to prevent automatic screen lock on android by code?

丶灬走出姿态 提交于 2019-12-18 11:04:40
问题 In my app there is a long loading process, and if the devices puts on the screen lock, my process stops for some reason. How can i prevent the device from automatic screen lock? 回答1: you have to declare this uses-permission on AndroidManifest: <uses-permission android:name="android.permission.WAKE_LOCK" /> And in your code Activity: PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); WakeLock wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE

Android: Showing wrong screen resolution

你。 提交于 2019-12-17 06:50:13
问题 I was trying to get the screen resolution of android phones,using this code DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); str_ScreenSize = dm.widthPixels + " x " + dm.heightPixels; str_ScreenSize = "dd" + " x " + dm.heightPixels; When i tried this code in my Galaxy S phone i got the screen resolution as 320x533 px, but in reality the Galaxy S got a screen resolution of 480x800 px. So what's wrong with the code?? How can i get the actual

Can LongPress trigger after move events?

▼魔方 西西 提交于 2019-12-13 17:08:10
问题 I am working on a simple android app, my Requirement is, "After some move events(MotionEvent.ACTION_MOVE is true) on the screen, if the user stops moving for few seconds some where with out taking finger from the screen, then need to perform some action." *I learnt that LongPress is something which triggers when user doesn't make any move after the down event is triggered(MotionEvent.ACTION_DOWN).* So is there any way to trigger LongPress after Moving around in the screen? Or should I create

Difference between the declared size in inches and the size obtained using DisplayMetrics

三世轮回 提交于 2019-12-11 06:22:18
问题 I have got a Samsung Galaxy S4 Active When I execute on Android, the following code: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width=dm.widthPixels; int height=dm.heightPixels; int dens=dm.densityDpi; double wi=(double)width/(double)dens; double hi=(double)height/(double)dens; double x = Math.pow(wi,2); double y = Math.pow(hi,2); double screenInches = Math.sqrt(x+y); I obtain width = 1080 heigh = 1920 dens = 480 So, is the used

Android Different Values Folder For Different Screen Sizes

强颜欢笑 提交于 2019-12-11 04:17:08
问题 i have an issue for my application. I want to define different view width and height dimensions or different text sizes for different screen sizes. I've defined different values folders for screen resolution as other question and Android documentation said. But i have a problem for this way. For example Samsung Galaxy S5 uses "values-sw320dp-xxhdpi" folder and Samsung Galaxy S3 Mini uses "values-sw320dp-hdpi" folder according to my tests. If i don't have sw-320dp-xxhdpi folder, i expected