最近学习wigdet,自己做了个桌面时间日历,显示当前的时间和日期,点击会打开一个设置的activity。
在onUpdate中通过setOnClickPendingIntent绑定的点击事件。程序写完之后运行游戏或者其它程序时,发现进程会被系统kill掉,导致时间和单击事件都失效,后来我在onUpdate中开启了一个Service负责更新时间,但是Service也会被kill掉。请教一下该如何处理?
在onUpdate中通过setOnClickPendingIntent绑定的点击事件。程序写完之后运行游戏或者其它程序时,发现进程会被系统kill掉,导致时间和单击事件都失效,后来我在onUpdate中开启了一个Service负责更新时间,但是Service也会被kill掉。请教一下该如何处理?
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
widgetViews.setOnClickPendingIntent(R.id.btn, pendingIntent);
for(int i= 0;i<appWidgetIds.length;i++){
Intent intent1 = new Intent(context,MainFrameActivity.class);
//创建一个pendingIntent。
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent1, 0);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
//绑定处理器
remoteViews.setOnClickPendingIntent(R.id.tqpic, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds[i], remoteViews);
}我是这样做的,开始是没有问题的,但是玩游戏或者别的时候,由于机子内存不足,进程被系统强制回收了之后再点击时就没有响应了。