CWAC更新程序问题与通知

时间:2014-04-15 06:21:51

标签: android commonsware-cwac

我正在使用此库https://github.com/commonsguy/cwac-updater为应用提供自动更新功能。

我为demoUpdater阅读API使用已弃用的Notification,因此我使用了以下代码:

ConfirmationStrategy buildPreDownloadConfirmationStrategy(Context mContext) {

        long[] vibrate = { 0, 100, 200, 300 };
        NotificationManager mNotificationManager= (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);

        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(mContext)
        .setSmallIcon(R.drawable.ic_launcher)
        .setContentTitle("Update Available")
        .setContentText("Click to download the update!")
        .setVibrate(vibrate)
        .setAutoCancel(true)
        .setLights(Color.BLUE, 500, 500);
        mNotificationManager.notify(1, mBuilder.build());
        return null; 

        //return(new NotificationConfirmationStrategy());
    }

但无法让它发挥作用。

1 个答案:

答案 0 :(得分:1)

我开始工作,如果有人发现问题,请使用下面的代码

ConfirmationStrategy buildPreDownloadConfirmationStrategy(Context mContext) {

        long[] vibrate = { 0, 100, 200, 300 };
        NotificationManager mNotificationManager= (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);

        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(mContext)
        .setSmallIcon(R.drawable.ic_launcher)
        .setContentTitle("Update Available")
        .setContentText("Click to download the update!")
        .setVibrate(vibrate)
        .setAutoCancel(true)
        .setLights(Color.BLUE, 500, 500);
        Notification notification = mBuilder.build();
        mNotificationManager.notify(1, notification);

        return(new NotificationConfirmationStrategy(notification));
    }