小编tha*_*guy的帖子

Android无法通过AlarmManager传递intent附加功能

我试图在我的意图中添加一条额外的消息,以便传递给稍后触发的AlarmManager.我的onReceive正确触发,但extras.getString()返回null

建立:

public PendingIntent getPendingIntent(int uniqueRequestCode, String extra) {
    Intent intent = new Intent(this, ActionReceiver.class);
    intent.putExtra("EXTRA", extra);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, uniqueRequestCode,
            intent, 0);
    return pendingIntent;
}

public void setSilentLater(TimeRule timeRule) {
    boolean[] weekdays = timeRule.getReoccurringWeekdays();
    int dayOfWeek = 0;

    for (boolean day : weekdays) {
        dayOfWeek++;
        if (day == true) {
            Calendar cal = Calendar.getInstance();

            AlarmManager alarmManager = (AlarmManager) this
                    .getSystemService(Context.ALARM_SERVICE);

            cal.set(Calendar.DAY_OF_WEEK, dayOfWeek);
            cal.set(Calendar.HOUR_OF_DAY,
                    timeRule.getStartTime().get(Calendar.HOUR_OF_DAY));
            cal.set(Calendar.MINUTE,
                    timeRule.getStartTime().get(Calendar.MINUTE));
            cal.set(Calendar.SECOND, 0);
            cal.set(Calendar.MILLISECOND, 0);

            alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
                    cal.getTimeInMillis(), 3600000 * 7, getPendingIntent(0, "RINGER_OFF"));
  } …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver alarmmanager android-pendingintent android-bundle

44
推荐指数
2
解决办法
2万
查看次数

Javascript准确地将HSB/HSV颜色转换为RGB

我需要准确地将HSB转换为RGB,但我不知道如何解决将小数转换为整数而不进行舍入的问题.这是我在colorpicker库中使用的当前函数:

HSBToRGB = function (hsb) {

    var rgb = { };
    var h = Math.round(hsb.h);
    var s = Math.round(hsb.s * 255 / 100);
    var v = Math.round(hsb.b * 255 / 100);

        if (s == 0) {

        rgb.r = rgb.g = rgb.b = v;
        } else {
        var t1 = v;
        var t2 = (255 - s) * v / 255;
        var t3 = (t1 - t2) * (h % 60) / 60;

            if (h == 360) h = 0;

                if …
Run Code Online (Sandbox Code Playgroud)

javascript rgb converter hsv hsb

39
推荐指数
4
解决办法
4万
查看次数

Windows手机广告无效

我正在尝试将广告整合到已经成功部署的应用中.但无论我做什么,我似乎无法让广告正常运作.我尝试过使用代码版本和drag n'drop gui版本.我都不能开始工作.

这就是我所看到的:当它启动时,它可能会闪烁一瞬间白色,广告应该是,但不过没有,没有添加.它识别它放在我放置的位置,当我将它放在按钮上时,按钮变得不可点击.总而言之,没有默认的"微软广告"图像弹出.我已经安装了广告SDK,并且已经成功地轻松地在其他项目中展示广告.

是什么赋予了?这是非常简单的页面,我无法弄清楚出了什么问题.我似乎也无法在任何其他页面上放置广告......我确实拥有Microsoft.Advertising.Mobile和Microsoft.Advertising.Mobile.UI包含在项目中,我的互联网正在运行(我有一个项目同时打开广告,它的工作原理)

<phone:PhoneApplicationPage 
    x:Class="AppName.AdPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    xmlns:my="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Margin="12,17,12,28">
            <TextBlock x:Name="PageTitle" Text="Thank You!" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Width="334" />
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0" Height="569" …
Run Code Online (Sandbox Code Playgroud)

windows-phone-7

12
推荐指数
1
解决办法
5291
查看次数

角度自定义ngIf指令'as'语法

我正在创建一个自定义* ngIf指令,以在加载时用占位符替换内容。我可以根据需要进行所有工作并在* ngIf指令之后对其进行建模(https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_if.ts)唯一不起作用的是as语法,但看不到任何引用或从何处开始。

*myCustomDirective="loading$ | async as result" 
Run Code Online (Sandbox Code Playgroud)

上面的方法不起作用,当loading $ observable发出数据时,结果是不确定的。显示占位符,但是按预期将其替换为内容。(尽管由于不确定的结果,内容还是有错误)

angular-directive angular2-directives angular

9
推荐指数
1
解决办法
707
查看次数

Android alarmManager setRepeating不触发

我试图在指定的时间设置一个警报,但它没有被我的reciver捕获.

建立:

Intent intent = new Intent(this, ActionReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

Calendar current = Calendar.getInstance();
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, (current.getTimeInMillis() + 60000),3600000, pendingIntent);
Run Code Online (Sandbox Code Playgroud)

这是我的收发器:

public class ActionReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras(); //breakpoint here that doesn't get triggered 
  }
 }
Run Code Online (Sandbox Code Playgroud)

我把这些值放在我的清单中:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<receiver android:name="com.project.ActionReceiver" android:enabled="true" />
Run Code Online (Sandbox Code Playgroud)

不确定有什么问题...谢谢!

android alarmmanager

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

启用 ivy 时的角度循环依赖

在我的 angular 项目中启用 ivy 后,一切都会编译,但是在浏览器中启动应用程序时,我在应用程序引导期间收到以下错误:

Error: Cannot instantiate cyclic dependency! ApplicationRef
    at throwCyclicDependencyError (core.js:5208)
    at R3Injector.push../node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js.R3Injector.hydrate (core.js:11763)
    at R3Injector.push../node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js.R3Injector.get (core.js:11590)
    at injectInjectorOnly (core.js:648)
    at ??inject (core.js:653)
    at injectArgs (core.js:730)
    at Object.factory (core.js:11858)
    at R3Injector.push../node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js.R3Injector.hydrate (core.js:11767)
    at R3Injector.push../node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js.R3Injector.get (core.js:11590)
    at injectInjectorOnly (core.js:648)
Run Code Online (Sandbox Code Playgroud)

我正在努力找出循环依赖的位置以及为什么在不使用常春藤时它可以正常工作。我尝试使用 madge (madge --circular --extensions ts ./) 但没有找到循环依赖。

编辑:我已经手动浏览了所有服务并验证它们之间没有循环依赖

circular-dependency angular angular-ivy

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

Cassandra查询时间长,并且在完全约束键时添加到memtable

我有一个Cassandra表,键看起来像这样:

PRIMARY KEY(("k1","k2"),"c1","c2"),)具有聚类顺序("c1"DESC,"c2"DESC);

