Solved

ancdroid abstract class eror

Posted on 2016-07-27
2
20 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 17

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 17

Expert Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, people trade privacy and security for convenience. However in today's concrete jungle, this is an extremely foolish decision considering the vast amount of technologies being used against consumer interest. First off, I won't waste any time e…
Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
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…

839 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