screen

Android Java : Turn screen Off

泪湿孤枕 提交于 2020-01-01 05:39:08
问题 I am making an application that turn the screen ON and OFF with the proximity sensor. The proximity code is finished, but i got trouble using the screen controls. I have read that I should use, PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE); manager.goToSleep(int amountOfTime); For that, I need to grant special permissions in order to make it works, but I haven't figured out how to do it. Also, I have read about changing screen brightness WindowManager

How to get screen width dpi in ANDROID?

旧街凉风 提交于 2020-01-01 05:34:09
问题 How can I get the screen width dpi? DisplayMetrics metrics = getResources().getDisplayMetrics(); int f = metrics.densityDpi; // getWindowManager().getDefaultDisplay().getMetrics(metrics); int width = metrics.widthPixels; int dp = (int)(width / (metrics.density)); I do this, so lets assume my densitydpi is 120..and widthpixel 240.. via calculation i get 240/0.75.... so I have 320 widthdpi? However that's not the case....widthdpi is smaller then 320 I think...because 320 goes with me wrong in

What happens if I leave all of my images in the drawable-hdpi folder?

和自甴很熟 提交于 2020-01-01 04:14:07
问题 I have all of my images in the drawable-hdpi folder. And I finished all of my layouts for all screen sizes. But i forgot to put the images in the drawable-mdpi folder and drawable-ldpi folder. If a phone with an mdpi screen density were to download my application would it just use the images in the drawable-hdpi folder? Or would an error occur because there are no images in the mdpi folder? The only images in the mdpi and ldpi folder is the icon. 回答1: The phone is gonna take the images from

How can I make a ProgressDialog be cancelable by the back button but not by a screen tap?

徘徊边缘 提交于 2019-12-31 11:29:24
问题 I would like to make a ProgressDialog cancelable by the back button but not by a screen tap. Currently I use setCancelable(true) . However, in some newer devices a tap on the screen also cancels the ProgressDialog . I'd like to disable the screen tap action while the ProgressDialog is shown. 回答1: Use setCanceledOnTouchOutside(false). 回答2: Try this it will help you: ProgressDialog pd = ProgressDialog.show(main.this, "", "Loading. Please wait...", true); pd.setCancelable(true);` 来源: https:/

how to continuously display a file of its last several lines of contents

天涯浪子 提交于 2019-12-31 10:34:07
问题 I am trying to find a Unix command (combination, maybe) on how to continuously display a file of its last several lines of contents. But during this displaying, I want some of the top lines are always displayed on the screen top when the rolling contents reach the screen top. Is that possible? (1) Suppose I have file, "job.sta", the first 2 lines are: job name, John's job on 2013-Jan-30,... Tab1, Tab2, Tab3 0, 1, 2, 1, 90, 89 2, 89, 23 ... (2) This file is on its running, its contents are

how to continuously display a file of its last several lines of contents

♀尐吖头ヾ 提交于 2019-12-31 10:34:03
问题 I am trying to find a Unix command (combination, maybe) on how to continuously display a file of its last several lines of contents. But during this displaying, I want some of the top lines are always displayed on the screen top when the rolling contents reach the screen top. Is that possible? (1) Suppose I have file, "job.sta", the first 2 lines are: job name, John's job on 2013-Jan-30,... Tab1, Tab2, Tab3 0, 1, 2, 1, 90, 89 2, 89, 23 ... (2) This file is on its running, its contents are

Detecting a Mouse Click Anywhere on Screen with Java

非 Y 不嫁゛ 提交于 2019-12-31 05:15:10
问题 Is it possible to detect a mouse click anywhere on a screen, outside of my application? I have written an application to do this in C#, but would like to write a version of this in Java so that it can be run on several platforms. It looks like I can get the co-ordinates of the mouse at any time with java.awt.MouseInfo.getPointerInfo() but I am not sure as to how to listen for a mouse click. In C# I used GetAsyncKeyState to detect whether the mouse button was clicked, but obviously I cannot

Cocos2D 2.0 OpenGL errors?

只谈情不闲聊 提交于 2019-12-30 15:00:22
问题 In my app it was working fine in Cocos2D version 1.1. When I upgraded to 2.0rc0a, I just see a black screen now and I get the following 4 errors nonstop until I quit the application: OpenGL error 0x0506 in -[CCSprite draw] 532 OpenGL error 0x0506 in -[CCParticleSystemQuad draw] 461 OpenGL error 0x0506 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 543 OpenGL error 0x0506 in -[CCGLView swapBuffers] 280 So I googled this a bit and it seems that the app cannot find the shader files . What

Blackberry: select item in a list, return to previous screen

匆匆过客 提交于 2019-12-30 14:36:49
问题 I have prepared a very short test case (s. below) for my question. On a button click I would like to display a list of strings in a new screen. After the user selects one item in the list, the previous screen should be displayed again and the button label should be set to the selected string. My 2 problems are: From inside the menu I don't know how to pop the currently displayed screen How to pass the selected item from one screen to another (assuming I don't want to introduce a public

How do you tell Android not to scale images?

流过昼夜 提交于 2019-12-30 11:17:10
问题 I have some pictures in the /drawable folder, which to my understanding is intepreted as /drawable-mdpi. Now these images are scaled when being used (depending on the device). I don't want to add more pictures, because they don't exist. And I don't have the resources to create different res pictures. I just want the pictures to appear smaller on bigger devices. Is there a way of not scaling the images? I'd hate to have to hard-code all the picture sizes. This is the second question, as edits