ローカル通知からアプリを開くときにアプリがクラッシュする。 通知は5秒後に送信する必要がありますが、時にはそうすることもありますが、時には時間がかかることもあり、まったく送信されないこともあります。ローカル通知がクラッシュするアプリケーションandroid java
public void sendPushNotificationUpdate() {
new Print("SEND NOTIFICATION");
AlarmManager service = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(MyService.this, LocalNotification.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pending = PendingIntent.getBroadcast(MyService.this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
Calendar cal = Calendar.getInstance();
// Start 1 month after boot completed
cal.add(Calendar.SECOND, 5);
new Print("send notification at " + cal.getTime());
//
// Fetch every 1 month
// InexactRepeating allows Android to optimize the energy consumption
// service.setInexactRepeating(AlarmManager.RTC_WAKEUP ,cal.getTimeInMillis(), AlarmManager.ELAPSED_REALTIME , pending);
service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), AlarmManager.INTERVAL_HOUR, pending);
}
///////////////////////////////////////////////////////////////////// /////////////////////////////
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(notificationIntent);
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Notification notification = builder
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("TEST")
.setContentText(title)
.setSound(soundUri)
.setAutoCancel(false)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(title))
.setPriority(Notification.PRIORITY_MAX)
.setContentIntent(pendingIntent).build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
通知を送信するのでログが表示するものである:
I/System.out: RECEIVE LOCAL NOTIFICATION
I/System.out: DISABLE SERVICEEEEEEEEEEEEEEEEEEEEEEEEEEEE
I/System.out: Database exists
D/Background mode ->: VERIFY INTERNET CONNECTION
D/Background mode ->: NO CONNECTION AVAILABLE
I/System.out: DELEGATE STARTS
V/FA: onActivityCreated
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/data/com.test/databases/db.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
V/ztgl: asset != NULL
I/System.out: Between 22.02.2017 - 10:50 and 22.02.2017 - 11:20 there are:
I/System.out: 0 days, 0 hours, 30 minutes, 0 seconds
V/FA: Using measurement service
V/FA: Connecting to remote service
V/FA: Activity resumed, time: 182309534
I/Choreographer: Skipped 30 frames! The application may be doing too much work on its main thread.
D/Background mode ->: Service destroyed
I/System.out: Between 22.02.2017 - 10:50 and 22.02.2017 - 11:20 there are:
I/System.out: 0 days, 0 hours, 30 minutes, 0 seconds
I/Process: Sending signal. PID: 20941 SIG: 9
///////////////////////////////////// ///////////
これは私が現時点で持っているものです。私はインターネットで見て回ったが、私の問題を解決するための何かを見つけることができませんでした。お返事ありがとうございます。
Unfortunately MyApp has stopped. How can I solve this?とは異なり、ローカル通知に関する特定の質問をしています。 @Vlad Matvienko
あなたのlogcatエラーを投稿する –
あなたのクラッシュレポートを投稿する必要があります。 – Piyush
[不幸にもMyAppが停止しました。どうすればこの問題を解決できますか?](http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this) –