我想创建一个应用程序,通过USB从Android-app发送数据到PC.我的代码如下:
package com.sample.dummy.app.senddatathoughserialport;
import java.io.UnsupportedEncodingException;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbDevice;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView tv = (TextView)findViewById(R.id.multiAutoCompleteTextView1);
Button sButton = (Button) findViewById(R.id.button1);
final UsbManager manager = (UsbManager) this.getSystemService(Context.USB_SERVICE);
Toaster(""+manager);
// -- register click event with first button ---
sButton.setOnClickListener(new View.OnClickListener()
{ …Run Code Online (Sandbox Code Playgroud) 我正在传递一个创建JTable的java文件的值.
ResultSet res = np.InvestmentByInvestType(IType);
String tablename = "Investment By Invest Type";
int customAmt = np.showCustomizeInvestAmount1(IType);
CommonTable ct = new CommonTable();
ct.CommonSearchTable(res, customAmt,tablename);
Run Code Online (Sandbox Code Playgroud)
public void CommonSearchTable( final ResultSet res, int totally, final String tablename) throws SQLException
{
JButton exportTable= new JButton ("Export");
ResultSetMetaData metaData = res.getMetaData();
// names of columns
Vector<String> columnNames = new Vector<String>();
int columnCount = metaData.getColumnCount();
for (int column = 1; column <= columnCount; column++)
{
columnNames.add(metaData.getColumnName(column));
}
// data of the table
Vector<Vector<String>> data = new …Run Code Online (Sandbox Code Playgroud)