jeudi 29 octobre 2015

Why do I receive an error databaseHandler(android.content.context) cannot be applied to anonymous android.os.Handler

For some Reason it seems i can't store a value in this method in my database. Its my first time in countering this issue. Do I need to extend activity somewhere or is there another method of fixing this issue

final  Handler Newhandler = new Handler(){
    public void handleMessage(Message msg)
    {
        TextView tv;
        switch (msg.what)
        {
            case HEART_RATE:

                Storage value = new Storage(Integer.parseInt(msg.getData().getString("HeartRate")));

                DatabaseHandler db = new DatabaseHandler(this); The error occurs right her on the (this) value.

                db.add(value);

                List<Storage> a=db.getAllContacts();


                for(int i=0;i<a.size();i++){

                    System.out.println("Steps " + Integer.toString(a.get(i).get_heartrate()));





                }

                int Count = db.getContactsCount();
                System.out.println("Count: "+Integer.toString(Count) );*/
        }
                String HeartRatetext = msg.getData().getString("HeartRate");
                tv = (EditText)findViewById(R.id.labelHeartRate);
                System.out.println("Heart Rate Info is "+ HeartRatetext);
                if (tv != null)tv.setText(HeartRatetext);
                break;



        }
    }

};

}

Aucun commentaire:

Enregistrer un commentaire