Table of Contents

Class AssetVideoActivity

Namespace
VpnHood.AppLib.App.Android.Activities
Assembly
VpnHood.AppLib.App.Android.dll

Represents an activity that plays a video shipped as an asset, full screen over whatever shows, as an ad network's interstitial does.

[Activity(Theme = "@android:style/Theme.Material.NoActionBar.Fullscreen", ConfigurationChanges = ConfigChanges.KeyboardHidden|ConfigChanges.Orientation|ConfigChanges.ScreenSize, ExcludeFromRecents = true)]
public class AssetVideoActivity : Activity, IComponentCallbacks2, IComponentCallbacks, KeyEvent.ICallback, LayoutInflater.IFactory2, LayoutInflater.IFactory, View.IOnCreateContextMenuListener, Window.ICallback, ISurfaceHolderCallback, View.IOnApplyWindowInsetsListener, IJavaObject, IJavaPeerable, IDisposable
Inheritance
AssetVideoActivity
Implements
Inherited Members

Remarks

The video is read where it lies in the package, so its entry must be stored, not deflated. It runs to its end before it can be closed, unless the parameters let it close early: the seconds left count down in the corner and become a close mark, and Close, the caller's action and Back wake at the end. It knows nothing about ads: the caller names the words and the colour, decides what the action does, and is told how it ended.

Methods

OnApplyWindowInsets(View, WindowInsets)

public WindowInsets OnApplyWindowInsets(View view, WindowInsets insets)

Parameters

view View
insets WindowInsets

Returns

WindowInsets

Remarks

The controls keep clear of the cutout and of the navigation bar the background runs under.

OnCreate(Bundle?)

Called when the activity is starting.

protected override void OnCreate(Bundle? savedInstanceState)

Parameters

savedInstanceState Bundle

If the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in #onSaveInstanceState. <b>Note: Otherwise it is null.</b>

Remarks

Called when the activity is starting. This is where most initialization should go: calling setContentView(int) to inflate the activity's UI, using findViewById(int) to programmatically interact with widgets in the UI, calling managedQuery(android.net.Uri,String[],String,String[],String) to retrieve cursors for data being displayed, etc. You can call finish() from within this function, in which case onDestroy() will be immediately called after onCreate(Bundle) without any of the rest of the activity lifecycle (onStart(), onResume(), onPause(), etc.) executing. Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

See also:

Android reference for

    <pre><code class="lang-csharp">android.app.Activity.onCreate</code></pre>

    .</a>
</format>

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

OnDestroy()

Perform any final cleanup before an activity is destroyed.

protected override void OnDestroy()

Remarks

Perform any final cleanup before an activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it), or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isFinishing() method. Note: do not count on this method being called as a place for saving data! For example, if an activity is editing data in a content provider, those edits should be committed in either onPause() or onSaveInstanceState(Bundle), not here. This method is usually implemented to free resources like threads that are associated with an activity, so that a destroyed activity does not leave such things around while the rest of its application is still running. There are situations where the system will simply kill the activity's hosting process without calling this method (or any others) in it, so it should not be used to do things that are intended to remain around after the process goes away. Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

See also:

Android reference for

    <pre><code class="lang-csharp">android.app.Activity.onDestroy</code></pre>

    .</a>
</format>

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

OnKeyDown(Keycode, KeyEvent?)

Called when a key was pressed down and not handled by any of the views inside of the activity.

public override bool OnKeyDown(Keycode keyCode, KeyEvent? e)

Parameters

keyCode Keycode

int: The value in event.getKeyCode().

e KeyEvent

To be added.

Returns

bool

Return true to prevent this event from being propagated further, or false to indicate that you have not handled this event and it should continue to be propagated.

Remarks

Called when a key was pressed down and not handled by any of the views inside of the activity. So, for example, key presses while the cursor is inside a TextView will not trigger the event (unless it is a navigation to another object) because TextView handles its own key presses. If the focused view didn't want this event, this method is called. The default implementation takes care of KeyEvent.KEYCODE_BACK by calling onBackPressed(), though the behavior varies based on the application compatibility mode: for Build.VERSION_CODES.ECLAIR or later applications, it will set up the dispatch to call onKeyUp(int, KeyEvent) where the action will be performed; for earlier applications, it will perform the action immediately in on-down, as those versions of the platform behaved. This implementation will also take care of KeyEvent.KEYCODE_ESCAPE by finishing the activity if it would be closed by touching outside of it. Other additional default key handling may be performed if configured with setDefaultKeyMode(int).

