Android 为什么过了一段时间我的程序被强制关闭?
我的应用程序也可以工作,但12或24小时后无法工作,因为程序已被操作系统关闭 如何防止操作系统关闭程序 我的手机型号:Android 为什么过了一段时间我的程序被强制关闭?,android,forceclose,reminders,Android,Forceclose,Reminders,我的应用程序也可以工作,但12或24小时后无法工作,因为程序已被操作系统关闭 如何防止操作系统关闭程序 我的手机型号:华为G620S-L02 我的闹钟设置如下: AlarmManager alarmManager = (AlarmManager) this.mContext.getSystemService(Context.ALARM_SERVICE); Intent intentAlarm = new Intent(this.mContext, AlarmReciever.cl
华为G620S-L02
我的闹钟设置如下:
AlarmManager alarmManager = (AlarmManager) this.mContext.getSystemService(Context.ALARM_SERVICE);
Intent intentAlarm = new Intent(this.mContext, AlarmReciever.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.mContext, 1, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT);
long time = System.currentTimeMillis() + 25 * 60 * 60 * 1000
alarmManager.set(AlarmManager.RTC_WAKEUP, time, pendingIntent);
这是AlarmReceiver
:
public class AlarmReciever extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
PendingIntent pi = PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher) // notification icon
.setTicker(sticker)
.setContentTitle("title") // title for notification
.setContentText("text) // message for notification
.setAutoCancel(true) // clear notification after click
.setContentIntent(pi)
.setLights(0xff00ff00, 300, 500)
.setShowWhen(false);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
}
}
我的清单是:
<receiver
android:name=".AlarmReciever"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE" />
</intent-filter>
在某些设备(如华为)中,必须在受保护的应用程序中检查您的应用程序:
转到设置=>受保护的应用=>检查你的应用简短回答你不能。尝试使用AlarmManager、BroadcastReceiver和Services@RaduIonescu我已经习惯了AlarmManager、BroadcastReceiver、Services和你所想的一切!,但当我的应用程序强制关闭时,不工作!。我的应用程序运行得很好,但12或24小时后无法运行,因为该程序已被操作系统关闭。然后,你应该在帖子中包含此信息。添加更多关于您正在使用的内容的详细信息,以及关于如何管理此余数的代码,而不是投票否决请指导我。我没有投票否决您,我正在尝试帮助您:)