我想在窗口打印上更改纸张模式(方向).我想以编程方式更改它,但我找不到任何东西.
window.print()
但我不知道,我怎么能这样做.
@media print{@page {size: landscape}}
Run Code Online (Sandbox Code Playgroud)
我不需要它.
function printWindow()
{
window.print({
/*
some code here?
*/
});
}
Run Code Online (Sandbox Code Playgroud) 这是我的BroadcastReciever类。该类正在处理启动电话状态。
代码;
public class BroadCastRecieverBoot extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent ?ntent) {
if(Intent.ACTION_BOOT_COMPLETED.equals(?ntent.getAction()))
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(new Intent(context, MyService.class));
context.startForegroundService(new Intent(context, GPSTracker.class));
} else {
context.startService(new Intent(context, MyService.class));
context.startService(new Intent(context, GPSTracker.class));
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我得到这个错误;
android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1792)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
Run Code Online (Sandbox Code Playgroud)
现在,它不适用于Android Oreo。我不知道那是什么错误。