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");
     
  • 相关阅读:
    怎么样把网站logo(小图标)在地址栏里显示
    PHP 做群发短信(短信接口连接问题)
    网页JS弹出广告代码,头部,右下角,网页中漂浮,对联广告代码等大全
    PHP 时间戳与系统时间保持一致
    PHP 把数据表列出来的东西导出成execle格式
    数据库连接类 DB.class.php
    session判断页面是否已经登录的问题
    结合Smarty,生成HTML静态页
    PHP做文件下载功能
    滚动字幕,鼠标经过停留
  • 原文地址:https://www.cnblogs.com/marklove/p/10464975.html
Copyright © 2011-2022 走看看