zoukankan      html  css  js  c++  java
  • 点击按钮打开一个新的窗口 关键词(Intent, setData , putExtra , startActivity |Bundle)

    M3U8_Video_demo 项目

    //------------------ 创建发送
    private void playVideo(String source, String title) {
    if (source == null || source.equals("")) {
    Toast.makeText(this, "视频内容不存在!", Toast.LENGTH_LONG).show();
    source = "http://ad.i5suoi.com/video/94.m3u8";
    Intent intent = new Intent(this, VideoActivity.class);//VideoActivity 是一个完整的xml 窗口

    intent.setData(Uri.parse(source));
    intent.putExtra("mVideoTitle", title);
    startActivity(intent);
    } else {
    Intent intent = new Intent(this, VideoActivity.class);
    intent.setData(Uri.parse(source));//m3u8链接 链接都必须Uri.parse 处理吧?

    intent.putExtra("mVideoTitle", title);//播放标题
            startActivity(intent);//开始新窗体?
    }
    }
    //-----------------接收
    初始化的时候调用
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.play_video);

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, POWER_LOCK);

    Uri uriPath = getIntent().getData();//m3u8链接

    mVideoTitle = getIntent().getStringExtra("mVideoTitle");//播放标题

    if (null != uriPath) {
    String scheme = uriPath.getScheme();
    if (null != scheme) {
    mVideoSource = uriPath.toString();
    } else {
    mVideoSource = uriPath.getPath();
    }
    }

    initUI();
    android-tivi github项目
    ///-----方法2

    protected Void doInBackground(Integer... params) {//创建
    int id = params[0];
    intent = new Intent(getActivity().getApplicationContext(), WatchTvActivity.class);//WatchTvActivity 是一个完整的窗体

    Bundle bundle = new Bundle();
    bundle.putInt("id", id);//传递id索引
    intent.putExtras(bundle);
    return null;
    }
    protected void onPostExecute(Void aVoid) {//检查
    super.onPostExecute(aVoid);//这是个异步处理
    if (dialog != null) dialog.dismiss();
    startActivity(intent);//打开
    }
    //--------获取
    Bundle bundle = getIntent().getExtras();
    id = bundle.getInt("id");
     
  • 相关阅读:
    poj 3321 Apple Tree
    hdu 1520 Anniversary party
    Light OJ 1089 Points in Segments (II)
    Timus 1018 Binary Apple Tree
    zoj 3299 Fall the Brick
    HFUT 1287 法默尔的农场
    Codeforces 159C String Manipulation 1.0
    GraphQL + React Apollo + React Hook 大型项目实战(32 个视频)
    使用 TypeScript & mocha & chai 写测试代码实战(17 个视频)
    GraphQL + React Apollo + React Hook + Express + Mongodb 大型前后端分离项目实战之后端(19 个视频)
  • 原文地址:https://www.cnblogs.com/marklove/p/10464975.html
Copyright © 2011-2022 走看看