Solved

ancdroid abstract class eror

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Transfer Blackberry Contact to Andriod 2 77
Viber 1 43
messenger app crashes 7 55
IT Company 5 79
Android SDK is used for creating an android software application. It includes document and tools which are necessary to develop applications with java. In fact Android SDK is harder than other software infrastructure, because there is a virtual devi…
Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
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.
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…

810 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