AntennaPod/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/VideoPlayerActivityStarter....

39 lines
1.2 KiB
Java

package de.danoeh.antennapod.ui.appstartintent;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
/**
* Launches the video player activity of the app with specific arguments.
* Does not require a dependency on the actual implementation of the activity.
*/
public class VideoPlayerActivityStarter {
public static final String INTENT = "de.danoeh.antennapod.intents.VIDEO_PLAYER";
private final Intent intent;
private final Context context;
public VideoPlayerActivityStarter(Context context) {
this.context = context;
intent = new Intent(INTENT);
intent.setPackage(context.getPackageName());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
}
}
public Intent getIntent() {
return intent;
}
public PendingIntent getPendingIntent() {
return PendingIntent.getActivity(context, R.id.pending_intent_video_player,
getIntent(), PendingIntent.FLAG_UPDATE_CURRENT);
}
public void start() {
context.startActivity(getIntent());
}
}