2016-06-02 5 views
0
06-02 06:43:35.978 4227-4227/? I/art: Late-enabling -Xcheck:jni 
06-02 06:43:36.088 4227-4227/meet.projectoklahoma W/System: ClassLoader referenced unknown path: /data/app/meet.projectoklahoma-1/lib/x86 
06-02 06:43:36.183 4227-4227/meet.projectoklahoma I/GMPM: App measurement is starting up, version: 8487 
06-02 06:43:36.183 4227-4227/meet.projectoklahoma I/GMPM: To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE 
06-02 06:43:36.473 4227-4254/meet.projectoklahoma D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true 
06-02 06:43:36.516 4227-4254/meet.projectoklahoma D/libEGL: loaded /system/lib/egl/libEGL_emulation.so 
06-02 06:43:36.517 4227-4254/meet.projectoklahoma D/libEGL: loaded /system/lib/egl/libGLESv1_CM_emulation.so 
06-02 06:43:36.532 4227-4254/meet.projectoklahoma D/libEGL: loaded /system/lib/egl/libGLESv2_emulation.so 
06-02 06:43:36.575 4227-4254/meet.projectoklahoma I/OpenGLRenderer: Initialized EGL, version 1.4 
06-02 06:43:36.658 4227-4254/meet.projectoklahoma W/EGL_emulation: eglSurfaceAttrib not implemented 
06-02 06:43:36.658 4227-4254/meet.projectoklahoma W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xed6fcd40, error=EGL_SUCCESS 
06-02 06:44:56.177 4227-4254/meet.projectoklahoma W/EGL_emulation: eglSurfaceAttrib not implemented 
06-02 06:44:56.177 4227-4254/meet.projectoklahoma W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xed6ff6c0, error=EGL_SUCCESS 
06-02 06:44:56.585 4227-4227/meet.projectoklahoma I/Choreographer: Skipped 30 frames! The application may be doing too much work on its main thread. 
06-02 06:44:57.062 4227-4254/meet.projectoklahoma E/Surface: getSlotFromBufferLocked: unknown buffer: 0xf3dd7240 
06-02 06:44:59.933 4227-4227/meet.projectoklahoma D/AndroidRuntime: Shutting down VM 
06-02 06:44:59.934 4227-4227/meet.projectoklahoma E/AndroidRuntime: FATAL EXCEPTION: main 
                    Process: meet.projectoklahoma, PID: 4227 
                    android.app.RemoteServiceException: Bad notification posted from package meet.projectoklahoma: Couldn't expand RemoteViews for: StatusBarNotification(pkg=meet.projectoklahoma user=UserHandle{0} id=1 tag=null score=0 key=0|meet.projectoklahoma|1|null|10060: Notification(pri=0 contentView=meet.projectoklahoma/0x7f04001c vibrate=null sound=null defaults=0x0 flags=0x0 color=0x00000000 vis=PRIVATE)) 
                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1507) 
                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                     at android.os.Looper.loop(Looper.java:148) 
                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
                     at java.lang.reflect.Method.invoke(Native Method) 
                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

ユーザーがログインすると、アプリは待機中のイベントで通知を読み込むが、代わりにクラッシュする。上記のコードは、クラッシュした後のエラーです。通知を読み込もうとするとアプリがクラッシュする

これは、通知を送信するためのコードです:

private void sendNotification() { 
    if (!LocalDataBase.getCurrentUser().getWaitingList().isEmpty()) 
    { 
     int notificationID=1; 
     setContentView(R.layout.activity_events_status_bar2); 
     TextView eventName=(TextView)findViewById(R.id.incomingEventsNameText2) ; 
     Event eventToDisplay=LocalDataBase.getCurrentUser().getWaitingList().get(0); 
     eventName.setTag(eventToDisplay); 
     Intent showEvents=new Intent(this, EventsStatusBarActivity.class); 
     PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, showEvents, 0); 
     RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.activity_events_status_bar2); 
     contentView.setTextViewText(R.id.incomingEventsNameText2, eventToDisplay.getName()); 
     contentView.setOnClickPendingIntent(R.id.attendButton,pendingIntent); 
     contentView.setOnClickPendingIntent(R.id.declineButton,pendingIntent); 
     NotificationCompat.Builder eventsNotification= new NotificationCompat.Builder(this) 
       .setSmallIcon(R.drawable.notification_template_icon_bg) 
       .setContentText("Incoming notifications") 
       .setContent(contentView); 
     eventsNotification.setContentIntent(pendingIntent); 
     NotificationManager notificationManager=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
     notificationManager.notify(notificationID,eventsNotification.build()); 
    } 


} 

これはactivity_events_status_bar2のコードです:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:weightSum="1"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Event Name" 
     android:tag="event" 
     android:id="@+id/incomingEventsNameText2" 
     android:layout_gravity="left" 
     android:textColor="@android:color/black" 
     android:textSize="22sp" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignBottom="@+id/attendButton" /> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Going" 
     android:id="@+id/attendButton" 
     android:layout_alignParentTop="true" 
     android:layout_toLeftOf="@+id/declineButton" 
     android:layout_toStartOf="@+id/declineButton" 
     android:onClick="selectGoing"/> 

    <Button 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Not Going" 
     android:id="@+id/declineButton" 
     android:layout_alignBottom="@+id/attendButton" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" 
     android:onClick="selectNotGoing"/> 


</RelativeLayout> 
+0

あなたは 'activity_events_status_bar2'のコードを表示できますか?このエラーは、このビューを拡大する際に問題があることを示唆しているようです。具体的には、属性 'android:layout_height'の値を確認したいと思います。 – ishmaelMakitla

+0

投稿しました。 –

答えて

0

あなたが直接contentViewを適用することによって、それを回避する必要があります:

 NotificationCompat.Builder eventsNotification= new NotificationCompat.Builder(this) 
        .setSmallIcon(R.drawable.notification_template_icon_bg) 
        .setContentText("Incoming notifications") 
        .setContent(contentView); 
      eventsNotification.setContentIntent(pendingIntent); 
NotificationManager notificationManager=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

    Notification myNotification = eventsNotification.build(); 
    notification.contentView = contentView; 
    notificationManager.notify(notificationID,myNotification); 
+0

私はこれを取得しています - "シンボル 'contentView'を解決できません" –

+0

私は一度試してみてください答えを編集しました。 –

+0

私はもう一度試しました。今は「記号を解決できません」と言っているわけではありませんが、まだ破砕しています。エラーは同じです。 –

0

この密接に関連する質問here、私はあなたが試みることができると思うあなたのNotificationオブジェクトを取得し、そのcontentViewを直接設定することです。 は、ここでは、あなたのコードに加える必要がある変更の一部です:

//... the rest of your code up to this point (unchanged) 
NotificationCompat.Builder eventsNotification= new NotificationCompat.Builder(this) 
       .setSmallIcon(R.drawable.notification_template_icon_bg) 
       .setContentText("Incoming notifications") 

    eventsNotification.setContentIntent(pendingIntent); 
    NotificationManager notificationManager=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
    //get handle to your notification object 
    Notification notification = eventsNotification.build(); 
    //then set contentView directly like this: 
    notification.contentView = contentView; 
    //finally, pass the notification over 
    notificationManager.notify(notificationID,notification); 

私は、これは同様にあなたの問題を解決するのに役立ちます願っています。

+0

いいえ。ログインした後もまだクラッシュしていますが、エラーは同じです。私は、Androidのモニターからの完全なエラーを投稿に追加しました。 –

関連する問題