E / Surface:getSlotFromBufferLocked:未知缓冲区:0xb96ae9c0收到此错误

时间:2016-08-19 06:37:38

标签: android

我正在做一个通知视图项目。通知确实出现在通知栏上,当我点击通知栏时,它将继续下一个活动,以显示与通知内容相同的信息。但是这个错误......

E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb96ae9c0

我的代码是

MainActivity.java

public class MainActivity extends AppCompatActivity {

    Button view_notifi,btn_time,btn_date;
    int notificationID,getHour,getMin,getDay,getMonth,getYear;
    final int dialogTime=0,dialogDate=1;
    Notification notification;
    EditText edt_heading,edt_details,edt_details2;
    String head,details,details2;
    String Time,setDate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        edt_heading=(EditText)findViewById(R.id.editText_Heading);
        edt_details=(EditText)findViewById(R.id.editText_Details);
        edt_details2=(EditText)findViewById(R.id.editText_details2);
        notificationID=1;
        view_notifi=(Button)findViewById(R.id.button_viewN);
        btn_time=(Button)findViewById(R.id.button_time);
        btn_date=(Button)findViewById(R.id.button_date);
        view_notifi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                head=edt_heading.getText().toString();
                details=edt_details.getText().toString();
                details2=edt_details2.getText().toString();
                displayNotification(head,details,details2);
                edt_heading.getText().clear();
                edt_details.getText().clear();
                edt_details2.getText().clear();
            }
        });
    }

    public void getTimeInfo(View view){
        showDialog(dialogTime);
    }
    public void getDateInfo(View view){
        showDialog(dialogDate);
     }
    protected Dialog onCreateDialog(int id){
        switch (id){
            case dialogTime:
                return new TimePickerDialog(this,mTimeListener,getHour,getMin,false);
            case dialogDate:
                DatePickerDialog dialog = new DatePickerDialog(this, mDateListener, getYear, getMonth, getDay);
                DatePicker datePicker = dialog.getDatePicker();
                Calendar calendar = Calendar.getInstance();
                datePicker.setMinDate(calendar.getTimeInMillis());
                //dialog.getDatePicker().setMinDate(new Date().getTime());
                return dialog;
                //return new DatePickerDialog(this,mDateListener,getYear,getMonth,getDay);
        }
        return null;
    }

    private TimePickerDialog.OnTimeSetListener mTimeListener=new TimePickerDialog.OnTimeSetListener(){
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            getHour=hourOfDay; getMin=minute;
            Time=String.valueOf(" "+getHour+":"+getMin);
            Toast.makeText(getBaseContext(),"Time: "+Time,Toast.LENGTH_SHORT).show();
        }
    };
    private DatePickerDialog.OnDateSetListener mDateListener=new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

            getYear=year; getMonth=monthOfYear+1;getDay=dayOfMonth;
            //getMonth=+1;
            setDate=String.valueOf(" "+getDay+"/"+getMonth+"/"+getYear);
            Toast.makeText(getBaseContext(),"Date: "+setDate,Toast.LENGTH_SHORT).show();
        }
    };

    public void displayNotification(String str1,String str2,String str3){


        Intent intent = new Intent("notify_filter");
        Bundle bundle = new Bundle();
        bundle.putString("arg1", str1);
        bundle.putString("arg2", str2);
        bundle.putString("arg3", str3);
        bundle.putString("arg4", Time);
        bundle.putString("arg5", setDate);
        intent.putExtras(bundle);
        intent.putExtra("notificationID",notificationID);

        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
        Notification.Builder builder = new Notification.Builder(MainActivity.this);

        builder.setAutoCancel(true);
        builder.setTicker("New Alert...");
        builder.setSmallIcon(R.mipmap.ic_launcher);
        builder.setContentTitle(str1);
        builder.setContentText(str2);
        builder.setSubText("Time " + Time + "  Date:" + setDate);   //API level 16
        builder.setContentIntent(pendingIntent);
        builder.setOngoing(true);
        builder.setNumber(100);
        builder.build();


        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        notification = builder.getNotification();
        notification.vibrate = new long[]{100, 250, 100, 400};
        notificationManager.notify(notificationID, notification);

    }
}

ViewNotification.java

public class ViewNotification extends AppCompatActivity {

    TextView head,detail1,detail2,time,date;
    Bundle bundle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_notification);

        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        notificationManager.cancel(getIntent().getExtras().getInt("notificationID"));
        head=(TextView)findViewById(R.id.textView_head);
        detail1=(TextView)findViewById(R.id.textView_det1);
        detail2=(TextView)findViewById(R.id.textView_det2);
        time=(TextView)findViewById(R.id.textView_time);
        date=(TextView)findViewById(R.id.textView_date);
        bundle = getIntent().getExtras();
        String view1= bundle.getString("arg1");
        String view2= bundle.getString("arg2");
        String view3= bundle.getString("arg3");
        //String view4=bundle.getString("arg4");
        //String view5=bundle.getString("arg5");
        head.setText(view1);
        detail1.setText(view2);
        detail2.setText(view3);
        time.setText(bundle.getChar("arg4"));
        date.setText(bundle.getChar("arg5"));
    }
}

1 个答案:

答案 0 :(得分:0)

当您尝试将TextView的值设置为整数时会发生这种情况。

为TextView指定String值时,此错误消失。

例如

我在xml文件中创建了一个文本视图。我试图从java代码设置该特定文本字段的值。我将int值设置为Text View但是我收到一个错误getSlotFromBufferLocked:unknown buffer:0xab7519c0但是在将值从int更改为String并从该String设置TextView后,错误消失且app正常工作。