0

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());

        }
    }

    }
TN888
  • 7,659
  • 9
  • 48
  • 84

2 Answers2

0

There is no CommPortIdentifier in Android. If you mention what you're trying to accomplish, the great minds here at SO can provide you alternatives :)

josephus
  • 8,284
  • 1
  • 37
  • 57
0

You cannot simply add java communication library (Com port communication library) in an android project as such, since android doesn't provide the java COMM library's native implementations. If you still want to accomplish COM port communication in android, you can look into this: http://v-lad.org/projects/gnu.io.android/

Suji
  • 6,044
  • 2
  • 19
  • 17
  • @hrishi, was my answer useful for you? – Suji Jul 26 '13 at 09:43
  • hey I got that link but I am not able to use that API. Please can you provide me step by step guidance as I am not a framework programmer – hrishikesh Deshpande Aug 05 '13 at 07:42
  • Explain what you are trying to achieve, where you are stuck with in detail. Then only I can help you. You just mentioned ComPortIdentifier gives error, but that is not enough to give you a solution. – Suji Aug 05 '13 at 09:00