Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓:设置通知图像_Android - Fatal编程技术网

Android 安卓:设置通知图像

Android 安卓:设置通知图像,android,Android,在我的项目中,我使用pushbot将通知推送到设备上。现在它正在显示应用程序徽标,但我希望显示一个特别的“R.drawable.alert”,而不是应用程序徽标。那么该怎么做呢。下面是自定义处理程序类的代码。我和推送机器人一起工作 自定义处理程序类 public class customHandler extends BroadcastReceiver { private static final String TAG = "customHandler"; @Overri

在我的项目中,我使用pushbot将通知推送到设备上。现在它正在显示应用程序徽标,但我希望显示一个特别的“R.drawable.alert”,而不是应用程序徽标。那么该怎么做呢。下面是自定义处理程序类的代码。我和推送机器人一起工作

自定义处理程序类

    public class customHandler extends BroadcastReceiver
{
    private static final String TAG = "customHandler";
    @Override
    public void onReceive(Context context, Intent intent)
    {
        String action = intent.getAction();
        android.util.Log.d(TAG, "action=" + action);
        // Handle Push Message when opened
        if (action.equals(PBConstants.EVENT_MSG_OPEN)) {
            //Check for Pushbots Instance
            Pushbots pushInstance = Pushbots.sharedInstance();
            if(!pushInstance.isInitialized()){
                com.pushbots.push.utils.Log.d("Initializing Pushbots.");
                Pushbots.sharedInstance().init(context.getApplicationContext());
            }

            //Clear Notification array
            if(PBNotificationIntent.notificationsArray != null){
                PBNotificationIntent.notificationsArray = null;
            }

            HashMap<?, ?> PushdataOpen = (HashMap<?, ?>) intent.getExtras().get(PBConstants.EVENT_MSG_OPEN);
            android.util.Log.w(TAG, "User clicked notification with Message: " + PushdataOpen.get("message"));

            //Report Opened Push Notification to Pushbots
            if(Pushbots.sharedInstance().isAnalyticsEnabled()){
                Pushbots.sharedInstance().reportPushOpened( (String) PushdataOpen.get("PUSHANALYTICS"));
            }

            //Start lanuch Activity
            String packageName = context.getPackageName();
            Intent resultIntent = new Intent(context.getPackageManager().getLaunchIntentForPackage(packageName));
            resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_CLEAR_TASK);

            resultIntent.putExtras(intent.getBundleExtra("pushData"));
            Pushbots.sharedInstance().startActivity(resultIntent);

            // Handle Push Message when received
        }else if(action.equals(PBConstants.EVENT_MSG_RECEIVE)){
            HashMap<?, ?> PushdataOpen = (HashMap<?, ?>) intent.getExtras().get(PBConstants.EVENT_MSG_RECEIVE);
            android.util.Log.w(TAG, "User Received notification with Message: " + PushdataOpen.get("message"));
        }
    }


}
公共类customHandler扩展了BroadcastReceiver
{
私有静态最终字符串标记=“customHandler”;
@凌驾
公共void onReceive(上下文、意图)
{
String action=intent.getAction();
android.util.Log.d(标记“action=“+action”);
//打开时处理推送消息
if(action.equals(PBConstants.EVENT_MSG_OPEN)){
//检查Pushbots实例
Pushbots pushInstance=Pushbots.sharedInstance();
如果(!pushInstance.isInitialized()){
com.pushbots.push.utils.Log.d(“初始化pushbots”);
Pushbots.sharedInstance().init(context.getApplicationContext());
}
//清除通知数组
如果(PBNotificationIntent.notificationsArray!=null){
PBNotificationIntent.notificationsArray=null;
}
HashMap PushdataOpen=(HashMap)intent.getExtras().get(PBConstants.EVENT\u MSG\u OPEN);
android.util.Log.w(标签,“用户点击通知并显示消息:”+PushdataOpen.get(“消息”));
//将打开的推送通知报告给推送机器人
如果(Pushbots.sharedInstance().isAnalyticsEnabled()){
Pushbots.sharedInstance().ReportPushOpen((字符串)PushdataOpen.get(“PUSHANALYTICS”);
}
//启动lanuch活动
字符串packageName=context.getPackageName();
Intent resultent=新的Intent(context.getPackageManager().getLaunchIntentForPackage(packageName));
resultint.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
结果.putExtras(intent.getBundleExtra(“pushData”);
Pushbots.sharedInstance().startActivity(resultIntent);
//收到推送消息时处理推送消息
}else if(action.equals(PBConstants.EVENT_MSG_RECEIVE)){
HashMap PushdataOpen=(HashMap)intent.getExtras().get(PBConstants.EVENT\u MSG\u RECEIVE);
android.util.Log.w(标记为“用户接收到带有消息的通知:”+PushdataOpen.get(“消息”));
}
}
}

您只需将图标上传到服务器,然后在服务器推送机器人>“自定义负载”中,写入图标的
Key=largeIcon
Value=URL

图像示例


这里有更多信息:

您需要做的就是将图标上传到服务器,并在服务器推送机器人>“自定义负载”中,写入图标的
Key=largeIcon
Value=URL

图像示例

更多信息请点击此处: