Phonegap方向锁确实无法正常工作

时间:2018-03-09 17:43:56

标签: cordova locking screen phonegap

我遇到PhoneGap和屏幕方向锁定问题。我在config.xml文件中使用它:

<preference name="Orientation" value="portrait" />

问题是Android设备上的屏幕没有锁定为肖像,如果传感器被激活,我的Android手机仍然能够旋转屏幕。我只在Android上测试了这个(我不知道在iOS上是否是同样的问题)。

我也尝试在onDeviceReady函数中添加它:

screen.orientation.lock('portrait');

也尝试了这个:

window.screen.orientation.lock('portrait');

没有办法锁定屏幕旋转。要构建apk文件,我使用此构建器:https://build.phonegap.com

1 个答案:

答案 0 :(得分:1)

当使用&#34;桌面应用程序&#34;的组合时,我观察到同样的事情。和#34;开发人员移动应用&#34;

function OpenURL(const URL: string; const DisplayError: Boolean = False): Boolean;
var
  Intent: JIntent;
begin
// There may be an issue with the geo: prefix and URLEncode.
// will need to research
  Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW,
    TJnet_Uri.JavaClass.parse(StringToJString(System.NetEncoding.TNetEncoding.URL.Encode(URL))));
  if TAndroidHelper.Activity.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then
  begin
    try
      TAndroidHelper.Activity.startActivity(Intent);
      exit(true);
    except
      on e: Exception do
      begin
        if DisplayError then ShowMessage('Error: ' + e.Message);
        exit(false);
      end;
    end;
  end
  else
  begin
    ShowMessage('Intent.resolveActivity <= 0');
  end;
end;

不行。我相信这是因为开发人员移动应用程序&#34;就像一个预制容器。

当我实际使用该服务构建然后下载并在我的手机上安装.apk时,屏幕旋转锁定工作。

相关问题