我有一个后台服务,调用GoogleAuthUtl.getTokenWithNotification它,它正常工作,但我正在尝试实现此功能的回调部分,但是无法正常工作.
我已经实现了一个广播接收器并将其添加到清单中,我的应用程序中也有一个活动.以下是相关的代码段.
GoogleAuthUtil.getTokenWithNotification
GoogleAuthUtil.getTokenWithNotification(this.getContext(), account, "oauth2:" + GmailScopes.GMAIL_SEND, null, new Intent(AuthReceiver.AUTH_INTENT));
Run Code Online (Sandbox Code Playgroud)
AuthReceiver
public class AuthReceiver extends BroadcastReceiver
{
public final static String AUTH_INTENT = "com.testoauth.AUTH_INTENT";
public AuthReceiver()
{
}
@Override
public void onReceive(Context context, Intent intent)
{
Log.d("RECEIVER", "Received Auth broadcast.");
NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
}
}
Run Code Online (Sandbox Code Playgroud)
AndroidManifest
<receiver android:name=".AuthReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.testoauth.AUTH_INTENT" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
我不知道为什么它没有收到广播.我没有在日志中看到任何异常,并且没有任何迹象表明接收器完全被调用,它在调试时甚至不会在断点处中断.我做错了什么吗?
编辑
我正在使用min sdk 16和目标sdk 25
从GoogleAuthUtil.getTokenWithNotification API文档中:
此方法专门用于后台任务.如果出现需要用户干预的错误,此方法负责推送相关通知.在用户解决通知之后,广播回叫.如果用户取消,则不会触发回调.
无论用户是否取消,都不会触发回调.除了ActivityManager显示通知(Displayed com.google.android.gms/.auth.uiflows.gettoken.GetTokenActivity)的说法之外,没有迹象表明com.testoauth.AUTH_INTENT已经在日志中发送了指定的广播意图(在这种情况下)."收到的Auth广播".日志中也没有消息.
包含此功能( …
android google-authentication google-play-services google-oauth android-broadcastreceiver
这个问题与Android有关,因为我的需求存在于该域中,但问题仍然适用于整个Java; 我将在这里使用了一些Android的术语,如Activity,FragmentActivity,ListActivity,等...
我需要实现一个抽象基类,其中包含必须在整个应用程序中Activity使用的功能,更具体地说,每个必须使用此功能,但我希望它由基类自动处理.我的问题是,我有类似的应用程序内的许多不同类型的活动Activity,FragmentActivity并且ListActivity,所有这些都延长Activity(减去Activity当然).
由于基类中的代码对于每个实现都是完全相同的Activity,有没有办法避免代码重复并且需要为每种类型创建基类Activity?
我想避免的:
public abstract class BaseActivity extends Activity
{
public void onCreate(Bundle savedBundle)
{
// code goes here, will be the exact same for all these base classes
}
}
public abstract class BaseFragmentActivity extends FragmentActivity
{
public void onCreate(Bundle savedBundle)
{
// code goes here, will be the exact same for all these base …Run Code Online (Sandbox Code Playgroud) 我写了一个小的PowerShell脚本来向服务器发送请求并获得简单的XML结果.
PowerShell脚本
$xml = "<?xml version='1.0' encoding='utf-8'?><Search><ID>278A87E1-1BC2-4E19-82E9-8BBE31D67D20</ID></Search>"
$response = Invoke-RestMethod -Method Post -Uri "http://localhost/search" -ContentType "application/xml" -Body $xml
Run Code Online (Sandbox Code Playgroud)
就是这样,非常简单,我没有理由看到它失败了.我也尝试过脚本Invoke-WebRequest并且都失败了.返回的错误是Invoke-RestMethod : Value cannot be null. Parameter name: name.奇怪的是,当我监视这个时Wireshark,我看到了连接,我看到了POST,我看到了服务器的结果,所有看起来都非常好,但是cmdlet说它失败了(是的,返回代码是200).
如果我使用参数运行Invoke-WebRequest/ ,它运行正常,没有错误,并将结果保存到指定的文件; 如果你想知道就失败了.Invoke-RestMethod-OutFile-OutVariable
结果是一个xml文件,标头指定它是xml并且xml格式正确.
成功时的结果
<?xml version="1.0" encoding="UTF-8" ?>
<Result version="1.0" xmlns="urn:xmlns-org">
<searchID>{278a87e1-1bc2-4e19-82e9-8bbe31d67d20}</searchID>
<responseStatus>true</responseStatus>
<responseStatusStrg>MORE</responseStatusStrg>
<numOfMatches>40</numOfMatches>
</Result>
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么Invoke-XXXcmdlet返回错误以及我可以做些什么来修复它?同样,当我使用-OutFile参数时,它完全正常工作,即使失败,我也可以在脚本和服务器之间看到正确的对话Wireshark.
另外,如果我使用-Verbose它告诉我以下内容:
VERBOSE: POST http://localhost/search with -1-byte payload
VERBOSE: received X-byte response of content type …Run Code Online (Sandbox Code Playgroud) 我正在使用内存数据库中的 sqlite 运行单元测试,但遇到了一个问题。
当我使用 mysql 数据库执行测试时,以下比较正常工作
if ($item->user_id === Auth::id())
Run Code Online (Sandbox Code Playgroud)
如果数字匹配,它将评估为真,如果不匹配,它将评估为假。当我在内存数据库中使用 sqlite 时,条件语句将始终返回,false因为该user_id属性作为 astring而不是正确的int数据类型返回。
我读过一些帖子和评论,说这是 PHP 中 sqlite 的可配置内容,而其他人则说它无法更改。我想在我的测试中使用内存中的 sqlite 数据库,但如果我不能改变这种行为,我必须改变我的条件来使用,==而不是更严格的===. 如何更改 sqlite 查询的行为?
更新
我也试过将它添加到 sqlite 配置中
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'options' => [
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::FETCH_NUM => true,
],
],
Run Code Online (Sandbox Code Playgroud)
这也无济于事。
我创建了一个私有s3存储桶和一个Fargate集群,其中包含一个简单的任务,尝试使用python 3和从该存储桶中进行读取boto3。我已经在2个不同的docker映像上进行了尝试,其中一个我ClientError从boto 那里得到了一个说法HeadObject Bad request (400),而另一个我得到了NoCredentialsError: Unable to locate credentials。
映像中唯一真正的不同是,一个说错误请求正在正常运行,另一个说是我通过ssh手动运行到任务容器。因此,我不确定为什么其中一个图像说“请求错误”而另一个图像说“找不到凭据”。
我尝试了几种不同的IAM策略,包括(terraform)以下策略:
data "aws_iam_policy_document" "access_s3" {
statement {
effect = "Allow"
actions = ["s3:ListBucket"]
resources = ["arn:aws:s3:::bucket_name"]
}
statement {
effect = "Allow"
actions = [
"s3:GetObject",
"s3:GetObjectVersion",
"s3:GetObjectTagging",
"s3:GetObjectVersionTagging",
]
resources = ["arn:aws:s3:::bucket_name/*"]
}
}
Run Code Online (Sandbox Code Playgroud)
第二次尝试:
data "aws_iam_policy_document" "access_s3" {
statement {
effect = "Allow"
actions = ["s3:*"]
resources = ["arn:aws:s3:::*"]
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试的最后一个是构建策略:
resource "aws_iam_role_policy_attachment" "access_s3" …Run Code Online (Sandbox Code Playgroud) 我正在使用Caliburn.Micro并Modern-UI在WPF应用程序中.在modern-ui框架(即a UserControl)中的"页面"上,我试图使用a Conductor来切换当前视图.这是我到目前为止所得到的:
注意:为简洁起见,从源代码中删除了命名空间
现代ui窗口内的"页面"的XAML
<UserControl x:Class="ShellView">
<ContentControl x:Name="ActiveItem" />
</UserControl>
Run Code Online (Sandbox Code Playgroud)
ShellViewModel的来源(指挥)
[Export]
public class ShellViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly Test1ViewModel m_TestView1;
private readonly Test2ViewModel m_TestView2;
public ShellViewModel()
{
this.m_TestView1 = new Test1ViewModel();
this.m_TestView2 = new Test2ViewModel();
this.ActivateItem(this.m_TestView1);
}
}
Run Code Online (Sandbox Code Playgroud)
Test1View的XAML现在没有任何东西,只是普通的UserControl东西.
Test1ViewModel的源代码
public class Test1ViewModel : Screen
{
protected override void OnActivate()
{
//This DOES NOT show or fire, I even put a breakpoint to double check
Debug.Print("This should show in …Run Code Online (Sandbox Code Playgroud) 我在这里问这个问题是因为我对试图解决这个问题感到不知所措。我已经搜索过了,所有出现的东西都是有意义的,但也不适合我的情况。
我正在使用WPF和MVVM。Caliburn.Micro我有一个带有相应视图模型的 shell 窗口,该视图模型是 aConductor<Screen>.Collection.OnceActive和一个继承自 的屏幕Screen。我ActivateItem在 Conductor 的构造函数中调用以显示后续屏幕,它正确显示屏幕,但从未调用 Screen 的覆盖,OnActivate并且屏幕的IsActive属性设置为False。
这只发生在我第一次ActivateItem从 Conductor 调用时,所有其他调用都将正确调用OnActivate和OnDeactivate。
这对我来说毫无意义,我不知道发生了什么。我清理了解决方案,重建,甚至重新启动,但它仍然无法正常工作。下面是代码:
家长指挥
[Export]
public sealed class ShellViewModel : Conductor<Screen>.Collection.OneActive, IHandle<SimpleMessage>
{
private readonly DashboardViewModel m_Dash;
private readonly LoginViewModel m_Login;
private readonly IEventAggregator m_MsgBus;
[ImportingConstructor]
public ShellViewModel(DashboardViewModel dash, LoginViewModel login, IEventAggregator msgBus)
{
this.m_MsgBus = msgBus;
this.m_Dash = dash;
this.m_Login = login;
this.ActivateItem(this.m_Login);
} …Run Code Online (Sandbox Code Playgroud) 我在互联网上看到很多相互矛盾的信息Alfresco Share clustering.根据我的发现,看起来群集已从Alfresco Community版本中完全删除4.2 and above.
我确实找到了一些文档,显示Alfresco One 5有Share clustering,我注意到我可以启用hazelcast,Alfresco Community 5但集群根本不起作用.
有没有办法Alfresco Community 5在负载均衡器后面有多个实例,并且在共享实例之间发生了适当的同步/复制/集群?
android ×2
wpf ×2
alfresco ×1
amazon-iam ×1
amazon-s3 ×1
aws-fargate ×1
boto3 ×1
google-oauth ×1
inheritance ×1
java ×1
modern-ui ×1
pdo ×1
php ×1
powershell ×1
python-3.x ×1
sqlite ×1