Giter Club home page Giter Club logo

Comments (6)

viveksb007 avatar viveksb007 commented on August 22, 2024

expected as code wasn't tested.
will try to solve communication error as soon as i get the device.
@jithinbp I took reference from your comm. library and https://github.com/mik3y/usb-serial-for-android.

from pslab-android.

akarshan96 avatar akarshan96 commented on August 22, 2024

@viveksb007 I think the Androidmanifest.xml should be configured to notify the app when PSLab is attached.
The intent filter needs to be declared

<intent-filter>
        <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    </intent-filter>

from pslab-android.

jithinbp avatar jithinbp commented on August 22, 2024

@akarshan96 yea, I remember using those to automatically launch the App when the device was connected. Another way would be to ask for permission when the app is launched. The following code was used by the MainMenuActivity in the Android app for ExpEYES

private static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
private PendingIntent mPermissionIntent;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_menu);
		
		setTitle("ExpEYES Experiments ( Connect... )");
		
 		mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
		filter = new IntentFilter(ACTION_USB_PERMISSION);
		registerReceiver(mUsbReceiver, filter);
        
        mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
        mcp2200 = new devhandler(mUsbManager);
        
        if(mcp2200.device_found )mUsbManager.requestPermission(mcp2200.mDevice, mPermissionIntent);
        else Toast.makeText(getBaseContext(),"No device connected. check connections.",Toast.LENGTH_SHORT).show();
        ej=expeyesCommon.getInstance();
        
        
        
	}

from pslab-android.

jithinbp avatar jithinbp commented on August 22, 2024

Look for

/*---------------------REQUEST USB PERMISSION WITHIN THE APPLICATION--------------------------*/

in (https://github.com/jithinbp/ExpEYES_android/blob/master/src/com/expeyesexperiments/MainMenuActivity.java)

from pslab-android.

akarshan96 avatar akarshan96 commented on August 22, 2024

@jithinbp yes, we have to define a onReceive method under BroadcastReceiver. I am working on it. Hope it resolve errors

from pslab-android.

viveksb007 avatar viveksb007 commented on August 22, 2024

@akarshan96 this onReceive method is for explicitly asking for permission when there are more than one device connected.
Using an intent filter should solve the issue.
Reference : https://developer.android.com/guide/topics/connectivity/usb/host.html#permission-d

from pslab-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.