本文整理汇总了C#中Android.Content.Intent.GetIntExtra方法的典型用法代码示例。如果您正苦于以下问题:C# Intent.GetIntExtra方法的具体用法?C# Intent.GetIntExtra怎么用?C# Intent.GetIntExtra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Intent
的用法示例。
在下文中一共展示了Intent.GetIntExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnReceive
public override void OnReceive(Context context, Intent intent)
{
if (!MainActivity.REPLY_ACTION.Equals(intent.Action))
return;
var requestId = intent.GetIntExtra(MainActivity.REQUEST_CODE_KEY, -1);
if (requestId == -1)
return;
var reply = GetMessageText(intent);
using (var notificationManager = NotificationManagerCompat.From(context))
{
// Create new notification to display, or re-build existing conversation to update with new response
var notificationBuilder = new NotificationCompat.Builder(context);
notificationBuilder.SetSmallIcon(Resource.Drawable.reply);
notificationBuilder.SetContentText(Application.Context.GetString(Resource.String.replied));
var repliedNotification = notificationBuilder.Build();
// Call notify to stop progress spinner.
notificationManager.Notify(requestId, repliedNotification);
}
Toast.MakeText(context, $"Message sent: {reply}", ToastLength.Long).Show();
}
示例2: main
public static int main(Intent i){
switch (i.GetIntExtra("previous",3)) { // This value shows which is the previous activity, with: 0-MainActivity/1-VertexActivity/2-EdgeActivity/3-Any other
case 0:
initiate(i);
break;
case 1:
switch (graph.addVertex(i.GetStringExtra("vertex"))) {
case -1:
return 1;
case -2:
return 6;
default:
return 2;
}
case 2:
switch (graph.addEdge(i.GetIntExtra("weight", -1),i.GetStringExtra("start"),i.GetStringExtra("end"))){
case -1:
return 1;
case -2:
return 3;
case -3:
return 4;
case -4:
return 7; //Do not accept weight 0
default:
return 5;
}
}
return 0;
}
示例3: OnReceive
public override void OnReceive(Context context, Intent intent)
{
var level = intent.GetIntExtra(BatteryManager.ExtraLevel, -1);
var scale = intent.GetIntExtra(BatteryManager.ExtraScale, -1);
var batteryPct = level / (float)scale;
_batteryLevel.Text = string.Format("{000} %", batteryPct * 100);
_batteryHealth.Text = ((BatteryHealth)intent.GetIntExtra(BatteryManager.ExtraHealth, 0)).ToString();
_batteryTemp.Text = string.Format("{0:0.00} C", intent.GetIntExtra(BatteryManager.ExtraTemperature, 0) / 10.0);
_batteryVoltage.Text = intent.GetIntExtra(BatteryManager.ExtraVoltage, 0) + " mV";
}
示例4: OnHandleIntent
protected override void OnHandleIntent (Intent intent)
{
google_api_client.BlockingConnect (TIME_OUT_MS, TimeUnit.Milliseconds);
Android.Net.Uri dataItemUri = intent.Data;
if (!google_api_client.IsConnected) {
Log.Error (TAG, "Failed to update data item " + dataItemUri +
" because client is disconnected from Google Play Services");
return;
}
var dataItemResult = WearableClass.DataApi.GetDataItem (
google_api_client, dataItemUri).Await ().JavaCast<IDataApiDataItemResult> ();
var putDataMapRequest = PutDataMapRequest.CreateFromDataMapItem (
DataMapItem.FromDataItem (dataItemResult.DataItem));
var dataMap = putDataMapRequest.DataMap;
//update quiz status variables
int questionIndex = intent.GetIntExtra (EXTRA_QUESTION_INDEX, -1);
bool chosenAnswerCorrect = intent.GetBooleanExtra (EXTRA_QUESTION_CORRECT, false);
dataMap.PutInt (Constants.QUESTION_INDEX, questionIndex);
dataMap.PutBoolean (Constants.CHOSEN_ANSWER_CORRECT, chosenAnswerCorrect);
dataMap.PutBoolean (Constants.QUESTION_WAS_ANSWERED, true);
PutDataRequest request = putDataMapRequest.AsPutDataRequest ();
WearableClass.DataApi.PutDataItem (google_api_client, request).Await ();
//remove this question notification
((NotificationManager)GetSystemService (NotificationService)).Cancel (questionIndex);
google_api_client.Disconnect ();
}
示例5: OnReceive
public override void OnReceive(Context context, Intent intent)
{
string action = intent.Action;
if (WifiP2pManager.WifiP2pStateChangedAction == action)
{
// Determine if Wifi Direct mode is enabled
int state = intent.GetIntExtra(WifiP2pManager.ExtraWifiState, -1);
Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> WifiDirectReceiver - OnReceive - WifiP2pStateChangedAction - state: {0}", state);
if (state == (int)WifiP2pState.Enabled)
{
// enabled
}
else
{
// disabled
}
}
else if (WifiP2pManager.WifiP2pPeersChangedAction == action)
{
Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> WifiDirectReceiver - OnReceive - WifiP2pPeersChangedAction");
_manager.RequestPeers(_channel, _peerListListener);
}
else if (WifiP2pManager.WifiP2pConnectionChangedAction == action)
{
Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> WifiDirectReceiver - OnReceive - WifiP2pConnectionChangedAction");
}
else if (WifiP2pManager.WifiP2pThisDeviceChangedAction == action)
{
Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> WifiDirectReceiver - OnReceive - WifiP2pThisDeviceChangedAction");
}
}
示例6: CompleteWakefulIntent
/// <summary>
/// Finish the execution from previous <see cref="StartWakefulService(Context, Intent)"/>.
/// </summary>
/// <remarks>
/// Any wake lock that was being held will now be released.
/// </remarks>
/// <param name="intent">The <see cref="Intent"/> that was originally generated by <see cref="StartWakefulService(Context, Intent)"/></param>
/// <returns><c>true</c> if the intent is associated with a wake lock that is now released.
/// Returns <c>false</c> if there was no wake lock specified for it.</returns>
internal static bool CompleteWakefulIntent(Intent intent) {
int id = intent.GetIntExtra(ExtraWakeLockId, 0);
if (id == 0) {
return false;
}
lock (activeWakeLocksMutex) {
PowerManager.WakeLock wl = activeWakeLocks[id];
if (wl != null) {
wl.Release();
activeWakeLocks.Remove(id);
return true;
}
// We return true whether or not we actually found the wake lock
// the return code is defined to indicate whether the Intent contained
// an identifier for a wake lock that it was supposed to match.
// We just log a warning here if there is no wake lock found, which could
// happen for example if this function is called twice on the same
// intent or the process is killed and restarted before processing the intent.
Android.Util.Log.Warn("ParseWakefulHelper", "No active wake lock id #" + id);
return true;
}
}
示例7: OnCreate
public override void OnCreate (Android.OS.Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
if (savedInstanceState != null) {
mRetryCounter = savedInstanceState.GetInt (KEY_RETRY_COUNTER);
mRetryLoadFullWalletCount = savedInstanceState.GetInt (KEY_RETRY_FULL_WALLET_COUNTER);
mHandleFullWalletWhenReady =
savedInstanceState.GetBoolean (KEY_HANDLE_FULL_WALLET_WHEN_READY);
}
mActivityLaunchIntent = Activity.Intent;
mItemId = mActivityLaunchIntent.GetIntExtra (Constants.EXTRA_ITEM_ID, 0);
mMaskedWallet = mActivityLaunchIntent.GetParcelableExtra (Constants.EXTRA_MASKED_WALLET).JavaCast<MaskedWallet> ();
var accountName = ((BikestoreApplication) Activity.Application).AccountName;
// Set up an API client;
mGoogleApiClient = new GoogleApiClient.Builder (Activity)
.AddConnectionCallbacks (this)
.AddOnConnectionFailedListener (this)
.SetAccountName (accountName)
.AddApi (WalletClass.API, new WalletClass.WalletOptions.Builder ()
.SetEnvironment (Constants.WALLET_ENVIRONMENT)
.SetTheme (WalletConstants.ThemeLight)
.Build ())
.Build ();
mRetryHandler = new RetryHandler (this);
}
示例8: OnReceive
public override void OnReceive(Context context, Intent intent)
{
var action = intent.Action;
switch (action)
{
case WifiP2pManager.WifiP2pStateChangedAction:
WifiP2pState state = (WifiP2pState)intent.GetIntExtra(WifiP2pManager.ExtraWifiState, -1);
P2PManager.Available = state == WifiP2pState.Enabled;
break;
case WifiP2pManager.WifiP2pPeersChangedAction:
manager.RequestPeers(channel, new PeerListListener(peerList =>
{
P2PManager.peerList = peerList.DeviceList;
P2PManager.waitForPeerListSuccess = true;
P2PManager.waitForPeerList.Set();
}));
break;
case WifiP2pManager.WifiP2pConnectionChangedAction:
break;
case WifiP2pManager.WifiP2pThisDeviceChangedAction:
break;
}
}
示例9: OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (resultCode == Result.Ok)
if (requestCode==tkey)
{
EditText tb1 = FindViewById<EditText>(Resource.Id.text);
tb1.Text = File.ReadAllText(data.GetStringExtra("1"));
Log.Verbose("FileListFragment", "файл {0} был открыт.", data.GetStringExtra("1"));
Toast.MakeText(this, "файл выбран" + data.GetStringExtra("1"), ToastLength.Short).Show();
}
else
{
ttslist[data.GetIntExtra("4",0)] = new elemTts(data.GetStringExtra("1"), data.GetIntExtra("2",0) / 255f + 0.1f,data.GetIntExtra("3",0) / 170f + 0.5f);
}
}
示例10: OnReceive
public override void OnReceive(Context context, Intent intent)
{
var message = new SmsMessage {
Text = intent.GetStringExtra ("messageText"),
SmsGroupId = intent.GetIntExtra ("smsGroupId", -1),
ContactAddressBookId = intent.GetStringExtra ("addressBookId"),
ContactName = intent.GetStringExtra ("contactName"),
SentDate = DateTime.Parse (intent.GetStringExtra ("dateSent"))
};
switch ((int)ResultCode)
{
case (int)Result.Ok:
_messageRepo = new Repository<SmsMessage>();
_messageRepo.Save (message);
Toast.MakeText (context, string.Format ("Message sent to {0}", message.ContactName), ToastLength.Short).Show ();
break;
case (int)global::Android.Telephony.SmsResultError.NoService:
case (int)global::Android.Telephony.SmsResultError.RadioOff:
case (int)global::Android.Telephony.SmsResultError.NullPdu:
case (int)global::Android.Telephony.SmsResultError.GenericFailure:
default:
Toast.MakeText (context, string.Format("Doh! Message could not be sent to {0}.", message.ContactName),
ToastLength.Short).Show ();
break;
}
_messageRepo = null;
}
示例11: OnReceive
/// <summary>
/// This is the entry point for all asynchronous messages sent from Android Market to
/// the application. This method forwards the messages on to the
/// <seealso cref="BillingService"/>, which handles the communication back to Android Market.
/// The <seealso cref="BillingService"/> also reports state changes back to the application through
/// the <seealso cref="ResponseHandler"/>.
/// </summary>
public override void OnReceive(Context context, Intent intent)
{
string action = intent.Action;
if (Consts.ACTION_PURCHASE_STATE_CHANGED.Equals(action))
{
string signedData = intent.GetStringExtra(Consts.INAPP_SIGNED_DATA);
string signature = intent.GetStringExtra(Consts.INAPP_SIGNATURE);
purchaseStateChanged(context, signedData, signature);
}
else if (Consts.ACTION_NOTIFY.Equals(action))
{
string notifyId = intent.GetStringExtra(Consts.NOTIFICATION_ID);
if (Consts.DEBUG)
{
Log.Info(TAG, "notifyId: " + notifyId);
}
notify(context, notifyId);
}
else if (Consts.ACTION_RESPONSE_CODE.Equals(action))
{
long requestId = intent.GetLongExtra(Consts.INAPP_REQUEST_ID, -1);
int responseCodeIndex = intent.GetIntExtra(Consts.INAPP_RESPONSE_CODE, (int)Consts.ResponseCode.RESULT_ERROR);
checkResponseCode(context, requestId, responseCodeIndex);
}
else
{
Log.Warn(TAG, "unexpected action: " + action);
}
}
示例12: OnReceive
public override void OnReceive(Context context, Intent intent)
{
var action = intent.Action;
if (WifiP2pManager.WifiP2pStateChangedAction.Equals(action))
{
// UI update to indicate wifi p2p status.
var state = intent.GetIntExtra(WifiP2pManager.ExtraWifiState, -1);
if (state == (int) WifiP2pState.Enabled)
// Wifi Direct mode is enabled
_activity.IsWifiP2PEnabled = true;
else
{
_activity.IsWifiP2PEnabled = false;
_activity.ResetData();
}
Log.Debug(WiFiDirectActivity.Tag, "P2P state changed - " + state);
}
else if (WifiP2pManager.WifiP2pPeersChangedAction.Equals(action))
{
// request available peers from the wifi p2p manager. This is an
// asynchronous call and the calling activity is notified with a
// callback on PeerListListener.onPeersAvailable()
if (_manager != null)
{
_manager.RequestPeers(_channel,
_activity.FragmentManager.FindFragmentById<DeviceListFragment>(Resource.Id.frag_list));
}
Log.Debug(WiFiDirectActivity.Tag, "P2P peers changed");
}
else if (WifiP2pManager.WifiP2pConnectionChangedAction.Equals(action))
{
if (_manager == null)
return;
var networkInfo = (NetworkInfo) intent.GetParcelableExtra(WifiP2pManager.ExtraNetworkInfo);
if (networkInfo.IsConnected)
{
// we are connected with the other device, request connection
// info to find group owner IP
var fragment =
_activity.FragmentManager.FindFragmentById<DeviceDetailFragment>(Resource.Id.frag_detail);
_manager.RequestConnectionInfo(_channel, fragment);
}
else
{
// It's a disconnect
_activity.ResetData();
}
}
else if (WifiP2pManager.WifiP2pThisDeviceChangedAction.Equals(action))
{
var fragment =
_activity.FragmentManager.FindFragmentById<DeviceListFragment>(Resource.Id.frag_list);
fragment.UpdateThisDevice((WifiP2pDevice)intent.GetParcelableExtra(WifiP2pManager.ExtraWifiP2pDevice));
}
}
示例13: GetRecipeId
public static int? GetRecipeId(Intent intent) {
var recipeId = intent.GetIntExtra(RecipeId, -1);
if(recipeId != -1) {
return recipeId;
}
return null;
}
示例14: GetAlbum
public static Album GetAlbum (DrunkAudibleMobileDatabase database, Intent intent)
{
var album = database
.Albums
.FirstOrDefault (a => a.Id == intent.GetIntExtra (ALBUM_ID_INTENT_EXTRA, -1));
return album ?? Album.Empty;
}
示例15: OnReceive
public override void OnReceive(Context context, Intent intent) {
if (intent.Action.Equals(ACTION_STARTED)) {
callbackData.Text = ("STARTED");
} else if (intent.Action.Equals(ACTION_UPDATE)) {
callbackData.Text = ("Got update: " + intent.GetIntExtra("value", 0));
} else if (intent.Action.Equals(ACTION_STOPPED)) {
callbackData.Text = ("STOPPED");
}
}