I am trying to control a peice of hardware that the company gave me an API/Java file to. the board runs android, and I was able to compile and run my own APK files on it no problem.
But to control the hardware, I have to use the JAR file and call some native stuff to get brightness, etc.
Trouble is I dunno how to get it to work in JavaObject. I tried to add the jar file with AdditionalJar and it crashes with function not found errors.
I attached the JAR file. Here is the code in the Java example that was given to me. How do I convert to java object?
This is the code I tried:
That didnt work so I must be missing something as I see they are doing something else with: card = CommunicationJoey.getCardService(MainActivity.this);
At this point I am completely lost as I have almost zero java knowledge. Just a VB guy.
Any help here would be awesome!
But to control the hardware, I have to use the JAR file and call some native stuff to get brightness, etc.
Trouble is I dunno how to get it to work in JavaObject. I tried to add the jar file with AdditionalJar and it crashes with function not found errors.
I attached the JAR file. Here is the code in the Java example that was given to me. How do I convert to java object?
B4X:
package com.xixun.joey.aidldemo;
import com.xixun.contract.model.TaskToSetBrightness;
import com.xixun.joey.aidlset.CardService;
import com.xixun.joey.aidlset.CommunicationJoey;
import com.xixun.joey.aidlset.FpgaInfomation;
public class MainActivity extends Activity {
private static String TAG = "aidldemo";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
CardService card = null;
try {
// Log.e(TAG, "Upgrading ...");
card = CommunicationJoey.getCardService(MainActivity.this);
if (null != card) {
Log.i(TAG, "Brightness is: " + card.getBrightness());
FpgaInfomation info = (FpgaInfomation) card.getFpgaInfomation().get(0);
Log.i(TAG, "Temperature is: " + info.temperature);
Log.i(TAG, "Humidity is: " + info.humidity);
Log.i(TAG, "CardVoltage is: " + info.cardVoltage);
Log.i(TAG, "ExternalVoltage1 is: " + info.externalVoltage1);
Log.i(TAG, "ExternalVoltage2 is: " + info.externalVoltage2);
Log.i(TAG, "DoorOpened is: " + info.doorOpened);
Log.i(TAG, "Smoke is: " + info.smoke);
TaskToSetBrightness tts = new TaskToSetBrightness();
card.setTimingTaskBrightness(tts);
} else {
Log.i(TAG, "Is NULL.");
}
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
}
@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;
}
}
This is the code I tried:
B4X:
Label1.Text = JO.InitializeStatic("com.xixun.joey.aidlset.CardService").RunMethod("GetBrightness", Null)
That didnt work so I must be missing something as I see they are doing something else with: card = CommunicationJoey.getCardService(MainActivity.this);
At this point I am completely lost as I have almost zero java knowledge. Just a VB guy.
Any help here would be awesome!