本文整理汇总了C#中Android.Content.Context.GetObbDirs方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetObbDirs方法的具体用法?C# Context.GetObbDirs怎么用?C# Context.GetObbDirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Context
的用法示例。
在下文中一共展示了Context.GetObbDirs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MountObbs
public void MountObbs(Context context)
{
if ((int) Android.OS.Build.VERSION.SdkInt >= (int) Android.OS.BuildVersionCodes.Kitkat) {
var obbMgr = context.GetSystemService (Context.StorageService).JavaCast<StorageManager> ();
var obbs = context.GetObbDirs ().SelectMany (d => Directory.GetFiles (d.Path, "*.obb"));
foreach (var obb in obbs.Where (obb => !obbMgr.IsObbMounted (obb)))
obbMgr.MountObb (obb, null, new ObbListener ());
}
}
示例2: GetSoundFonts
public static void GetSoundFonts(IList<string> soundFonts, Context context, string predefinedTempPath, CancellationToken cancellationToken = default (CancellationToken))
{
// OBB support
if ((int) Android.OS.Build.VERSION.SdkInt >= (int) Android.OS.BuildVersionCodes.Kitkat) {
var obbMgr = context.GetSystemService (Context.StorageService).JavaCast<StorageManager> ();
var obbs = context.GetObbDirs ().SelectMany (d => Directory.GetFiles (d.Path, "*.obb"));
foreach (var obbDir in obbs.Where (d => obbMgr.IsObbMounted (d)).Select (d => obbMgr.GetMountedObbPath (d)))
foreach (var sf2 in Directory.GetFiles (obbDir, "*.sf2", SearchOption.AllDirectories))
soundFonts.Add (sf2);
}
// Assets
foreach (var asset in context.Assets.List (""))
if (asset.EndsWith (".sf2", StringComparison.OrdinalIgnoreCase))
soundFonts.Add (asset);
#if DEBUG
// temporary local files for debugging
if (Directory.Exists (predefinedTempPath))
foreach (var sf2 in Directory.GetFiles (predefinedTempPath, "*.sf2", SearchOption.AllDirectories))
if (!soundFonts.Any (_ => Path.GetFileName (_) == Path.GetFileName (sf2)))
soundFonts.Add (sf2);
#endif
}