[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ancdroid abstract class eror

Posted on 2016-07-27
2
Medium Priority
?
28 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 17

Accepted Solution

by:
Chris Harte earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
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.
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…

656 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