小编Zar*_*law的帖子

手机进入睡眠状态后,保持wifi在前台服务中处于活动状

我想在手机锁定时从wifi接收数据包.问题是,当我锁定屏幕时,我的前台服务停止接收数据包.我正在使用Foreground Service,如下所示:

public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
    var notification = new Notification.Builder(this)
        .SetContentTitle(Resources.GetString(Resource.String.app_name))
        .SetContentText(Resources.GetString(Resource.String.notification_text))
        .SetSmallIcon(Resource.Drawable.ic_stat_name)
        .SetContentIntent(BuildIntentToShowMainActivity())
        .SetOngoing(true)
        .AddAction(BuildRestartTimerAction())
        .AddAction(BuildStopServiceAction())
        .Build();


    // Enlist this instance of the service as a foreground service
    StartForeground(Constants.SERVICE_RUNNING_NOTIFICATION_ID, notification);

    /*DO THIS EVEN WHEN SCREEN IS LOCKED*/

    var powerManager = (PowerManager)GetSystemService(PowerService);
    _wakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial, "WakeLockTag");
    _wakeLock.Acquire();

    var wifiManager = (WifiManager)GetSystemService(WifiService);
    _wifiLock = wifiManager.CreateWifiLock(WifiMode.FullHighPerf, "xamarin_wifi_lock");
    _wifiLock.Acquire();

    if (!powerManager.IsIgnoringBatteryOptimizations("com.xamarin.xample.foregroundservicedemo") ||
        !_wakeLock.IsHeld || !_wifiLock.IsHeld)
        throw new InvalidOperationException("OPTIMIZATIONS NOT ACTIVE");

    string msg = timestamper.GetFormattedTimestamp();
    Log.Debug(TAG, msg); …
Run Code Online (Sandbox Code Playgroud)

c# android xamarin.android xamarin xamarin.forms

22
推荐指数
1
解决办法
1046
查看次数

ionic 2 ion-datetime ISO格式问题

我正在使用ion-datetime作为我的预约表格.插入它时工作正常没有任何问题.但是当我需要从后端更新插入的约会日期表单详细信息时,日期值不会显示在ion-datetime中.

以下是我的代码:

update.html:

<ion-item class="border-bottom">
      <ion-label  class="ionselect" >Appointment Date:</ion-label>
      <ion-datetime name="appdate" displayFormat="YYYY MMM DD" [(ngModel)]="leadDetailsUpdate.appt_date"></ion-datetime>
</ion-item>
Run Code Online (Sandbox Code Playgroud)

update.ts:

leadDetailsUpdate={
        appt_date:''
}; 
Run Code Online (Sandbox Code Playgroud)

我从后端获得的日期格式如下: appt_date: "2017-01-01"

以下是我在控制台中收到的错误消息:

Error parsing date: "null". Please provide a valid ISO 8601 datetime format: https://www.w3.org/TR/NOTE-datetime

javascript typescript ionic2 angular

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

为什么 Android 设备上 TabbedPage 中的页面标题默认为大写

为什么页面标题默认为大写TabbedPage

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/tabbed-page

此文档链接TabbedPage显示了示例,其中选项卡式页面标题在代码中为 Titlecase,但在 UI 上为大写。如下所示:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:local="clr-namespace:TabbedPageWithNavigationPage;assembly=TabbedPageWithNavigationPage"
            x:Class="TabbedPageWithNavigationPage.MainPage">
    <local:TodayPage />
    <NavigationPage Title="Schedule" IconImageSource="schedule.png">
        <x:Arguments>
            <local:SchedulePage />
        </x:Arguments>
    </NavigationPage>
</TabbedPage>
Run Code Online (Sandbox Code Playgroud)

日程页面

android xamarin xamarin.forms

2
推荐指数
1
解决办法
663
查看次数