Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application #1

Open
tstr007 opened this issue Mar 24, 2018 · 3 comments

Comments

@tstr007
Copy link

tstr007 commented Mar 24, 2018

`android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

at android.view.ViewRootImpl.setView(ViewRootImpl.java:566)

at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:282)

at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)

at android.app.Dialog.show(Dialog.java:298)

at com.naivor.player.surface.DialogHolder.showNotWifiDialog(DialogHolder.java:116)

at com.naivor.player.VideoPlayer.requestPrepareSourceData(VideoPlayer.java:1175)

at com.naivor.player.surface.ControlView.start(ControlView.java:501)

at com.naivor.player.surface.ControlView$ComponentListener.onClick(ControlView.java:880)

at android.view.View.performClick(View.java:4780)

`

@naivor
Copy link
Owner

naivor commented Mar 24, 2018

There needs a context that which type is activity when you create VideoPlayer,because Dialog needs it ,if you used a application type context , the BadTokenException occoured .

@tstr007
Copy link
Author

tstr007 commented Mar 24, 2018

What did I miss here ?
`package me.domain.naivorplayertest;

import android.support.v7.app.AppCompatActivity;
import com.naivor.player.VideoPlayer;
import com.naivor.player.constant.ScreenState;

import me.domain.naivorplayertest.R;

/**

  • NaivorPlayer 的使用例子
    */
    public class NaivorPlayerActivity extends AppCompatActivity {

    private String testStream ;
    private String testStreamTitle ;

    private VideoPlayer videoPlayer ;

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

     setContentView(R.layout.activity_naivorplayer_test);
    
     testStream = "https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8";
     testStreamTitle = "Test Video Title";
      videoPlayer = findViewById(R.id.videoPlayer);
         //自动缓冲
         videoPlayer.setAutoPrepare(true);
    
         //加载封面
    

// Glide.with(this)
// .load(DataRepo.VIDEO_COVER)
// .override(320, 240)
// .into(videoPlayer.getPreviewView());

        //设置播放源
        videoPlayer.setUpFullscreen(testStream, testStreamTitle);

        //开始播放

}

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

    videoPlayer.onResume();
}

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

    videoPlayer.onPause();
}

@Override
protected void onDestroy() {
    videoPlayer.release();
    super.onDestroy();
}

@Override
public void onBackPressed() {

    if (!videoPlayer.backPress()) {
        super.onBackPressed();
    }

}

}
`

@naivor
Copy link
Owner

naivor commented Mar 25, 2018

Oh,i 'm sorry, it's a bug ,thanks for your feedback, and i do suggest you choose other videoplayer ,this only has a beauteful UI more than Exoplayer2 , and beause of myself reason , this project has given up , and it is not performance !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants