首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android :设置通知图片

Android :设置通知图片
EN

Stack Overflow用户
提问于 2016-04-02 02:45:12
回答 1查看 268关注 0票数 1

在我的项目中,我使用push机器人将通知推送到设备上。现在它正在显示应用程序徽标,但我希望显示一个特定的"R.drawable.alert“,而不是应用程序徽标。那么该怎么做呢?下面我将发布Custom Handler类的代码。我正在和推送机器人合作。

自定义处理程序类

代码语言:javascript
复制
    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"));
        }
    }


}
EN

回答 1

Stack Overflow用户

发布于 2016-06-19 13:31:09

你所要做的就是将图标上传到服务器,并在服务器的pushbots >"Custom Payload“中写入Key=largeIconValue=URL of icon。

图像示例

更多信息请点击此处:PushBots tutorial

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36363669

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档