-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UART Cant open #8
Comments
Seems like you've opened it in another activity without closing it. See this Stackoverflow answer to learn more. |
But I'm closing UART before passing the Intent in every activity and this problem occurs randomly if it occurs always I can consider I forget to Close somewhere even I had the main thread.sleep before passing the Intent but nothing solved this problem. |
Where are you closing it? In the activity's |
I'm closing it before passing the intent like
I'm not closing it in onDestroy method. |
Can you add a type of asynchronous wait before starting your activity, like using a Handler: try {
closeUart();
} catch (IOException e) {
Log.e(TAG, "Error closing UART device:", e);
}
h = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(int what) {
Intent i = new Intent(MainActivity.this,MainActivity2.class);
String strName = "j";
i.putExtra(Intent.EXTRA_TEXT, strName);
startActivity(i);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);finish();
finish();
}
};
h.sendEmptyMessageDelayed(0, 50); (this code wasn't tested, so it may not be completely valid) |
I have tried using main thread timer before passing the intent. Like |
E/Exception: UART cant opencom.google.android.things.pio.PioException: android.os.ServiceSpecificException: UART0 is already in use (code 16)
The text was updated successfully, but these errors were encountered: