Please refer to the code below. I am able to use javax.comm
as I included it in lib
folder of Eclipse but I am not able to solve the problem regarding commPortIdentifier
it gives error that comm port Identifier can't be resolved.
If anyone is having idea regarding serial port identification in android. Please revert back.
package com.example.mysocket;
import java.util.Enumeration;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener {
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=(Button)findViewById(R.id.button1);
b1.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Enumeration e = CommPortIdentifier.getPortIdentifiers();
while (e.hasMoreElements()) {
System.out.println((CommPortIdentifier) e.nextElement());
}
}
}