本文整理汇总了C#中Bundle.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Bundle.Get方法的具体用法?C# Bundle.Get怎么用?C# Bundle.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bundle
的用法示例。
在下文中一共展示了Bundle.Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Quest
public Quest(Bundle b)
: this()
{
ID = (int)b.Get ("id");
Name = (string)b.Get ("name");
Description = (string)b.Get ("description");
XP = (int)b.Get ("xp");
Joules = (int)b.Get ("joules");
}
示例2: OnMessageReceived
public override void OnMessageReceived(string from, Bundle data)
{
var notificationBundle = data.Get("notification") as Bundle;
if (notificationBundle != null)
{
var message = notificationBundle.Get("body").ToString();
var pushService = DependencyService.Get<IPushService>();
var dict = new Dictionary<string, string>();
dict.Add("notification", message);
pushService.ProcessPushNotification(dict);
SendNotification(message);
}
}
示例3: GetResponseCodeFromBundle
/// <summary>
/// Workaround to bug where sometimes response codes come as Long instead of Integer
/// </summary>
/// <param name="b"></param>
/// <returns></returns>
public static int GetResponseCodeFromBundle(Bundle b)
{
var o = b.Get(Consts.RESPONSE_CODE);
if (o == null)
{
LogDebug("Bundle with null response code, assuming OK (known issue)");
return Consts.BILLING_RESPONSE_RESULT_OK;
}
else if (o is Integer)
return (int)o;
else if (o is Long)
return (int)o;
else
{
LogError("Unexpected type for bundle response code.");
LogError(o.GetType().Name);
throw new RuntimeException("Unexpected type for bundle response code: " + o.GetType().Name);
}
}
示例4: OnMessageReceived
/// <summary>
/// Called when message is received.
/// </summary>
/// <param name="from"></param>
/// <param name="extras"></param>
public override void OnMessageReceived(string from,Bundle extras)
{
if (extras != null && !extras.IsEmpty)
{
System.Diagnostics.Debug.WriteLine(string.Format("{0} - GCM Listener - Push Received", PushNotificationKey.DomainName));
var parameters = new Dictionary<string, object>();
foreach (var key in extras.KeySet())
{
parameters.Add(key, extras.Get(key));
System.Diagnostics.Debug.WriteLine(string.Format("{0} - GCM Listener - Push Params {1} : {2}", PushNotificationKey.DomainName, key, extras.Get(key)));
}
Context context = Android.App.Application.Context;
if (CrossPushNotification.IsInitialized)
{
CrossPushNotification.PushNotificationListener.OnMessage(parameters, DeviceType.Android);
}
else
{
throw CrossPushNotification.NewPushNotificationNotInitializedException();
}
try
{
int notifyId = 0;
string title = context.ApplicationInfo.LoadLabel(context.PackageManager);
string message = "";
string tag = "";
if (!string.IsNullOrEmpty(CrossPushNotification.NotificationContentTextKey) && parameters.ContainsKey(CrossPushNotification.NotificationContentTextKey))
{
message = parameters[CrossPushNotification.NotificationContentTextKey].ToString();
}
else if (parameters.ContainsKey(PushNotificationKey.Message))
{
message = parameters[PushNotificationKey.Message].ToString();
}
else if (parameters.ContainsKey(PushNotificationKey.Subtitle))
{
message = parameters[PushNotificationKey.Subtitle].ToString();
}
else if (parameters.ContainsKey(PushNotificationKey.Text))
{
message = parameters[PushNotificationKey.Text].ToString();
}
if (!string.IsNullOrEmpty(CrossPushNotification.NotificationContentTitleKey) && parameters.ContainsKey(CrossPushNotification.NotificationContentTitleKey))
{
title = parameters[CrossPushNotification.NotificationContentTitleKey].ToString();
}
else if (parameters.ContainsKey(PushNotificationKey.Title))
{
if (!string.IsNullOrEmpty(message))
{
title = parameters[PushNotificationKey.Title].ToString();
}
else
{
message = parameters[PushNotificationKey.Title].ToString();
}
}
if (parameters.ContainsKey(PushNotificationKey.Id))
{
var str = parameters[PushNotificationKey.Id].ToString();
try
{
notifyId = Convert.ToInt32(str);
}
catch (System.Exception)
{
// Keep the default value of zero for the notify_id, but log the conversion problem.
System.Diagnostics.Debug.WriteLine("Failed to convert {0} to an integer", str);
}
}
if (parameters.ContainsKey(PushNotificationKey.Tag))
{
tag = parameters[PushNotificationKey.Tag].ToString();
}
if (!parameters.ContainsKey(PushNotificationKey.Silent) || !System.Boolean.Parse(parameters[PushNotificationKey.Silent].ToString()))
{
if (CrossPushNotification.PushNotificationListener.ShouldShowNotification())
{
CreateNotification(title, message, notifyId, tag);
}
}
//.........这里部分代码省略.........
示例5: GetResponseCodeFromBundle
int GetResponseCodeFromBundle (Bundle bunble)
{
object response = bunble.Get (Response.Code);
if (response == null) {
//Bundle with null response code, assuming OK (known issue)
return BillingResult.OK;
}
if (response is Java.Lang.Number) {
return ((Java.Lang.Number)response).IntValue ();
}
return BillingResult.Error;
}