Solved

ancdroid abstract class eror

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction This article is a continuation of Part-1 as evident from the title. Please visit this page (http://www.experts-exchange.com/articles/18706/Backing-up-personal-data-on-your-Android-device-Part-1.html) to read the earlier Part -1. If y…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
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.

708 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

18 Experts available now in Live!

Get 1:1 Help Now