I have a streaming app which plays video in ExoPlayer2
. I added an intent which opens the video in the external player but I want to check if the getData()
is empty/null
and if so, then show a toast or proceed with the intent
.
My code:
imgExternal.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
if(getIntent().getData() == null) {
new ToastMsg(DetailsActivity.this).toastIconError("Sorry but there was an error retrieving the url!");
} else {
intent.setData(Uri.parse(listDirector.get(0).getStremURL()));
startActivity(Intent.createChooser(intent, "Open In"));
}
}
});
Now the problem is, my app thinks everything is null and showing me toast so any help would be appreciated.
You can check
if (listDirector.get(0).getStremURL() == null) {
new ToastMsg(DetailsActivity.this).toastIconError("Sorry but there was an error retrieving the url!");
} else {
intent.setData(Uri.parse(listDirector.get(0).getStremURL()));
startActivity(Intent.createChooser(intent, "Open In"));
}
代替getIntent().getData()
尝试使用this.getIntent().getData()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.