本文整理汇总了C#中Bundle.PutByteArray方法的典型用法代码示例。如果您正苦于以下问题:C# Bundle.PutByteArray方法的具体用法?C# Bundle.PutByteArray怎么用?C# Bundle.PutByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bundle
的用法示例。
在下文中一共展示了Bundle.PutByteArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenColorSelector
private void OpenColorSelector(object sender, EventArgs e)
{
var intent = new Intent(this, typeof(ColorSelectActivity));
Bundle b = new Bundle();
b.PutByteArray("color", new byte[] { color.R, color.G, color.B });
intent.PutExtra("color", b);
StartActivity(intent);
}
示例2: BackToMain
private void BackToMain(object sender, EventArgs e)
{
Intent.Extras.Remove("color");
Bundle bun = new Bundle();
bun.PutByteArray("newColor", new byte[] { color.R, color.G, color.B });
var intent = new Intent(this, typeof(MainActivity));
intent.PutExtra("newColor", bun);
StartActivity(intent);
}
示例3: SaveToBundle
public static void SaveToBundle(this IStateBundle state, Bundle bundle)
{
var formatter = new BinaryFormatter();
foreach (var kv in state.Data.Where(x => x.Value != null))
{
var value = kv.Value;
if (value.GetType().IsSerializable)
{
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, value);
stream.Position = 0;
bundle.PutByteArray(kv.Key, stream.ToArray());
}
}
}
}
示例4: OnCreate
/** Called when the activity is first created. */
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
if (APP_ID == null) {
Util.ShowAlert (this, "Warning", "Facebook Applicaton ID must be " +
"specified before running this example: see Example.java");
}
SetContentView (Resource.Layout.main);
mLoginButton = (LoginButton)FindViewById (Resource.Id.login);
mText = (TextView)FindViewById (Resource.Id.txt);
mRequestButton = (Button)FindViewById (Resource.Id.requestButton);
mPostButton = (Button)FindViewById (Resource.Id.postButton);
mDeleteButton = (Button)FindViewById (Resource.Id.deletePostButton);
mUploadButton = (Button)FindViewById (Resource.Id.uploadButton);
mFacebook = new Facebook (APP_ID);
mAsyncRunner = new AsyncFacebookRunner (mFacebook);
SessionStore.Restore (mFacebook, this);
SessionEvents.AddAuthListener (new SampleAuthListener (this));
SessionEvents.AddLogoutListener (new SampleLogoutListener (this));
mLoginButton.Init (this, mFacebook);
mRequestButton.Click += delegate {
mAsyncRunner.Request ("me", new SampleRequestListener (this));
};
mRequestButton.Visibility = mFacebook.IsSessionValid ?
ViewStates.Visible :
ViewStates.Invisible;
mUploadButton.Click += async delegate {
Bundle parameters = new Bundle ();
parameters.PutString ("method", "photos.upload");
URL uploadFileUrl = null;
try {
uploadFileUrl = new URL (
"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg");
} catch (MalformedURLException e) {
e.PrintStackTrace ();
}
try {
HttpURLConnection conn = (HttpURLConnection)uploadFileUrl.OpenConnection ();
conn.DoInput = true;
await conn.ConnectAsync ();
int length = conn.ContentLength;
byte[] imgData = new byte[length];
var ins = conn.InputStream;
await ins.ReadAsync (imgData, 0, imgData.Length);
parameters.PutByteArray ("picture", imgData);
} catch (IOException e) {
e.PrintStackTrace ();
}
mAsyncRunner.Request (null, parameters, "POST",
new SampleUploadListener (this), null);
};
mUploadButton.Visibility = mFacebook.IsSessionValid ?
ViewStates.Visible :
ViewStates.Invisible;
mPostButton.Click += delegate {
mFacebook.Dialog (this, "feed",
new SampleDialogListener (this));
};
mPostButton.Visibility = mFacebook.IsSessionValid ?
ViewStates.Visible :
ViewStates.Invisible;
}
示例5: OnCreate
protected override void OnCreate(Bundle bundle)
{
sInstance = this;
base.OnCreate(bundle);
Game1.Activity = this;
mGame = new Game1();
SetContentView(mGame.Window);
using (var ignore = new TV.Ouya.Sdk.OuyaInputView(this))
{
// do nothing
}
View content = FindViewById (Android.Resource.Id.Content);
if (null != content) {
content.KeepScreenOn = true;
}
mGame.Run();
Bundle developerInfo = new Bundle();
developerInfo.PutString(OuyaFacade.OUYA_DEVELOPER_ID, "310a8f51-4d6e-4ae5-bda0-b93878e5f5d0");
byte[] applicationKey = null;
// load the application key from assets
try {
AssetManager assetManager = ApplicationContext.Assets;
AssetFileDescriptor afd = assetManager.OpenFd(SIGNING_KEY);
int size = 0;
if (null != afd) {
size = (int)afd.Length;
afd.Close();
using (Stream inputStream = assetManager.Open(SIGNING_KEY, Access.Buffer))
{
applicationKey = new byte[size];
inputStream.Read(applicationKey, 0, size);
inputStream.Close();
}
}
} catch (Exception e) {
Log.Error (TAG, string.Format("Failed to read application key exception={0}", e));
}
if (null != applicationKey) {
Log.Debug (TAG, "Read signing key");
developerInfo.PutByteArray (OuyaFacade.OUYA_DEVELOPER_PUBLIC_KEY, applicationKey);
} else {
Log.Error (TAG, "Failed to authorize with signing key");
Finish ();
return;
}
developerInfo.PutString(OuyaFacade.XIAOMI_APPLICATION_ID, "0000000000000");
developerInfo.PutString(OuyaFacade.XIAOMI_APPLICATION_KEY, "000000000000000000");
developerInfo.PutStringArray(OuyaFacade.OUYA_PRODUCT_ID_LIST, Game1.PURCHASABLES);
_ouyaFacade = OuyaFacade.Instance;
_ouyaFacade.Init(this, developerInfo);
}