当我完全约束查询时,它比我省略最后一个聚类键需要更长的时间.它还预先形成"添加到饲料记忆",无约束查询不会.为什么是这样?我知道以前这个查询不会将条目添加到memtable中,因为我已经将事物添加到memtable中时运行了自定义代码.此代码应仅在插入或修改内容时运行,但在我仅查询项目时开始运行.

编辑:我应该提到两个查询返回1行,它是相同的记录.

  activity                                                                                                                                                                          | timestamp                  | source        | source_elapsed | client
 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------+---------------+----------------+------------
                                                                                                                                                                 Execute CQL3 query | 2017-09-05 18:09:37.456000 | **.***.**.237 |              0 | ***.**.*.4
                                              Parsing select c2 from feed where k1 = 'AAA' and k2 = 'BBB' and c1 = '2017-09-05T16:09:00.222Z' and c2 = 'CCC'; [SharedPool-Worker-1] | 2017-09-05 18:09:37.456000 | **.***.**.237 |            267 | ***.**.*.4
                                                                                                                                          Preparing statement [SharedPool-Worker-1] | 2017-09-05 18:09:37.456000 | **.***.**.237 |            452 | ***.**.*.4
                                                                                                                     Executing single-partition query on feed [SharedPool-Worker-3] | 2017-09-05 18:09:37.457000 …
