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");
     
  • 相关阅读:
    写在连载之前——DIY微型操作系统篇
    footer始终在页面最底部的方法(问题待检验)
    各种二级菜单代码
    复选框已经有checked,但是页面没有选中效果(解决)
    px em rem 的区别
    marquee标签详解
    Docker:正常运行的容器突然端口不通一般检查方法
    linux中 vm.overcommit_memory 的含义
    redis6 redis-cli cluster的使用总结
    利用Java反射机制优化简单工厂设计模式
  • 原文地址:https://www.cnblogs.com/marklove/p/10464975.html
Copyright © 2011-2022 走看看