See also:

Android reference for

    <pre><code class="lang-csharp">android.app.Activity.onKeyDown</code></pre>

    .</a>
</format>

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

OnPause()

Called as part of the activity lifecycle when the user no longer actively interacts with the activity, but it is still visible on screen.

protected override void OnPause()

Remarks

Called as part of the activity lifecycle when the user no longer actively interacts with the activity, but it is still visible on screen. The counterpart to onResume(). When activity B is launched in front of activity A, this callback will be invoked on A. B will not be created until A's onPause() returns, so be sure to not do anything lengthy here. This callback is mostly used for saving any persistent state the activity is editing, to present a "edit in place" model to the user and making sure nothing is lost if there are not enough resources to start the new activity without first killing this one. This is also a good place to stop things that consume a noticeable amount of CPU in order to make the switch to the next activity as fast as possible. On platform versions prior to Build.VERSION_CODES.Q this is also a good place to try to close exclusive-access devices or to release access to singleton resources. Starting with Build.VERSION_CODES.Q there can be multiple resumed activities in the system at the same time, so onTopResumedActivityChanged(boolean) should be used for that purpose instead. If an activity is launched on top, after receiving this call you will usually receive a following call to onStop() (after the next activity has been resumed and displayed above). However in some cases there will be a direct call back to onResume() without going through the stopped state. An activity can also rest in paused state in some cases when in multi-window mode, still visible to user. Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

See also:

Android reference for

    <pre><code class="lang-csharp">android.app.Activity.onPause</code></pre>

    .</a>
</format>

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

OnResume()

Called after #onRestoreInstanceState, #onRestart, or #onPause.

protected override void OnResume()

Remarks

Called after onRestoreInstanceState(Bundle), onRestart(), or onPause(). This is usually a hint for your activity to start interacting with the user, which is a good indicator that the activity became active and ready to receive input. This sometimes could also be a transit state toward another resting state. For instance, an activity may be relaunched to onPause() due to configuration changes and the activity was visible, but wasn't the top-most activity of an activity task. onResume() is guaranteed to be called before onPause() in this case which honors the activity lifecycle policy and the activity eventually rests in onPause(). On platform versions prior to Build.VERSION_CODES.Q this is also a good place to try to open exclusive-access devices or to get access to singleton resources. Starting with Build.VERSION_CODES.Q there can be multiple resumed activities in the system simultaneously, so onTopResumedActivityChanged(boolean) should be used for that purpose instead. Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

See also:

Android reference for

    <pre><code class="lang-csharp">android.app.Activity.onResume</code></pre>

    .</a>
</format>

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

PlayAsync(IActivityEvent, AssetVideoParams, CancellationToken)

Shows the video over an activity, and returns how it ended.

public static Task<AssetVideoResult> PlayAsync(IActivityEvent activityEvent, AssetVideoParams videoParams, CancellationToken cancellationToken)

Parameters

activityEvent IActivityEvent

The activity to show it over.

videoParams AssetVideoParams

The video, its colour and its words.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<AssetVideoResult>

A task whose result is how the screen ended.

Remarks

The task faults where the asset cannot be opened or the video cannot be played, so a caller that promised to show something knows it did not happen.

Exceptions

OperationCanceledException

cancellationToken was canceled: the call stops waiting, and the screen stays.

InvalidOperationException

The screen could not open the asset or play the video.

ArgumentNullException

activityEvent, videoParams or the video's asset path is null.

ArgumentException

The video's asset path is empty or white space.

SurfaceChanged(ISurfaceHolder, Format, int, int)

This is called immediately after any structural changes (format or size) have been made to the surface.

public void SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)

Parameters

holder ISurfaceHolder

The SurfaceHolder whose surface has changed.

format Format

The new PixelFormat of the surface.

width int

The new width of the surface.

height int

The new height of the surface.

Remarks

SurfaceCreated(ISurfaceHolder)

This is called immediately after the surface is first created.

public void SurfaceCreated(ISurfaceHolder holder)

Parameters

holder ISurfaceHolder

The SurfaceHolder whose surface is being created.

Remarks

SurfaceDestroyed(ISurfaceHolder)

This is called immediately before a surface is being destroyed.

public void SurfaceDestroyed(ISurfaceHolder holder)

Parameters

holder ISurfaceHolder

The SurfaceHolder whose surface is being destroyed.

Remarks