Solved

ancdroid abstract class eror

Posted on 2016-07-27
2
18 Views
Last Modified: 2016-08-22
i am getting an abstract class error when i use implemented items in my main acticity

package uk.co.ifsoft.auth.authenticationsystem;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.punchthrough.bean.sdk.Bean;
import com.punchthrough.bean.sdk.BeanDiscoveryListener;
import com.punchthrough.bean.sdk.BeanListener;
import com.punchthrough.bean.sdk.BeanManager;
import com.punchthrough.bean.sdk.message.BeanError;
import com.punchthrough.bean.sdk.message.Callback;
import com.punchthrough.bean.sdk.message.DeviceInfo;
import com.punchthrough.bean.sdk.message.LedColor;
import com.punchthrough.bean.sdk.message.ScratchBank;

import java.util.ArrayList;
import java.util.List;

import uk.co.ifsoft.auth.authenticationsystem.app.App;
import uk.co.ifsoft.auth.authenticationsystem.common.ActivityBase;

public class MainActivity extends ActivityBase implements BeanDiscoveryListener, BeanListener{

    Toolbar toolbar;

    Button btnLogout;
    Button btnView;
    String userpass;
    TextView beamserial;
    TextView beamtemp;
    TextView mUserUsername, mUserFullname, mUserEmail, mUserIp_addr;
    final List<Bean> beans = new ArrayList<>();
    Bean bean = null;
    TextView textView =null;

    BeanDiscoveryListener listener = new BeanDiscoveryListener() {
        @Override
        public void onBeanDiscovered(Bean bean, int rssi) {
            beans.add(bean);
        }

        @Override
        public void onDiscoveryComplete() {
            // This is called when the scan times out, defined by the .setScanTimeout(int seconds) method

            for (Bean bean : beans) {
                System.out.println(bean.getDevice().getName());

                beamserial = (TextView) findViewById(R.id.beamid);
                beamserial.setText("Purse Serial: " + bean.getDevice().getAddress());
             //   beamtemp = (TextView) findViewById(R.id.beamtempature);
            //    beamtemp.setText("Purse Temp: " + data);
            //    beamtemp = (TextView) findViewById(R.id.beamtempature);
            //  beamtemp.setText("Purse Temp: " + data);
            }
            if(beans.size()>0){
                bean=beans.get(0);
                bean.connect(this,this);
            }
        }

    };



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

        toolbar = (Toolbar) findViewById(R.id.toolbar);

        if (toolbar != null) {

            setSupportActionBar(toolbar);
        }




        mUserUsername = (TextView) findViewById(R.id.textUsername);
        mUserFullname = (TextView) findViewById(R.id.textUserFullname);
        mUserEmail = (TextView) findViewById(R.id.textUserEmail);
        mUserIp_addr = (TextView) findViewById(R.id.textUserIp_addr);

        mUserUsername.setText("Username: " + App.getInstance().getUsername());
        mUserFullname.setText("Fullname: " + App.getInstance().getFullname());
        mUserEmail.setText("Email: " + App.getInstance().getEmail());
        mUserIp_addr.setText("IP address: " + App.getInstance().getIp_addr());
        userpass =App.getInstance().getUsername();
        btnLogout = (Button) findViewById(R.id.btnLogout);
        btnView = (Button) findViewById(R.id.btnView);

        //////////////Function Start//////////////////

        btnLogout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                App.getInstance().logout();

                Intent i = new Intent(getApplicationContext(), AppActivity.class);
                startActivity(i);

                ActivityCompat.finishAffinity(MainActivity.this);
            }
        });
        //////////////////////// Function End ///////////////////

        //////////////Function Start////////////////
        btnView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent i = new Intent(getApplicationContext(), ProductActivity.class);
                i.putExtra("UN",userpass.toString());
                startActivity(i);

            }
        });
        //////////////////////// Function End ///////////////////


        // Start to look for bean device
        Log.d(TAG,"Start Bluebean discovery ...");
        BeanManager.getInstance().setScanTimeout(5);  // Timeout in seconds, optional, default is 30 seconds
        BeanManager.getInstance().startDiscovery(listener);



    }


    public void onConnectionFailed() {
        Log.d(TAG,"onConnectionFailed");
    }

    public void onDisconnected() {
        Log.d(TAG,"onDisconnected");
    }

    public void onSerialMessageReceived(byte[] data) {
        Log.d(TAG,"onSerialMessageReceived");
        Log.d(TAG,"data: "+data);
    }


    public void onScratchValueChanged(ScratchBank bank, byte[] value) {
        Log.d(TAG,"onScratchValueChanged");
        Log.d(TAG,"bank: "+bank+"\tvalue: "+value);
    }


    public void onError(BeanError error) {
        Log.d(TAG,"onError");
        Log.d(TAG,"error: "+error);
    }




}

Open in new window

0
Comment
Question by:Chris Jones
  • 2
2 Comments
 
LVL 16

Accepted Solution

by:
Chris Harte earned 500 total points (awarded by participants)
ID: 41732878
Never used bean before, but looking at the documentation you are missing your onConnected() method and you are not creating a BeanListener.
Have you declared it in the dependencies section of your gradle file?

https://github.com/PunchThrough/bean-sdk-android

What is the exact error message you are getting?
0
 
LVL 16

Expert Comment

by:Chris Harte
ID: 41759069
No response, so assumed it has worked.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I tend toward trying the newest hardware and software.  Thiss sometimes works out to my benefit, and sometimes not.  Because I downloaded and installed Android 5.x (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.htm…
I recently asked a question (http://www.experts-exchange.com/Programming/Smartphones/Android/Q_28684946.html) about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now