Hi,
I’m still troubled w/ declarations other than the pure ported/created Processing stuff.
I have a running ported App, which I wanted to extend w/ a Background Network task, because networking in the main thread is prohibited.
I created a background task, wich I believe is OK.
public class listen {
public AsyncTask async_client;
@SuppressLint("StaticFieldLeak")
public void receive() {
async_client = new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void... params) {
boolean run = true;
try {
...some code here
}
} catch (IOException e) {
... and here
run = false;
}
return null;
}
};
if (Build.VERSION.SDK_INT >= 11) async_client.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else async_client.execute();
}
I tried to activate this background thread in my main activity like this
public class MainActivity extends AppCompatActivity {
private PApplet sketch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout frame = new FrameLayout(this);
frame.setId(CompatUtils.getUniqueViewId());
setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
sketch = new MiniEFIS();
PFragment fragment = new PFragment(sketch);
fragment.setView(frame, this);
listen client = new listen();
client.receive();
}
Is this the right place? There are no errors at compile time!
I am receiving a runtime exception (and crash) wIth the error
java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.Void[]
and I don’t know, if the declaration is wrong, or in a wrong place, or what ??
Any help welcome.
Thank you in advance
hk