小编Nir*_*rel的帖子

以编程方式单击通知操作按钮

如何以编程方式单击通知操作按钮(另一个应用程序通知,而不是我的)?我可以使用button.performClick()方法单击一个普通按钮.我有无障碍服务来收听传入的通知(和Android 5.0+的通知服务监听器),那么,还有什么方法可以做到这一点?

例如,单击"打开省电模式"或"实际共享/删除"

...

在此输入图像描述

notifications android accessibilityservice

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

发送whatsapp消息给specfic contact

过去,您可以使用Google即时发送短信,环聊和电子邮件.但是,最近的更新将允许您使用该服务通过WhatsApp,Viber,WeChat,Telegram和NextPlus 发送消息.过程如下:

  • 说"好的,谷歌",然后等待应用程序开始收听.
  • 跟进"发送whatsapp消息到[联系人姓名]说[你的消息]"例如:"向杰夫发送一个whatsapp消息说你好吗?" 您将看到信息卡上显示的应用程序图标和您的消息,然后您可以通过说"是"或点击箭头按钮来确认发送.

那么,有一个选项可以从Google Now发送消息到Whatsapp,而不点击Whatsapp里面的发送按钮,这意味着有意图这样做,对吧?

所以,我的问题是,那是什么意图?我可以在自己的应用程序中使用它吗?

android whatsapp

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

Firebase推送通知更新数据库

我正在尝试通过新的Firebase推送通知服务向我的用户发送一些数据.

我正在使用"消息文本" - "dbupdate"添加一些"键值"自定义数据项,以检测它是更新消息还是我要向用户显示的正常推送通知.

在我的接收器中,我检查我是否有自定义数据并运行更新,如果为真.如果不是这种情况,我会通过短信显示正常通知.

它仅在我的应用程序打开时有效.如果应用程序关闭,则无论如何都会显示通知,而我的if检查甚至没有运行,

一些代码:

public class PushMessageService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        Map<String,String> data = remoteMessage.getData();
        String link = data.get("link");
        String name = data.get("name");
        if (link!=null) {
            Log.d("link",link);
            Log.d("name",name);
            UpdateHelper.Go(this, link, name);
        }
        else {
            NotificationCompat.Builder mBuilder =
                    new NotificationCompat.Builder(this)
                            .setSmallIcon(R.drawable.ic_shop_white_24dp)
                            .setAutoCancel(true)
                    .setContentTitle(remoteMessage.getNotification().getTitle())
                   .setContentText(remoteMessage.getNotification().getBody());
            NotificationManager mNotificationManager =
                    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(5, mBuilder.build());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这里举例说明

为什么会这样?即使应用程序关闭,我该怎么做才能运行我的代码?

android firebase firebase-notifications

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

Firebase UserProfileChangeRequest 不起作用

我正在尝试创建一个个人资料活动,用户可以在其中更改这些个人资料图片和显示名称,我正在尝试更新用户照片或用户名,已调用 CompleteListener,task.isSuccessful = true 但已完成,为什么?

更新名称的函数:

FirebaseUser mFirebaseUser = FirebaseAuth.getInstance().getCurrentUser();
final String newName;
newName = input.getText().toString();
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
.setDisplayName(newName)
.build();
mFirebaseUser.updateProfile(profileUpdates)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
DatabaseReference mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference().child("users");
   mFirebaseDatabaseReference.child(mFirebaseUser.getUid()).child("DisplayName").setValue(newName);
updateUI();
Toast.makeText(ProfileActivity.this, "User display name updated.", Toast.LENGTH_SHORT).show();
} else
Toast.makeText(ProfileActivity.this, "Error while updating display name.", Toast.LENGTH_SHORT).show();
}
});
Run Code Online (Sandbox Code Playgroud)

当我尝试更新我刚刚上传到 Firebase 存储的个人资料图片时也是如此...

和想法?

编辑:

有时用户名真的会更新,我想更新需要 10 多分钟,为什么?

android firebase firebase-authentication

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