Run Code Online (Sandbox Code Playgroud)

cassandra cassandra-3.0

6
推荐指数
1
解决办法
227
查看次数

从角度服务通过管道传输时,rxjs catchError 不起作用

使用 redux 和 Angular,我有以下效果:

  @Effect()
  public authenticate: Observable<Action> = this.actions
    .ofType(AUTHENTICATE)
    .pipe(
      map((action: AuthenticateAction) => action.payload),
      switchMap(payload => {
        return this.userService.authenticateUser(payload.email, payload.password).pipe(
          map(auth => new AuthenticationSuccessAction({ auth: auth })),
          catchError(error => of(new HttpErrorAction({ error: error })))
        );
      })
    );
Run Code Online (Sandbox Code Playgroud)

服务:

  public authenticateUser(email: string, password: string): Observable<IAuthentication> {
    const formData: FormData = new FormData();
    formData.append('email', email);
    formData.append('password', password);
    return this.httpClient.post('/api/auths/useraccounts', formData) as Observable<IAuthentication>;
  }
Run Code Online (Sandbox Code Playgroud)

当 POST 失败时,HttpErrorAction 永远不会被调度。

rest error-handling rxjs redux angular

5
推荐指数
1
解决办法
4590
查看次数

Postgres 转换具有重复 ID 的 json

通过此选择:

json_agg(json_build_object("id", price::money))
Run Code Online (Sandbox Code Playgroud)

我得到的结果值:

[
  {"6" : "$475.00"}, 
  {"6" : "$1,900.00"},
  {"3" : "$3,110.00"},
  {"3" : "$3,110.00"}
]
Run Code Online (Sandbox Code Playgroud)

我想要这种格式的数据:

{
  "6": ["$475.00","$1,900.00"],
  "3": ["$3,110.00","$3,110.00"]
}
Run Code Online (Sandbox Code Playgroud)

当在服务器上查询或与 jsonb 一起使用时,ID 是重复的,并且只有一个键值对能够通过。

postgresql json aggregate-functions

3
推荐指数
1
解决办法
607
查看次数

Windows 8本地存储

我已经搜索了很多,但没有找到任何关于Windows 8 metro应用程序的本地存储的东西.有谁知道用基本save()load()函数创建本地存储数据库的任何简单方法?
我只需XAML要将一些数据绑定到一些数据(标题,描述等).在使用Isolatedstoragesystem之前我已经制作了windows phone 7应用程序,但很明显它对于Windows 8来说是不同的...文档也没有多少帮助>.<任何提示赞赏.

c# data-storage microsoft-metro windows-8

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

ngrx reducer属性在类型上不存在

我正在使用TypeScript 2.7.1和ngrx.我的动作看起来像这样:

import { Action } from '@ngrx/store';


export const HEALTH_FORM_CONTENT_CHANGED = '[setupHealthForm] Content Changed';
export const HEALTH_FORM_TITLE_CHANGED = '[setupHealthForm] Title Changed';


export class SetupHealthFormContentChangedAction implements Action {
    public type: string = HEALTH_FORM_CONTENT_CHANGED;
    constructor(public payload: { content: string }) { }
}

export class SetupHealthFormTitleChangedAction implements Action {
    public type: string = HEALTH_FORM_TITLE_CHANGED;
    constructor(public payload: { title: string }) { }
}
export type Actions
    =
    SetupHealthFormContentChangedAction
    | SetupHealthFormTitleChangedAction;
Run Code Online (Sandbox Code Playgroud)

我的Reducer看起来像这样:

import { Actions, HEALTH_FORM_TITLE_CHANGED, HEALTH_FORM_CONTENT_CHANGED } from './setup-health-form.actions';


export interface …
Run Code Online (Sandbox Code Playgroud)

typescript ngrx angular

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