本文整理汇总了C#中Android.Content.Intent.SetPackage方法的典型用法代码示例。如果您正苦于以下问题:C# Intent.SetPackage方法的具体用法?C# Intent.SetPackage怎么用?C# Intent.SetPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Intent
的用法示例。
在下文中一共展示了Intent.SetPackage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
var registerButton = FindViewById<Button> (Resource.Id.registerButton);
var unregisterButton = FindViewById<Button> (Resource.Id.unregisterButton);
registerButton.Click += delegate {
const string senders = "<Google Cloud Messaging Sender ID>";
var intent = new Intent("com.google.android.c2dm.intent.REGISTER");
intent.SetPackage("com.google.android.gsf");
intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
intent.PutExtra("sender", senders);
StartService(intent);
};
unregisterButton.Click += delegate {
var intent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
StartService(intent);
};
}
示例2: OnWebCheckoutButtonClicked
// Launch the device browser so the user can complete the checkout.
private void OnWebCheckoutButtonClicked(object sender, EventArgs e)
{
var intent = new Intent(Intent.ActionView);
intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
intent.SetData(Android.Net.Uri.Parse(SampleApplication.Checkout.WebUrl));
try
{
intent.SetPackage("com.android.chrome");
StartActivity(intent);
}
catch (Exception)
{
try
{
// Chrome could not be opened, attempt to us other launcher
intent.SetPackage(null);
StartActivity(intent);
}
catch (Exception)
{
OnError(GetString(Resource.String.checkout_error));
}
}
}
示例3: initShareItent
// http://stackoverflow.com/questions/6827407/how-to-customize-share-intent-in-android/9229654#9229654
private void initShareItent(String type)
{
bool found = false;
Intent share = new Intent(Android.Content.Intent.ActionSend);
share.SetType("image/jpeg");
// gets the list of intents that can be loaded.
List<ResolveInfo> resInfo = PackageManager.QueryIntentActivities(share, 0).ToList();
if (resInfo.Count > 0) {
foreach (ResolveInfo info in resInfo) {
if (info.ActivityInfo.PackageName.ToLower().Contains(type) ||
info.ActivityInfo.Name.ToLower().Contains(type)) {
share.PutExtra(Intent.ExtraSubject, "[Corpy] hi");
share.PutExtra(Intent.ExtraText, "Hi " + employee.Firstname);
// share.PutExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(myPath)) );
// class atrribute
share.SetPackage(info.ActivityInfo.PackageName);
found = true;
break;
}
}
if (!found)
return;
StartActivity(Intent.CreateChooser(share, "Select"));
}
}
示例4: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button btnGetRegID = FindViewById<Button> (Resource.Id.btnGetRegID);
string senders = "374823337115";
Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
intent.SetPackage("com.google.android.gsf");
intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
intent.PutExtra("sender", senders);
this.StartService(intent);
txtRegID = FindViewById<TextView> (Resource.Id.txtRegID);
btnGetRegID.Click += delegate {
txtRegID.Text = appRegID;
};
}
示例5: Connect
public void Connect()
{
var serviceIntent = new Intent ("ir.cafebazaar.pardakht.InAppBillingService.BIND");
serviceIntent.SetPackage("com.farsitel.bazaar");
int intentServicesCount = _activity.PackageManager.QueryIntentServices (serviceIntent, 0).Count;
if (intentServicesCount != 0) {
_activity.BindService (serviceIntent, this, Bind.AutoCreate);
}
}
示例6: RegisterForGCM
private void RegisterForGCM()
{
string senders = Constants.GoogleConsoleProjectId;
Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
intent.SetPackage("com.google.android.gsf");
intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
intent.PutExtra("sender", senders);
StartService(intent);
}
示例7: StartService
// main class
public void StartService()
{
string senders = "922250740088";
Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
intent.SetPackage("com.google.android.gsf");
intent.PutExtra("app", PendingIntent.GetBroadcast(Application.Context, 0, new Intent(), 0));
intent.PutExtra("sender", senders);
Application.Context.StartService(intent);
}
示例8: OnReceive
public override void OnReceive(Context context, Intent intent)
{
if (intent.Action != AudioManager.ActionAudioBecomingNoisy)
return;
//signal the service to pause!
var pauseIntent = new Intent(MediaServiceBase.ActionPause);
pauseIntent.SetPackage(context.PackageName);
context.StartService(pauseIntent);
}
示例9: HandleClick
public void HandleClick()
{
Intent i = new Intent(Strings.ActionEntryActionSelected);
i.SetPackage(_pluginPackage);
i.PutExtra(Strings.ExtraActionData, _bundleExtra);
i.PutExtra(Strings.ExtraFieldId, _fieldId);
i.PutExtra(Strings.ExtraSender, _activity.PackageName);
_activity.AddEntryToIntent(i);
_activity.SendBroadcast(i);
}
示例10: BroadcastNewTotp
private void BroadcastNewTotp(string totp)
{
Intent i = new Intent(Strings.ActionSetEntryField);
i.PutExtra(Strings.ExtraAccessToken,new PluginDatabase(_context).GetInternalToken());
i.SetPackage(_context.PackageName);
i.PutExtra(Strings.ExtraSender, _context.PackageName);
i.PutExtra(Strings.ExtraFieldValue, totp);
i.PutExtra(Strings.ExtraEntryId, App.Kp2a.GetDb().LastOpenedEntry.Entry.Uuid.ToHexString());
i.PutExtra(Strings.ExtraFieldId, _totp);
i.PutExtra(Strings.ExtraFieldProtected, true);
_context.SendBroadcast(i);
}
示例11: RegisterForRemoteNotificationsAsync
public async Task RegisterForRemoteNotificationsAsync()
{
var context = Application.Context;
var senderId = DonkyAndroid.Settings.GcmSenderId
?? _configurationManager.GetValue<string>("DefaultGCMSenderId");
Logger.Instance.LogInformation("Registering for GCM with SenderId {0}", senderId);
var senders = senderId;
var intent = new Intent("com.google.android.c2dm.intent.REGISTER");
intent.SetPackage("com.google.android.gsf");
intent.PutExtra("app", PendingIntent.GetBroadcast(context, 0, new Intent(), 0));
intent.PutExtra("sender", senders);
context.StartService(intent);
}
示例12: OnViewCreated
public override void OnViewCreated(View view, Bundle savedInstanceState)
{
base.OnViewCreated (view, savedInstanceState);
ListView.ItemLongClick += (sender, e) => {
var artist = ((ArtistAdapter)ListAdapter).GetArtistData (e.Position);
var name = artist.Name.Replace (' ', '_');
name = Android.Net.Uri.Encode (name);
var uri = "http://www.rdio.com/artist/" + name;
var intent = new Intent (Intent.ActionView,
Android.Net.Uri.Parse (uri));
intent.SetPackage ("com.rdio.android.ui");
StartActivity (intent);
};
}
示例13: RegisterService
public static void RegisterService()
{
var keyStore = new LocalStore();
var interval = keyStore.GetString(Constants.Keys.Interval);
if (string.IsNullOrEmpty(interval))
interval = "1";
var intervalTime = 60000 * int.Parse(interval);
var serviceIntent = new Intent(Constants.GPSServiceIntent);
serviceIntent.SetPackage(Application.Context.PackageName);
var alarm = (AlarmManager)Application.Context.GetSystemService(Context.AlarmService);
var pendingServiceIntent = PendingIntent.GetService(Application.Context, 0, serviceIntent, PendingIntentFlags.CancelCurrent);
alarm.SetRepeating(AlarmType.Rtc, 0, intervalTime, pendingServiceIntent);
}
示例14: Connect
public void Connect()
{
Intent intent = new Intent("ir.cafebazaar.pardakht.InAppBillingService.BIND");
intent.SetPackage("com.farsitel.bazaar");
IList<ResolveInfo> list = this._activity.PackageManager.QueryIntentServices(intent, 0);
if (list == null)
{
this.RaiseOnInAppBillingError(InAppBillingErrorType.BillingNotSupported, "Unable to bind with com.android.vending.billing.InAppBillingService API.");
this.Connected = false;
}
else if (list.Count != 0)
{
this._activity.BindService(intent, this, Bind.AutoCreate);
}
else
{
this.RaiseOnInAppBillingError(InAppBillingErrorType.BillingNotSupported, "Unable to access the com.android.vending service.");
this.Connected = false;
}
}
示例15: OnHandleIntent
protected override void OnHandleIntent(Intent intent)
{
try
{
var context = ApplicationContext;
var action = intent.Action;
switch (action)
{
case "com.google.android.c2dm.intent.REGISTRATION":
var senders = "MySenderID";
var regIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
regIntent.SetPackage("com.google.android.gsf");
regIntent.PutExtra("app", PendingIntent.GetBroadcast(context, 0, new Intent(), 0));
regIntent.PutExtra("sender", senders);
context.StartService(regIntent);
break;
case "com.google.android.c2dm.UNREGISTER":
var unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
unregIntent.PutExtra("app", PendingIntent.GetBroadcast(context, 0, new Intent(), 0));
context.StartService(regIntent);
break;
case "com.google.android.c2dm.intent.RECEIVE":
var eventid = intent.GetStringExtra("eventid");
var eventname = intent.GetStringExtra("eventname");
if (!string.IsNullOrEmpty(eventname) &&)
App.Self.ChangedClass.BroadcastIt(eventname);
break;
}
}
finally
{
lock (LOCK)
{
if (wakeLock != null)
wakeLock.Release();
}
}
}