0
저는 Xamarin.Forms의 초보자입니다. 질문 : 공유 코드/xaml.cs에서 다음 코드를 어떻게 호출 할 수 있습니까?내 공유 코드에서 종속성 인젝션 스크린 샷 코드를 호출하는 방법은 무엇입니까?
public class screenshotManager : IScreenshotManager
{
public static Activity Activity { get; set; }
public async System.Threading.Tasks.Task<byte[]> CaptureAsync()
{
if (Activity == null)
{
throw new Exception("You have to set ScreenshotManager.Activity in your Android project");
}
var view = Activity.Window.DecorView;
view.DrawingCacheEnabled = true;
Bitmap bitmap = view.GetDrawingCache(true);
byte[] bitmapData;
using (var stream = new MemoryStream())
{
bitmap.Compress(Bitmap.CompressFormat.Png, 0, stream);
bitmapData = stream.ToArray();
}
return bitmapData;
}
}
당신이 문서를 읽고? https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/dependency-service/introduction/ – Jason
ive는이 코드를 클릭 이벤트 내에 넣으려고했지만 아무 것도 발생하지 않았습니다. DependencyService.Get(). CaptureAsync(); –
구현을 등록 했습니까? [docs asks to] (https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/dependency-service/introduction/)에서 [[assembly : Xamarin.Forms.Dependency (typeof (screenshotManager))]]' #기재)? –