声明时清单中缺少活动

时间:2018-05-01 12:57:45

标签: java android manifest

如图所示,有两个箭头.. 一个表示我的项目中的活动 另一个表明建议活动在清单中声明.. 但除了“StreamingActivity”之外没有推荐的活动 当我运行我的应用程序时,应用程序向我显示该消息“不幸的是,应用程序已停止”

enter image description here

此发布的代码

package khaabbas.huthaifa.com.talk_listen;

import android.hardware.Camera;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.red5pro.streaming.R5Connection;
import com.red5pro.streaming.R5Stream;
import com.red5pro.streaming.R5StreamProtocol;
import com.red5pro.streaming.config.R5Configuration;
import com.red5pro.streaming.source.R5Camera;
import com.red5pro.streaming.source.R5Microphone;
//import android.graphics.Camera;

public class PublishFragment extends android.support.v4.app.Fragment implements SurfaceHolder.Callback {
public static android.support.v4.app.Fragment newInstance() {
    PublishFragment fragment = new PublishFragment();
    Bundle args = new Bundle();
    fragment.setArguments(args);
    return fragment;
}


public PublishFragment() {
    // Required empty public constructor
}

public R5Configuration configuration;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    configuration = new R5Configuration(R5StreamProtocol.RTSP, "localhost",  8554, "live", 1.0f);
    configuration.setLicenseKey("NBZF-UFM2-GCEP-OUYZ");
    configuration.setBundleID(getActivity().getPackageName());
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_publish, container, false);
    return v;
}
protected Camera camera;
protected boolean isPublishing = false;
protected R5Stream stream;

private void preview() {
    camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
    SurfaceView surface = (SurfaceView) getActivity().findViewById(R.id.surfaceView);
    surface.getHolder().addCallback(this);
}

@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
    try {
        camera.setPreviewDisplay(surfaceHolder);
        camera.startPreview();
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}

@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {

}

@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {

}
@Override
public void onResume() {
    super.onResume();
    preview();
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    Button publishButton = (Button) getActivity().findViewById(R.id.publishButton);
    publishButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onPublishToggle();
        }
    });
}

private void onPublishToggle() {
    Button publishButton = (Button) getActivity().findViewById(R.id.publishButton);
    if(isPublishing) {
        stop();
    }
    else {
        start();
    }
    isPublishing = !isPublishing;
    publishButton.setText(isPublishing ? "stop" : "start");
}

public void start() {
    camera.stopPreview();

    stream = new R5Stream(new R5Connection(configuration));
    stream.setView((SurfaceView) getActivity().findViewById(R.id.surfaceView));

    R5Camera r5Camera = new R5Camera(camera, 320, 240);
    R5Microphone r5Microphone = new R5Microphone();

    stream.attachCamera(r5Camera);
    stream.attachMic(r5Microphone);

    stream.publish("red5prostream", R5Stream.RecordType.Live);
    camera.startPreview();
}

public void stop() {
    if(stream != null) {
        stream.stop();
        camera.startPreview();
    }
}

@Override
public void onPause() {
    super.onPause();
    if(isPublishing) {
        onPublishToggle();
    }
}



}

2 个答案:

答案 0 :(得分:0)

删除这个活动,因为你只使用了一个活动来定义活动,另外两个是碎片。

    <activity android:name=".S"/>
    <activity android:name=".Sub"/>

和片段调用在代码下面使用..

         Fragment fragment = new HomeFragment();
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragment_frame, fragment, fragment.getClass().getSimpleName()).addToBackStack(null).commit();

答案 1 :(得分:0)

无需在清单上声明片段,从清单中删除片段声明,因为您在清单文件中的部分内声明了片段。