本文整理汇总了C#中Android.Content.Intent.AddCategory方法的典型用法代码示例。如果您正苦于以下问题:C# Intent.AddCategory方法的具体用法?C# Intent.AddCategory怎么用?C# Intent.AddCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Intent
的用法示例。
在下文中一共展示了Intent.AddCategory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.PublicJournalGroupList);
basePath = Intent.GetStringExtra("pjBaseURL");
this.Title = "Group of Departments";
if (!string.IsNullOrEmpty(basePath))
{
try
{
FillDepartments(basePath);
//Notification.Builder builder = new Notification.Builder(this).SetContentText("My text").SetContentTitle("Title goes here.").SetSmallIcon(Resource.Drawable.Icon);
//Notification notification = builder.Build();
//NotificationManager notifyMngr = GetSystemService(Context.NotificationService) as NotificationManager;
//notifyMngr.Notify(0, notification);
//Localhost360Sites.Sites sites = new Localhost360Sites.Sites();
//sites.Credentials.GetCredential()
}
catch (Exception ex)
{
}
}
else
{
Intent startMain = new Intent(Intent.ActionMain);
startMain.AddCategory(Intent.CategoryHome);
// startMain.SetFlags(Intent.Flags);
StartActivity(startMain);
}
// Create your application here
}
示例2: LoadApps
private void LoadApps ()
{
Intent mainIntent = new Intent (Intent.ActionMain, null);
mainIntent.AddCategory (Intent.CategoryLauncher);
mApps = PackageManager.QueryIntentActivities (mainIntent, 0);
}
示例3: GetLauncherPackageName
public static string GetLauncherPackageName(Context context)
{
Intent intent = new Intent(Intent.ActionMain);
intent.AddCategory(Intent.CategoryHome);
ResolveInfo resolveInfo = context.PackageManager.ResolveActivity(intent, PackageInfoFlags.MatchDefaultOnly);
return resolveInfo.ActivityInfo.PackageName;
}
示例4: OnBackPressed
public override void OnBackPressed()
{
var StartMain = new Intent (Intent.ActionMain);
StartMain.AddCategory (Intent.CategoryHome);
StartMain.SetFlags (ActivityFlags.NewTask);
StartActivity (StartMain);
}
示例5: GetDemoActivities
private List<ActivityListItem> GetDemoActivities(string prefix)
{
var results = new List<ActivityListItem>();
// Create an intent to query the package manager with,
// we are looking for ActionMain with our custom category
var query = new Intent(Intent.ActionMain, null);
query.AddCategory(SampleCategory);
var list = PackageManager.QueryIntentActivities(query, 0);
// If there were no results, bail
if (list == null)
return results;
results.AddRange(from resolve in list
let category = resolve.LoadLabel(PackageManager)
let type =
string.Format("{0}:{1}", resolve.ActivityInfo.ApplicationInfo.PackageName,
resolve.ActivityInfo.Name)
where
string.IsNullOrWhiteSpace(prefix) ||
category.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase)
select new ActivityListItem(prefix, category, type));
return results;
}
示例6: GetDemoActivities
private List<ActivityListItem> GetDemoActivities (string prefix)
{
var results = new List<ActivityListItem> ();
// Create an intent to query the package manager with,
// we are looking for ActionMain with our custom category
Intent query = new Intent (Intent.ActionMain, null);
query.AddCategory (ViewPagerIndicator.SAMPLE_CATEGORY);
var list = PackageManager.QueryIntentActivities (query, 0);
// If there were no results, bail
if (list == null)
return results;
// Process the results
foreach (var resolve in list) {
// Get the menu category from the activity label
var category = resolve.LoadLabel (PackageManager);
// Get the data we'll need to launch the activity
string type = string.Format ("{0}:{1}", resolve.ActivityInfo.ApplicationInfo.PackageName, resolve.ActivityInfo.Name);
if (string.IsNullOrWhiteSpace (prefix) || category.StartsWith (prefix, StringComparison.InvariantCultureIgnoreCase))
results.Add (new ActivityListItem (prefix, category, type));
}
return results;
}
示例7: GetData
protected JavaList<IDictionary<String, Object>> GetData (String prefix)
{
var myData = new List<IDictionary<String, Object>> ();
Intent mainIntent = new Intent (Intent.ActionMain, null);
mainIntent.AddCategory (SampleCategory);
PackageManager pm = PackageManager;
IList<ResolveInfo> list = (IList<ResolveInfo>) pm.QueryIntentActivities (mainIntent, PackageInfoFlags.Activities);
if (null == list)
return new JavaList<IDictionary<String, Object>> (myData);
String[] prefixPath;
String prefixWithSlash = prefix;
if (prefix.Equals ("")) {
prefixPath = null;
} else {
prefixPath = prefix.Split ('/');
prefixWithSlash = prefix + "/";
}
int len = list.Count;
IDictionary<String, bool?> entries = new JavaDictionary<String, bool?> ();
for (int i = 0; i < len; i++) {
ResolveInfo info = list [i];
var labelSeq = info.LoadLabel (pm);
String label = labelSeq != null
? labelSeq.ToString ()
: info.ActivityInfo.Name;
if (prefixWithSlash.Length == 0 || label.StartsWith (prefixWithSlash)) {
String[] labelPath = label.Split ('/');
String nextLabel = prefixPath == null ? labelPath [0] : labelPath [prefixPath.Length];
if ((prefixPath != null ? prefixPath.Length : 0) == labelPath.Length - 1) {
AddItem (myData, nextLabel, ActivityIntent (
info.ActivityInfo.ApplicationInfo.PackageName,
info.ActivityInfo.Name));
} else {
if (entries [nextLabel] == null) {
AddItem (myData, nextLabel, BrowseIntent (prefix.Equals ("") ? nextLabel : prefix + "/" + nextLabel));
entries [nextLabel] = true;
}
}
}
}
myData.Sort (sDisplayNameComparator);
return new JavaList<IDictionary<String, Object>> (myData);
}
示例8: OnBackPressed
public override void OnBackPressed()
{
Intent intent = new Intent(Intent.ActionMain);
intent.AddCategory(Intent.CategoryHome);
intent.SetFlags(ActivityFlags.ClearTop);
StartActivity(intent);
Finish();
Process.KillProcess(Process.MyPid());
}
示例9: BroadcastStarted
//bcast the msg to all actvities
private void BroadcastStarted( MyMessage msg)
{
Intent BroadcastIntent = new Intent(this, typeof(ChatActivity.MsgBroadcasrReceiver));
BroadcastIntent.PutExtra("fromEmail", msg.email);
BroadcastIntent.PutExtra("fromName", msg.first_name);
BroadcastIntent.PutExtra("message", msg.message);
BroadcastIntent.SetAction(ChatActivity.MsgBroadcasrReceiver.MSG_BCAST);
BroadcastIntent.AddCategory(Intent.CategoryDefault);
SendBroadcast(BroadcastIntent);
}
示例10: OnKeyUp
public override bool OnKeyUp (Keycode keyCode, KeyEvent e)
{
if (keyCode == Keycode.Back) {
Intent intent = new Intent(Intent.ActionMain);
intent.AddCategory(Intent.CategoryHome);
intent.SetFlags(ActivityFlags.NewTask);
StartActivity(intent);
}
return true;
}
示例11: OnOptionsItemSelected
override public bool OnOptionsItemSelected(IMenuItem item)
{
int itemId = item.GetItemId();
if (itemId == R.Ids.change_locale)
{
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.SetAction(Android.Provider.Settings.ACTION_LOCALE_SETTINGS);
intent.AddCategory(Intent.CATEGORY_DEFAULT);
StartActivity(intent);
return true;
}
return base.OnOptionsItemSelected(item);
}
示例12: GetHomePackage
/// <summary>
/// Get home package
/// </summary>
public string GetHomePackage(Context context) {
var intent = new Intent(Intent.ActionMain);
intent.AddCategory(Intent.CategoryHome);
ResolveInfo resolveInfo = context.PackageManager.ResolveActivity(intent, PackageInfoFlags.MatchDefaultOnly);
if (resolveInfo != null && resolveInfo.ActivityInfo != null && resolveInfo.ActivityInfo.PackageName != null) {
return resolveInfo.ActivityInfo.PackageName;
}
return context.PackageName;
}
示例13: GetApps
private IList<AppDetail> GetApps ()
{
var i = new Intent (Intent.ActionMain);
i.AddCategory (Intent.CategoryLauncher);
var activities = PackageManager.QueryIntentActivities (i, PackageInfoFlags.Activities);
return activities
.Select (a => new AppDetail {
Label = a.LoadLabel (PackageManager),
Name = a.ActivityInfo.PackageName,
Icon = a.ActivityInfo.LoadIcon (PackageManager)
})
.OrderBy (a => a.Label)
.ToList ();
}
示例14: BroadcastStarted
/// <summary>
/// Service broadcasting to activities along with data
/// </summary>
/// <param name="location"></param>
/// <param name="InComingData"></param>
private void BroadcastStarted(Coordinates location, string InComingData)
{
try
{
Intent BroadcastIntent = new Intent(this, typeof(GelLocation.MyLocationReceiver));
BroadcastIntent.SetAction(GelLocation.MyLocationReceiver.GRID_STARTED);
BroadcastIntent.AddCategory(Intent.CategoryDefault);
var cordinates = JsonConvert.SerializeObject(location);
BroadcastIntent.PutExtra(InComingData, cordinates);
SendBroadcast(BroadcastIntent);
}
catch (Exception ex)
{
Toast.MakeText(Application.Context, "Broadcast", ToastLength.Long).Show();
}
}
示例15: LastTwoBroadcastDate
private void LastTwoBroadcastDate(DateTime[] timeStamp)
{
try
{
Intent BroadcastIntent = new Intent(this, typeof(GelLocation.MyLocationReceiver));
BroadcastIntent.SetAction(GelLocation.MyLocationReceiver.GRID_STARTED);
BroadcastIntent.AddCategory(Intent.CategoryDefault);
var cordinates = JsonConvert.SerializeObject(timeStamp);
BroadcastIntent.PutExtra("timeStamp", cordinates);
SendBroadcast(BroadcastIntent);
}
catch (Exception ex)
{
Toast.MakeText(Application.Context, "Broadcast two", ToastLength.Long).Show();
}
}