I'm developing an APP that needs to gets the stream of an Airdrone through mjpeg.
I'm using the classes from this topic. It works great with the example but I need to add some other elements to the same view such as the buttons to control de airdrome.
The example code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
mv = new MjpegView(this);
setContentView(mv);
...
What i'm trying to do but is not working...
...
mv = (MjpegView) findViewById(R.id.mv);
setContentView(R.layout.activity_test);
...
And my layout xml...
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
tools:context="com.gabilheri.rosbridgecontroller.app.TestActivity"
android:layout_height="fill_parent"
android:id="@+id/mainLayout">
<com.gabilheri.rosbridgecontroller.app.VideoStreamClasses.MjpegView
android:id="@+id/mv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</FrameLayout>
This is the LOGCAT error:
04-26 22:40:19.521 2229-2229/com.gabilheri.rosbridgecontroller.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.gabilheri.rosbridgecontroller.app, PID: 2229
java.lang.NullPointerException
at com.gabilheri.rosbridgecontroller.app.TestActivity$DoRead.onPostExecute(TestActivity.java:86)
at com.gabilheri.rosbridgecontroller.app.TestActivity$DoRead.onPostExecute(TestActivity.java:59)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5184)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1015)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
at dalvik.system.NativeStart.main(Native Method)
This are the lines from the method onPost execute:
mv.setSource(result); //Line 86
mv.setDisplayMode(MjpegView.SIZE_BEST_FIT); // Line 87
mv.showFps(true); // Line 88
Anyone have any ideas? Thank you! :D
I figured it out what was my problem...
I was trying to do:
And was getting a NullPointerException.. I changed to:
And now everything is working like is supposed to be :)