Skip to content

Commit

Permalink
playUtils: try to avoid IllegalStateException when activity is finishing
Browse files Browse the repository at this point in the history
  • Loading branch information
courville committed May 19, 2024
1 parent 8f31f4d commit 2e67cf4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/java/com/archos/mediacenter/video/utils/PlayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.archos.mediacenter.video.utils;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -386,11 +387,15 @@ private void onResumeReady(Context context, Video video, final String mimeType,

ExternalPlayerResultListener.ExternalPositionExtra.setAllPositionExtras(intent,resumePosition );
try {
if(externalPlayerWithResultStarter==null||!allow3rdPartyPlayer(context))
context.startActivity(intent);
else {
if(externalPlayerWithResultStarter==null||!allow3rdPartyPlayer(context)) {
if (!((Activity) context).isFinishing()) {
context.startActivity(intent);
}
} else {
ExternalPlayerResultListener.getInstance().init(context, video.getUri(), dataUri, mVideoDbInfo);
externalPlayerWithResultStarter.startActivityWithResultListener(intent);
if (!((Activity) context).isFinishing()) {
externalPlayerWithResultStarter.startActivityWithResultListener(intent);
}
}
} catch (ActivityNotFoundException e) {
Toast.makeText(context, R.string.no_application_to_open_file, Toast.LENGTH_SHORT).show();
Expand Down

0 comments on commit 2e67cf4

Please sign in to comment.