I apologize, I recently asked a question that was not received well due to the inaccuracy of describing my problem. I have edited my question.
I am a beginner trying to develop an app that utilizes usb host. I have read through the USB Host|Android Developer tutorial, but I am still lost as to how it is initially set up.
My intent is for the app to use the Enumeration process to locate the device, as I do not know what my connected device's vendor-id or product-id is. I receive a Fatal Exception: main error when I attempt to run what I have.
Below is my code so far. Any help would be greatly appreciated.
Main Activity class
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbDevice;
import android.content.Context;
import java.util.HashMap;
import java.lang.Object;
import android.content.Intent;
import android.util.Log;
import java.util.Iterator;
import java.util.Collection;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap <String, UsbDevice> deviceList = manager.getDeviceList();
UsbDevice device = deviceList.get("deviceName");
}
Manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.trapperdavis.ircontprototype2">
<uses-sdk android:minSdkVersion="12" />
<uses-feature android:name="android.hardware.usb.host" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>
</application>
</manifest>