0

I've already saw questions suggestions but I didn't find my answer.

The LogCat throws this error:

I/Timeline( 7748): Timeline: Activity_launch_request id:com.miracle.livapp time:45951871
I/ActivityManager(  768): START u0 {flg=0x10000000 cmp=com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity} from uid 10252 on display 0
E/AndroidRuntime( 7748): Process: com.miracle.livapp, PID: 7748
E/AndroidRuntime( 7748): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class ru.denivip.nine00secondssdk.hlsstreaming.Nine00SecondsCameraView
D/ActivityManager(  768): New dropbox entry: com.miracle.livapp, data_app_crash, 877fda44-aca7-4a69-8c23-c0da45fa7bd4
W/ActivityManager(  768):   Force finishing activity com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity
W/ActivityManager(  768):   Force finishing activity com.miracle.livapp/.MainActivity
W/ActivityManager(  768): Activity pause timeout for ActivityRecord{3e7cfd61 u0 com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity t82 f}
W/ActivityManager(  768): Activity destroy timeout for ActivityRecord{338f1497 u0 com.miracle.livapp/.MainActivity t82 f}
W/ActivityManager(  768): Activity destroy timeout for ActivityRecord{3e7cfd61 u0 com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity t82 f}

The class involved has two constructor avoiding the second argument problem that I read in other places:

public Nine00SecondsCameraView(Context context){
    super(context, null);
}

public Nine00SecondsCameraView(Context context, AttributeSet attrs) {
    super(context, attrs);
    ....
}

This is the XML File:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<ru.denivip.nine00secondssdk.hlsstreaming.Nine00SecondsCameraView
    android:id="@+id/streamingView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

<ImageButton
    android:id="@+id/toggleRecording_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:layout_marginRight="16dp"
    android:background="@drawable/circle_button_background_selector"
    android:src="@drawable/reccord_button"
    android:clickable="true"
    android:onClick="clickToggleRecording" />
</RelativeLayout>

And this is the CameraStreamingActivity.java

package com.odizzain.cordova.plugins.livestream;


import ru.denivip.nine00secondssdk.hlsstreaming.Nine00SecondsCameraView;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

public class CameraStreamingActivity extends Activity {


    private String appPackageName = null;
    private Resources appResources = null;

    private Nine00SecondsCameraView streamingView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        appPackageName = getApplication().getPackageName();
        appResources = getApplication().getResources();
        // appResources.getIdentifier("activity_camerabroadcast", "layout", appPackageName)

        setContentView(appResources.getIdentifier("camera_streaming_activity", "layout", appPackageName));
        streamingView = (Nine00SecondsCameraView) findViewById(appResources.getIdentifier("streamingView", "id", appPackageName));
    }

    @Override
    protected void onResume() {
        super.onResume();
        streamingView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        streamingView.onPause();
    }

    /**
     * onClick handler for "record" button.
     */
    public void clickToggleRecording(View unused) {
        if (streamingView.isRecording())
            streamingView.stopRecording();
        else
            streamingView.startRecording();

        updateControls();
    }


    /**
     * Updates the on-screen controls to reflect the current state of the app.
     */
    private void updateControls() {
        ImageButton toggleRelease = (ImageButton) findViewById(appResources.getIdentifier("toggleRecording_button", "id", appPackageName));

        int id = streamingView.isRecording() ?
                appResources.getIdentifier("stop_reccord_button", "drawable", appPackageName) :
                appResources.getIdentifier("reccord_button", "drawable", appPackageName);

        toggleRelease.setImageResource(id);
    }

}

btw, i am using this sdk: http://livestreamsdk.com/

jsertx
  • 636
  • 7
  • 17
  • Can you post the entire logcat? – Timothy Frisch Jul 27 '15 at 16:58
  • @Tukajo done, I added the logcat from the beginning of the activity – jsertx Jul 27 '15 at 17:03
  • Your logcat shows a NullPointerError on line 33 of `CameraStreamingActivity` can you show us that? – Timothy Frisch Jul 27 '15 at 17:06
  • @Tukajo Im so sorry, I put the wrong logcat, now is the correct one. – jsertx Jul 27 '15 at 17:14
  • @Tukajo There you have, sorry. – jsertx Jul 27 '15 at 17:16
  • Change `setContentView(appResources.getIdentifier("camera_streaming_activity", "layout", appPackageName));` to `setContentView(R.layout.myLayout)` for whatever layout you are using. – Timothy Frisch Jul 27 '15 at 17:17
  • Also change streaming view to `streamingView = (Nine00SecondsCameriaView) findViewById(R.id.streamingView);` – Timothy Frisch Jul 27 '15 at 17:18
  • But I added that because I am developing a cordova plugin and I can't know the name of the app package. This allow me to get the resources from the package and does the same, R.layout.myLayout is an integer with the file ID, and appResources.getIdentifier() returns me the same. – jsertx Jul 27 '15 at 17:31
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/84396/discussion-between-sergi-from-and-tukajo). – jsertx Jul 27 '15 at 17:50

1 Answers1

0

I solved adding constructors for this three and four arguments:

SurfaceView(Context context, AttributeSet attrs, int defStyleAttr)
SurfaceView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Like the android documentation says.

jsertx
  • 636
  • 7
  • 17