相关疑难解决方法(0)

确定设备是智能手机还是平板电脑?

我想获得有关设备的信息,看看它是智能手机还是平板电脑.我该怎么做?

我想根据设备类型显示来自资源的不同网页:

String s="Debug-infos:";
s += "\n OS Version: " + System.getProperty("os.version") + "(" +    android.os.Build.VERSION.INCREMENTAL + ")";
s += "\n OS API Level: " + android.os.Build.VERSION.SDK;
s += "\n Device: " + android.os.Build.DEVICE;
s += "\n Model (and Product): " + android.os.Build.MODEL + " ("+ android.os.Build.PRODUCT + ")";
Run Code Online (Sandbox Code Playgroud)

但是,对我来说似乎没用.


这个解决方案现在适用于我:

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
int height = metrics.heightPixels;

if (SharedCode.width > 1023 || SharedCode.height > 1023){
   //code for big screen (like tablet)
}else{ …
Run Code Online (Sandbox Code Playgroud)

android device-detection

251
推荐指数
7
解决办法
16万
查看次数

锁定屏幕方向(Android)

可能重复:
如何在Android中禁用方向更改?

我正在编写一个使用不同内容(活动)的标签的Android应用程序.在其中一个活动中,我想将屏幕方向锁定为"Landscape"模式,但在其他活动中,我想要正常方向(根据传感器).

我现在正在做的是我正在打电话

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Run Code Online (Sandbox Code Playgroud)

当我切换到横向模式活动时,和

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
Run Code Online (Sandbox Code Playgroud)

当我切换回其他活动时.但是,这似乎不起作用,整个应用程序锁定.这个问题的正常方法是什么?

layout android orientation

146
推荐指数
3
解决办法
29万
查看次数

标签 统计

android ×2

device-detection ×1

layout ×1

orientation ×1