마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

블루투스 연결 상태에 따라 Notification 이상한 반응 문의

0 추천
블루투스 연결시에는 정상적으로 Notification이 Title과 text image가 다 뜹니다.

아래와 같이 정상적으로 뜹니다.

 

이미지  타이틀                        X

          텍스트  

 

그러나 미연결시에는 타이틀과 텍스트가 사라지고,

이미지가 중간으로 오면서 x는 그대로 위치합니다.

 

              이미지                      x

 

 

아래는 소스와 layout 입니다.

소스에서

if(BluetoothService.check_mState!=3){
          //     contentView.setImageViewResource(R.id.image, R.drawable.bt_dis);

이미지를 주석 처리할경우에는

title과 text가 뜹니다.

이미지과 title text간의 충돌인거같은데.. 이해가 안되서 이렇게 글을 올립니다.

<소스>

        Notification notification;
        RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification_layout);

        if(BluetoothService.check_mState!=3){
               contentView.setImageViewResource(R.id.image, R.drawable.bt_dis);
               contentView.setTextViewText(R.id.title, getResources().getString(R.string.noti_title));  
               contentView.setTextViewText(R.id.text,"연결안됨");
               contentView.setOnClickPendingIntent(R.id.finish_button, pfinishIntent);
         
               notification = new Notification.Builder(this)
                        .setSmallIcon(R.drawable.bt_dis)
                        .setContent(contentView)
                        .setContentIntent(pendingIntent)
                        .setPriority(NotificationCompat.PRIORITY_MAX)
                        .build();
        }else{
               
               contentView.setImageViewResource(R.id.image, R.drawable.ic_launcher);
               contentView.setTextViewText(R.id.title, getResources().getString(R.string.noti_title));
               contentView.setTextViewText(R.id.text, getResources().getString(R.string.noti_content));
               contentView.setOnClickPendingIntent(R.id.finish_button, pfinishIntent);
         
               notification = new Notification.Builder(this)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setContent(contentView)
                        .setContentIntent(pendingIntent)
                        .setPriority(NotificationCompat.PRIORITY_MAX)
                        .build();
        }
        startForeground(NOTIFICATION_ID, notification);

<layout>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    android:padding="10dp" >
    
    <ImageView android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_marginRight="10dp" />
    <TextView android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/image"
        android:textColor="#000000"
        style="Custom Notification Title" />
    <TextView android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/image"
        android:textColor="#000000"
        android:layout_below="@id/title"
        style="Custom Notification Text" />
    
    <ImageButton
          android:id="@+id/finish_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right|top"
        android:layout_alignParentRight="true"
        android:background="@drawable/x"/>
  
        
    
</RelativeLayout>
쿠쿠부다스 (6,470 포인트) 님이 2017년 1월 25일 질문
자답 아이콘 해상도 문제였습니다.

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...