本文整理汇总了C#中Android.Content.Intent.GetByteArrayExtra方法的典型用法代码示例。如果您正苦于以下问题:C# Intent.GetByteArrayExtra方法的具体用法?C# Intent.GetByteArrayExtra怎么用?C# Intent.GetByteArrayExtra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Intent
的用法示例。
在下文中一共展示了Intent.GetByteArrayExtra方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult (requestCode, resultCode, data);
switch (requestCode) {
case CAMMY:
if (resultCode == Result.Ok) {
string filename = data.GetStringExtra ("filename");
if (!string.IsNullOrEmpty (filename)) {
using (Bitmap bmp = BitmapFactory.DecodeFile(filename)) {
if (bmp != null) {
using (MemoryStream ms = new MemoryStream ()) {
bmp.Compress (Bitmap.CompressFormat.Jpeg, 80, ms);
if (userImage == null)
userImage = new byte[ms.Length];
userImage = ms.ToArray ();
displayImage (userImage);
}
}
}
AndroidData.imageFileName = filename;
}
}
break;
case PICCY:
if (resultCode == Result.Ok) {
string filename = getRealPathFromUri (data.Data);
using (Bitmap bmp = BitmapFactory.DecodeFile(filename)) {
if (bmp != null) {
using (MemoryStream ms = new MemoryStream ()) {
bmp.Compress (Bitmap.CompressFormat.Jpeg, 80, ms);
if (userImage == null)
userImage = new byte[ms.Length];
userImage = ms.ToArray ();
displayImage (userImage);
}
}
}
AndroidData.imageFileName = filename;
}
break;
case NEXT:
username.Text = data.GetStringExtra ("username");
email.Text = data.GetStringExtra ("email");
password.Text = verify.Text = data.GetStringExtra ("password");
userImage = data.GetByteArrayExtra ("image");
displayImage (userImage);
break;
}
}
示例2: GetParameterFromIntent
private object GetParameterFromIntent(Intent intent)
{
if (intent == null)
return null;
string value = intent.GetStringExtra(ParameterString);
if (value != null)
return value;
byte[] bytes = intent.GetByteArrayExtra(ParameterSerializer);
if (bytes == null)
return null;
using (var ms = new MemoryStream(bytes))
return _serializer.Deserialize(ms);
}
示例3: OnActivityResult
//.........这里部分代码省略.........
IOConnectionInfo ioc = new IOConnectionInfo();
SetIoConnectionFromIntent(ioc, data);
_keyFileOrProvider = IOConnectionInfo.SerializeToString(ioc);
UpdateKeyfileIocView();
}
break;
case (Result)FileStorageResults.FileUsagePrepared:
if (requestCode == RequestCodePrepareDbFile)
{
if (KeyProviderType == KeyProviders.KeyFile)
{
var iocKeyfile = IOConnectionInfo.UnserializeFromString(_keyFileOrProvider);
App.Kp2a.GetFileStorage(iocKeyfile)
.PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), iocKeyfile,
RequestCodePrepareKeyFile, false);
}
else
PerformLoadDatabase();
}
if (requestCode == RequestCodePrepareKeyFile)
{
PerformLoadDatabase();
}
if (requestCode == RequestCodePrepareOtpAuxFile)
{
GetAuxFileLoader().LoadAuxFile(true);
}
break;
}
if (requestCode == RequestCodeSelectAuxFile && resultCode == Result.Ok)
{
IOConnectionInfo auxFileIoc = new IOConnectionInfo();
SetIoConnectionFromIntent(auxFileIoc, data);
PreferenceManager.GetDefaultSharedPreferences(this).Edit()
.PutString("KP2A.PasswordAct.AuxFileIoc" + IOConnectionInfo.SerializeToString(_ioConnection),
IOConnectionInfo.SerializeToString(auxFileIoc))
.Apply();
GetAuxFileLoader().LoadAuxFile(false);
}
if (requestCode == RequestCodeChallengeYubikey && resultCode == Result.Ok)
{
try
{
_challengeProv = new KeeChallengeProv();
byte[] challengeResponse = data.GetByteArrayExtra("response");
_challengeSecret = _challengeProv.GetSecret(_chalInfo, challengeResponse);
Array.Clear(challengeResponse, 0, challengeResponse.Length);
}
catch (Exception e)
{
Kp2aLog.Log(e.ToString());
Toast.MakeText(this, "Error: " + e.Message, ToastLength.Long).Show();
return;
}
UpdateOkButtonState();
FindViewById(Resource.Id.otpInitView).Visibility = ViewStates.Gone;
if (_challengeSecret != null)
{
new LoadingDialog<object, object, object>(this, true,
//doInBackground
delegate
{
//save aux file
try
{
ChallengeInfo temp = _challengeProv.Encrypt(_challengeSecret);
IFileStorage fileStorage = App.Kp2a.GetOtpAuxFileStorage(_ioConnection);
IOConnectionInfo iocAux = fileStorage.GetFilePath(fileStorage.GetParentPath(_ioConnection),
fileStorage.GetFilenameWithoutPathAndExt(_ioConnection) + ".xml");
if (!temp.Save(iocAux))
{
Toast.MakeText(this, Resource.String.ErrorUpdatingChalAuxFile, ToastLength.Long).Show();
return false;
}
}
catch (Exception e)
{
Kp2aLog.Log(e.ToString());
}
return null;
}
, delegate
{
}).Execute();
}
else
{
Toast.MakeText(this, Resource.String.bad_resp, ToastLength.Long).Show();
return;
}
}
}
示例4: ParseActivityResult
/**
* <p>Call this from your {@link Activity}'s
* {@link Activity#onActivityResult(int, int, Intent)} method.</p>
*
* @return null if the event handled here was not related to this class, or
* else an {@link IntentResult} containing the result of the scan. If the user cancelled scanning,
* the fields will be null.
*/
public static MvxZXingIntentResult ParseActivityResult(int requestCode, Result resultCode, Intent intent)
{
if (requestCode == REQUEST_CODE)
{
if (resultCode == Result.Ok)
{
String contents = intent.GetStringExtra("SCAN_RESULT");
String formatName = intent.GetStringExtra("SCAN_RESULT_FORMAT");
byte[] rawBytes = intent.GetByteArrayExtra("SCAN_RESULT_BYTES");
int? intentOrientation = intent.GetIntExtra("SCAN_RESULT_ORIENTATION", int.MinValue);
int? orientation = intentOrientation == int.MinValue ? null : intentOrientation;
String errorCorrectionLevel = intent.GetStringExtra("SCAN_RESULT_ERROR_CORRECTION_LEVEL");
return new MvxZXingIntentResult(contents,
formatName,
rawBytes,
orientation,
errorCorrectionLevel);
}
return new MvxZXingIntentResult();
}
return null;
}