我们能否像我在cocos2dx中告诉的标题那样实现。我的意思是,当使用7天不开放应用程序(例如)。我们会推动一个通知,我们能实现它由Cocos跨平台吗?请帮帮忙。
发布于 2014-07-24 06:46:42
不能是跨平台的。因为cocos2d-x不能处理这个问题,但是没有人阻止你单独为不同的操作系统实现它,
您可以使用宏定义CC_PLATFORM_TARGET来编写目标代码。
像iOS一样实现how to create local notifications in iphone app
像Local Notifications in Android?一样实现Android
如果您需要帮助编写obj-c/c++混合代码,How can I use C++ with Objective-C in XCode
发布于 2014-07-24 06:44:28
我不明白您到底想要什么,但我认为要做到这一点,您可以使用这样的AlarmManager:
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR, heure); //choose here for a week
cal.add(Calendar.MINUTE, minute);
Intent intent = new Intent(this, MyBroadcastReceiver.class);
PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) this
.getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);并使用BroadcastReceiver作为通知,如下所示:
public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent resultIntent = new Intent(context,
YourActivity.class); //to open when click the notification
resultIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// Because clicking the notification opens a new ("special") activity,
// there's no need to create an artificial back stack.
PendingIntent resultPendingIntent = PendingIntent.getActivity(context,
0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification.Builder mBuilder = new Notification.Builder(context)
.setSmallIcon(R.drawable.courier_blanc)
.setContentTitle("Title")
.setContentText("Message");
mBuilder.setAutoCancel(true); //TODO enlever pour le mettre avec l'intent
mBuilder.setPriority(Notification.PRIORITY_MAX);
mBuilder.setContentIntent(resultPendingIntent);
// Sets an ID for the notification
int mNotificationId = 001;
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr = (NotificationManager) context
.getSystemService(Application.NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, mBuilder.build());
} }https://stackoverflow.com/questions/24926675
复制相似问题