在发布此问题之前,我已经看过以下链接
http://www.devx.com/wireless/Article/40792/1954
http://www.gitshah.com/2011/03/how-to-handle-screen-orientation_28.html
如果状态是由我的类组成的,如何在Android中的方向更改期间保存状态?
我没有得到如何覆盖以下功能:
@Override
public Object onRetainNonConfigurationInstance() {
return someExpensiveObject;
}
Run Code Online (Sandbox Code Playgroud)
在我的应用程序中,我有一个editext可见的布局,当第一个editext的数据验证为true时,其他editext可见.我已将所有其他editextes和textviews的可见性设置为false,并在验证后使它们可见.
因此,在我的活动中,如果更改了屏幕方向,则所有项目都将变为android:visibility="false"不可见.
我也知道当我们的活动屏幕方向改变时,它调用onStop()后跟onDestroy(),然后通过调用onCreate()再次启动一个新活动
这是原因..但我没有得到如何解决它..
在这里您可以看到我的应用程序的屏幕截图:
在此图像中,所有字段都被加载,而在另一个图像中,当屏幕方向变为横向时,它们都消失了

任何教程或代码片段的链接都会非常值得注意.
而且还当我的应用程序崩溃进度对话框显示了,我试图改变屏幕orientation.How来处理这个?
谢谢
我想要检测给定的设备是否是Android中的平板电脑或手机.我已经在模拟器中尝试了这两个但没有工作.两者都在这里:
第一
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
{
//code
}
Run Code Online (Sandbox Code Playgroud)
第二
private boolean isTabletDevice()
{
if (android.os.Build.VERSION.SDK_INT >= 11)
{
// honeycomb
// test screen size, use reflection because isLayoutSizeAtLeast is only available since 11
Configuration con = getResources().getConfiguration();
try {
Method mIsLayoutSizeAtLeast = con.getClass().getMethod("isLayoutSizeAtLeast");
Boolean r = (Boolean) mIsLayoutSizeAtLeast.invoke(con, 0x00000004); // Configuration.SCREENLAYOUT_SIZE_XLARGE
return r;
} catch (Exception x)
{
return false;
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud) 在我的应用程序全屏,我写这段代码:
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
.
.
.
Run Code Online (Sandbox Code Playgroud)
并在我的应用程序中保持屏幕我在布局中编写此代码:
android:keepScreenOn="true"
Run Code Online (Sandbox Code Playgroud)
虽然并非总是如此,但有时会像我这样错误:
java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:381)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:226)
at android.view.Window$LocalWindowManager.removeView(Window.java:432)
at android.app.Dialog.dismissDialog(Dialog.java:278)
at android.app.Dialog.access$000(Dialog.java:71)
at android.app.Dialog$1.run(Dialog.java:111)
at android.app.Dialog.dismiss(Dialog.java:268)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
我能做什么?我写真正的代码?谢谢...
CheckBox包含以下代码:
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);
}
}
});
Run Code Online (Sandbox Code Playgroud)
因此,当我检查它时,屏幕旋转到默认的系统方向(我的平板电脑的风景).
我需要冻结CURRENT方向.如果您将设备设置为纵向和切换CheckBox,则必须插入设备旋转,直到取消选中CheckBox.
Display.getRotation()不是解决方案,因为每个设备都有自己的Surface.ROTATION
我试图在我的代码中检测7"平板电脑(即Kindle Fire和Nook Color).但是,仅测试1024x600的最小尺寸并不好,因为那时Galaxy Nexus也会通过这个测试.任何人都有检测这个的经验那种信息?
谢谢,伊戈尔
编辑: 我找到了一种方法来检测Kindle Fire和Nook Color设备,代码如下:
Activity activity = (Activity) activityContext;
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = activity.getWindowManager().getDefaultDisplay().getWidth();
int height = activity.getWindowManager().getDefaultDisplay().getHeight();
if ((width == 1024 && height == 600) || (width == 600 && height == 1024)) {
//Detects 7" tablets: i.e. Kindle Fire & Nook Color
isTablet = true;
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一个简单的Android应用程序,我的要求是,
"在屏幕上的一些移动事件(MotionEvent.ACTION_MOVE为真)之后,如果用户停止移动几秒钟,而不是从屏幕上拿出手指,那么需要执行一些操作."
*我了解到LongPress是在用户在触发向下事件后没有进行任何移动时触发的事件(MotionEvent.ACTION_DOWN).*
那么有什么方法可以在屏幕上移动后触发LongPress吗?
或者我应该为相同的功能创建自己的监听器?
任何帮助表示赞赏.
谢谢.
在我的应用程序中是一个WebView小部件,它打开一个大页面.如何在WebView中捕获页面的可见部分?capturePicture()不适合它......
我想创建像Better Cracked Screen这样的东西.
破裂的屏幕仍然是最重要的.
我无法弄清楚如何制造出一切都位居首位的东西.
行为:例如,当显示破解的屏幕时,如果我按下主页按钮然后它显示我的家,但破裂的屏幕保持原样(这里在家的顶部)..无论你移动什么都没关系...破裂的屏幕看起来完好无损..
到目前为止的搜索结果:Google API演示:半透明GLSurfaceView
任何人都可以指导我如何实现这一任务?或者任何人都可以为我提供一个示例代码?
我想得到屏幕的压力.生病时,应用程序向我显示一条消息,Unfortunately, Application has stopped.我有另一个问题,当生病得到屏幕的压力可以转换成一个数学或物理的重量(克)?这是我的代码:
编辑:我在平板电脑上运行此应用程序
package com.realscale.stefanrafa;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.widget.TextView;
public class MainActivity extends Activity {
TextView textinfo;
MotionEvent pressure;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textinfo = (TextView) findViewById(R.id.Information);
float press = pressure.getPressure();
textinfo.setText("Scale: " + (int) press);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} …Run Code Online (Sandbox Code Playgroud) 我AVD用API 23那个做了一个,nexus 4它看起来像这样
Buttons & Manu在单独的面板中不是这样。
所以,我想知道是否Android Studio提供模拟器屏幕作为原始物理设备?而不是上面的第二张图片?或者我的emulator. 为什么我的emulator没有额外的面板buttons?
请指导我。
android android-virtual-device android-emulator android-screen android-studio
可以通过此代码防止Android应用程序屏幕截图
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
super.onCreate(savedInstanceState);
}
Run Code Online (Sandbox Code Playgroud)
但是在每个屏幕上都编写这段代码很麻烦。有什么方法可以在清单应用程序或任何地方声明它。
我有一项活动.我有一个过程,这很长.我改变了屏幕方向(纵向到横向),它们再次启动...我想在更改屏幕方向上禁用onCreate().
怎么让我这个?
android ×12
android-screen ×12
capture ×1
device ×1
java ×1
kindle-fire ×1
layoutparams ×1
screen-size ×1
screenshot ×1
tablet ×1