我已经在Google Firebase Analytics
中创建了一个项目,并且能够在控制台中记录屏幕名称。但是对于一个屏幕,screen_view
未记录,并且在屏幕视图列表中显示为未设置。我已使用默认功能记录屏幕视图事件(即setCurrentScreen())。
我正在使用Firebase:16.0.0
版本。有人可以为此指导我吗。
答案 0 :(得分:2)
使用logcat实时调试它,以找出未正确设置的原因。我最好的猜测是,您在传递不正确状态的活动时尝试调用public void addAppointmentsToCalender(Context context, String title, String desc, String place, String appointmentDate){
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
try {
Date eventDate = dateFormat.parse(appointmentDate);
calendar.setTime(eventDate);
calendar.add(Calendar.DATE, -1);
} catch (Exception ex) {
Log.e("Error Adding Event", "Error in adding event on calendar" + ex.getMessage());
}
String reminderDate = dateFormat.format(calendar.getTime());
Log.e("Day before event start", reminderDate);
String reminderDayStart = reminderDate + " 00:00:00";
String reminderDayEnd = reminderDate + " 23:59:59";
long startTimeInMilliseconds = 0, endTimeInMilliseconds = 0;
try {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");
Date SDate = formatter.parse(reminderDayStart);
Date EDate = formatter.parse(reminderDayEnd);
startTimeInMilliseconds = SDate.getTime();
endTimeInMilliseconds = EDate.getTime();
Log.e("StartDate", startTimeInMilliseconds + " " + reminderDayStart);
Log.e("EndDate", endTimeInMilliseconds + " " + reminderDayEnd);
} catch (Exception e) {
e.printStackTrace();
}
ContentResolver cr = context.getContentResolver();
ContentValues values = new ContentValues();
values.put(CalendarContract.Events.CALENDAR_ID, 1);
values.put(CalendarContract.Events.DTSTART, startTimeInMilliseconds);
values.put(CalendarContract.Events.DTEND, endTimeInMilliseconds);
values.put(CalendarContract.Events.TITLE, title);
values.put(CalendarContract.Events.DESCRIPTION, desc);
values.put(CalendarContract.Events.EVENT_LOCATION, place);
TimeZone timeZone = TimeZone.getDefault();
values.put(CalendarContract.Events.EVENT_TIMEZONE, timeZone.getID());
values.put(CalendarContract.Events.RRULE, "FREQ=HOURLY;COUNT=1");
values.put(CalendarContract.Events.HAS_ALARM, 1);
Uri eventUri;
if (Build.VERSION.SDK_INT >= 8) {
eventUri = Uri.parse("content://com.android.calendar/events");
} else {
eventUri = Uri.parse("content://calendar/events");
}
// insert event to calendar
Uri uri = cr.insert(eventUri, values);
Log.e("EventTest", uri.toString());
//add reminder for event
try {
Uri REMINDERS_URI;
long id = Long.parseLong(uri.getLastPathSegment());
ContentValues reminders = new ContentValues();
reminders.put(CalendarContract.Reminders.EVENT_ID, id);
reminders.put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT);
reminders.put(CalendarContract.Reminders.MINUTES, 1);
if (Build.VERSION.SDK_INT >= 8) {
REMINDERS_URI = Uri.parse("content://com.android.calendar/reminders");
} else {
REMINDERS_URI = Uri.parse("content://calendar/reminders");
}
Uri remindersUri = context.getContentResolver().insert(REMINDERS_URI, reminders);
//AsyncQueryHandler handler = new MyHandler(context.getContentResolver());
//handler.startInsert(0, null, REMINDERS_URI, reminders);
Log.e("RemindersTest", remindersUri.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
。
可能的解决方案:将日志记录移至setCurrentScreen()
。
答案 1 :(得分:2)
放入
analytics.setCurrentScreen(this, "Screen Name", this.getClass().getSimpleName());
在onResume()
中。