包裹已经张贴了50敬酒.没有显示更多 [英] Package has already posted 50 toasts. Not showing more

查看:49
本文介绍了包裹已经张贴了50敬酒.没有显示更多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在开发一个应用程序,在这一点上,我需要从用户那里获取输入并将其存储在数据库中,然后获取该数据并将其放在不同的 TextView 上.问题是我确实将数据存储在数据库中,并且当我尝试获取数据时,我的应用程序显示了一个弹出窗口,即:应用程序没有响应,logcat显示了此信息: 包裹已经张贴了50敬酒.没有显示更多. 在此pullAccStt可能会出现问题之前,我已经使用了6个数据库操作.

Hello I am working on an app and in which at one point I need to take input from user and store it in database and then fetch that data and put it on different TextView. Problem is I did stored the data in database and when i trying to fetch it My app shows a pop up i.e : App is not responding and logcat shows this: Package has already posted 50 toasts. Not showing more. I have used 6 database operations before this pullAccStt can this be a problem.

DatabseAdapotor

public long updateAccSettTable(String loactionName, String hospitalname, String PatientId, String FirstName, String MiddleName, String LastName, String DOB,
                               String Gender, String Weight, String Height, String MobNo, String emailId, String Ethinicity, String patientConcentStatus, String DevicePatientId,
                               String CoSensorId, String DeviceId, String VideoId){
    SQLiteDatabase db= helper.getWritableDatabase();
    ContentValues contentValuesAccSett= new ContentValues();
    contentValuesAccSett.put(DatabaseHelper.PatientId,PatientId);
    contentValuesAccSett.put(DatabaseHelper.LocationName,loactionName);
    contentValuesAccSett.put(DatabaseHelper.HospitalName,hospitalname);

    contentValuesAccSett.put(DatabaseHelper.FirstName,FirstName);
    contentValuesAccSett.put(DatabaseHelper.MiddleName,MiddleName);
    contentValuesAccSett.put(DatabaseHelper.LastName,LastName);
    contentValuesAccSett.put(DatabaseHelper.DateOfBirth,DOB);
    contentValuesAccSett.put(DatabaseHelper.Gender,Gender);
    contentValuesAccSett.put(DatabaseHelper.Weight,Weight);
    contentValuesAccSett.put(DatabaseHelper.Height,Height);
    contentValuesAccSett.put(DatabaseHelper.MobileNo,MobNo);
    contentValuesAccSett.put(DatabaseHelper.EmailId,emailId);
    contentValuesAccSett.put(DatabaseHelper.Ethnicity,Ethinicity);
    contentValuesAccSett.put(DatabaseHelper.P_ConsentStatus,patientConcentStatus);
    contentValuesAccSett.put(DatabaseHelper.DevicePId,DevicePatientId);
    contentValuesAccSett.put(DatabaseHelper.DeviceId,DeviceId);
    contentValuesAccSett.put(DatabaseHelper.CoSensorId,CoSensorId);
    contentValuesAccSett.put(DatabaseHelper.VideoId,VideoId);

    long id1= db.insert(DatabaseHelper.Accoun_setting_Table,null,contentValuesAccSett);
    if (id1<0){
        Message.message(helper.context,"Unsuccessfull");

    }else {
        Message.message(helper.context,"Account setting Updated");

    }

    db.close();
    return id1;


}
public String pullAccSett(){
    String patientId = null;
    Message.message(helper.context,"patient id is: ");
    SQLiteDatabase db=helper.getWritableDatabase();
    String query="Select * From "+DatabaseHelper.Accoun_setting_Table+" ;";
    Cursor AccCursor=db.rawQuery(query,null);
    Message.message(helper.context,"query "+query);
    while(AccCursor.moveToFirst()) {

        int index1 = AccCursor.getColumnIndex(DatabaseHelper.PatientId);
         patientId=AccCursor.getString(index1);


    }

    AccCursor.close();
    db.close();
    return patientId ;
}

活动类称为

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


/**
 * A simple {@link Fragment} subclass.
 */
public class AccountSettingFragment extends Fragment {
    FloatingActionButton fabEdit;
    DatabaseAdaptor databaseAdaptor=null;
    TextView PatientId;
    private Context context;


    public AccountSettingFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view=inflater.inflate(R.layout.fragment_account_setting, container, false);

        fabEdit=(FloatingActionButton)view.findViewById(R.id.btnFabEdit);
        PatientId=(TextView)view.findViewById(R.id.patientId);
        context=getActivity();
        databaseAdaptor=new DatabaseAdaptor(context);
       databaseAdaptor.pullAccSett();
        fabEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), AccountsSettingEdit.class);
                getActivity().startActivity(intent);
            }
        });


        return view;
    }


}

消息类别

import android.content.Context;
import android.widget.Toast;

/**
 * Created by frnds on 3/2/2016.
 */
public class Message {
    public static void message(Context context,String message){
        Toast.makeText(context,message,Toast.LENGTH_LONG).show();
    }
}

当我调用此pullAccSett()时;我的应用程序挂起,无法响应. 日志猫显示消息: 包裹已经张贴了50敬酒.没有显示更多. 这是什么原因造成的?

And when i call this pullAccSett(); my app hangs and goes to not responding. and log cat shows message: Package has already posted 50 toasts. Not showing more. What is the reason behind this.

推荐答案

您的 while 循环,我认为它将无限期运行.因为每次都将是真实的,并且您没有break语句. 因此,请像这样更改您的代码.

Your while loop i thinks will runs for infinite time. because every time it will be true and you have no break statement. so change your code like this.

try {
    if (AccCursor.moveToFirst()) {
        while (AccCursor.moveToNext()) {
        //code for fetch data from cursor
        }
    }

    AccCursor.close();
}catch (Exception e) {
    Log.e("Getdata", e.getMessage(), e);
}  

这篇关于包裹已经张贴了50敬酒.没有显示更多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