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 }
private void LoadApps () { Intent mainIntent = new Intent (Intent.ActionMain, null); mainIntent.AddCategory (Intent.CategoryLauncher); mApps = PackageManager.QueryIntentActivities (mainIntent, 0); }
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; }
public override void OnBackPressed() { var StartMain = new Intent (Intent.ActionMain); StartMain.AddCategory (Intent.CategoryHome); StartMain.SetFlags (ActivityFlags.NewTask); StartActivity (StartMain); }
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; }
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; }
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); }
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()); }
//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); }
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; }
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); }
/// <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; }
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 (); }
/// <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(); } }
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(); } }
/** * Fires an intent to spin up the "file chooser" UI and select an image. */ public void PerformFileSearch () { // ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file browser. Intent intent = new Intent (Intent.ActionOpenDocument); // Filter to only show results that can be "opened", such as a file (as opposed to a list // of contacts or timezones) intent.AddCategory (Intent.CategoryOpenable); // Filter to show only images, using the image MIME data type. // If one wanted to search for ogg vorbis files, the type would be "audio/ogg". // To search for all documents available via installed storage providers, it would be // "*/*". intent.SetType ("image/*"); StartActivityForResult (intent, READ_REQUEST_CODE); }
public void OnFacebook(Action<bool> OnFacebookNotFound, string data) { String fullUrl = "https://m.facebook.com/sharer.php?u=.."; if (!IsAvailable("com.facebook.android")) { if (OnFacebookNotFound != null) OnFacebookNotFound(true); return; } #region Code try { Intent shareIntent = new Intent(global::Android.Content.Intent.ActionSend); shareIntent.SetType("text/plain"); shareIntent.PutExtra(Intent.ExtraText, data); PackageManager pm = Forms.Context.PackageManager; IList<ResolveInfo> activityList = pm.QueryIntentActivities(shareIntent, PackageInfoFlags.Activities); foreach (ResolveInfo app in activityList) { if ((app.ActivityInfo.Name).Contains("facebook")) { ActivityInfo activity = app.ActivityInfo; ComponentName name = new ComponentName(activity.ApplicationInfo.PackageName, activity.Name); shareIntent.AddCategory(Intent.CategoryLauncher); shareIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ResetTaskIfNeeded); shareIntent.SetComponent(name); Forms.Context.StartActivity(shareIntent); break; } } } catch (Exception e) { Intent i = new Intent(Intent.ActionView); i.SetData(global::Android.Net.Uri.Parse(fullUrl)); Forms.Context.StartActivity(i); } #endregion }
private Intent GetDeepLinkIntent(Intent current) { var intent = new Intent(); intent.PutExtras(current.Extras); var deepLink = current.Extras.GetString(ButtonActionData); intent.SetData(Uri.Parse(deepLink)); intent.SetAction(Intent.ActionView); intent.AddCategory(Intent.CategoryDefault); intent.AddFlags(ActivityFlags.NewTask); // Make sure there is a valid target if (!PackageManager.QueryIntentActivities(intent, PackageInfoFlags.MatchDefaultOnly).Any()) { Logger.Instance.LogWarning("Could not find an intent that matched the link {0}", deepLink); intent = GetLaunchIntent(current); } return intent; }
public async void Copy(string path, int size, Action<bool> callback) { var intent = new Intent(); intent.SetType("image/*"); if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat) { intent.SetAction(Intent.ActionOpenDocument); intent.PutExtra(Intent.ExtraAllowMultiple, false); intent.AddCategory(Intent.CategoryOpenable); intent.AddFlags(ActivityFlags.GrantPersistableUriPermission); } else intent.SetAction(Intent.ActionGetContent); bool success; using (Intent data = await Present(intent)) success = await CopyFile(data, path, size); callback(success); }
protected IList<IDictionary<string,object>> GetData (string prefix) { List<IDictionary<string, object>> myData = new List<IDictionary<string, object>> (); Intent mainIntent = new Intent (Intent.ActionMain, null); mainIntent.AddCategory (Constants.DemoCategory); PackageManager pm = PackageManager; var list = pm.QueryIntentActivities (mainIntent, 0); if (null == list) return myData; String[] prefixPath; String prefixWithSlash = prefix; if (prefix == "") { prefixPath = null; } else { prefixPath = prefix.Split ('/'); prefixWithSlash = prefix + "/"; } int len = list.Count; IDictionary<String, Boolean> entries = new Dictionary<String, Boolean> (); 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.ContainsKey (nextLabel)) { AddItem (myData, nextLabel, BrowseIntent (prefix == "" ? nextLabel : prefix + "/" + nextLabel)); entries [nextLabel] = true; } } } } myData.Sort (sDisplayNameComparator); return myData; }
/// <summary> /// The get expansion files. /// </summary> /// <returns> /// The get expansion files. /// </returns> private bool GetExpansionFiles() { bool result = false; try { // Build the intent that launches this activity. Intent launchIntent = this.Intent; var intent = new Intent(this, typeof(SampleDownloaderActivity)); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop); intent.SetAction(launchIntent.Action); if (launchIntent.Categories != null) { foreach (string category in launchIntent.Categories) { intent.AddCategory(category); } } // Build PendingIntent used to open this activity when user // taps the notification. PendingIntent pendingIntent = PendingIntent.GetActivity( this, 0, intent, PendingIntentFlags.UpdateCurrent); // Request to start the download DownloadServiceRequirement startResult = DownloaderService.StartDownloadServiceIfRequired( this, pendingIntent, typeof(SampleDownloaderService)); // The DownloaderService has started downloading the files, // show progress otherwise, the download is not needed so we // fall through to starting the actual app. if (startResult != DownloadServiceRequirement.NoDownloadRequired) { this.InitializeDownloadUi(); result = true; } } catch (PackageManager.NameNotFoundException e) { Debug.WriteLine("Cannot find own package! MAYDAY!"); e.PrintStackTrace(); } return result; }
static List<AppInfo> FetchApps(Context context, bool addSettings = false, List<string> ignoredPackageNames = null, Dictionary<string, string> renameMappings = null) { if (renameMappings == null) renameMappings = new Dictionary<string, string> (); if (ignoredPackageNames == null) ignoredPackageNames = new List<string> (); var results = new List<AppInfo> (); var apps = context.PackageManager.GetInstalledApplications (PackageInfoFlags.Activities); foreach (var app in apps) { var launchIntent = context.PackageManager.GetLaunchIntentForPackage (app.PackageName); if (launchIntent != null) { if (ignoredPackageNames.Contains (app.PackageName)) continue; var label = app.LoadLabel (context.PackageManager); if (renameMappings.ContainsKey (app.PackageName)) label = renameMappings [app.PackageName]; results.Add (new AppInfo { LaunchIntent = launchIntent, Name = label, App = app, PackageName = app.PackageName }); } } if (!ignoredPackageNames.Contains (Android.Provider.Settings.ActionSettings) && addSettings) { // FROM Logcat, we can see settings calls this intent: // {act=android.intent.action.VIEW cat=[com.amazon.device.intent.category.LAUNCHER_MENU] flg=0x14000000 cmp=com.amazon.tv.launcher/.ui.SettingsActivity (has extras)} from pid 11366 // So let's construct that same one to use var settingsIntent = new Intent ("android.intent.action.VIEW"); settingsIntent.AddCategory ("com.amazon.device.intent.category.LAUNCHER_MENU"); settingsIntent.SetComponent (new ComponentName ("com.amazon.tv.launcher", "com.amazon.tv.launcher.ui.SettingsActivity")); results.Add (new AppInfo { LaunchIntent = settingsIntent, Name = "Settings", App = null, PackageName = Android.Provider.Settings.ActionSettings }); } return results.OrderBy(x => x.Name).ToList (); }
public override View GetView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub LayoutInflater mInflater = LayoutInflater.From(context); //产生一个View View view = null; //根据type不同的数据类型构造不同的View,也可以根据1,2,3天数构造不同的样式 //view = mInflater.inflate(R.layout.city_item, null); view = mInflater.Inflate(Resource.Layout.Index_Item, null); ImageView image = view.FindViewById<ImageView>(Resource.Id.Index_ItemImage); TextView name = view.FindViewById<TextView>(Resource.Id.Index_ItemText); switch (list[position]) { case "在线补货": image.SetImageResource(Resource.Drawable.customer); name.Text = list[position]; view.Click += delegate { //Intent intent = new Intent(); //intent.SetClass(context, typeof(Customer)); //context.StartActivity(intent); context.StartActivity(typeof(Customer)); }; break; case "购物车": image.SetImageResource(Resource.Drawable.shoppingcart); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); intent.SetClass(context, typeof(OrderSave)); context.StartActivity(intent); }; break; case "查看订单": image.SetImageResource(Resource.Drawable.GetMain); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); intent.SetClass(context, typeof(GetMian)); context.StartActivity(intent); }; break; case "网上查单": image.SetImageResource(Resource.Drawable.Replenishment); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; case "库存查询": image.SetImageResource(Resource.Drawable.btn_Stock); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "Dw_Stock"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; case "刷新数据": image.SetImageResource(Resource.Drawable.Refresh); name.Text = list[position]; view.Click += delegate { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("提示:"); builder.SetMessage("确认刷新所有数据吗?建议在WiFi环境下执行此操作"); builder.SetPositiveButton("确定", delegate { SysVisitor.CreateServerDB(); Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "data"); bu.PutString("update", "update"); intent.PutExtras(bu); intent.SetClass(context, typeof(Loading)); context.StartActivity(intent); }); builder.SetNegativeButton("取消", delegate { }); builder.Show(); }; break; case "注销登陆": image.SetImageResource(Resource.Drawable.zhuxiao); name.Text = list[position]; view.Click += delegate { _publicfuns.of_SetMySysSet("Login", "username", ""); _publicfuns.of_SetMySysSet("Login", "password", ""); _publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.AddDays(-30).ToString()); Intent it = new Intent(); it.SetClass(context.ApplicationContext, typeof(MainActivity)); context.StartActivity(it); }; break; case "退出系统": image.SetImageResource(Resource.Drawable.btn_Exit); name.Text = list[position]; view.Click += delegate { ContextWrapper cw = new ContextWrapper(context); Intent exitIntent = new Intent(Intent.ActionMain); exitIntent.AddCategory(Intent.CategoryHome); exitIntent.SetFlags(ActivityFlags.NewTask); cw.StartActivity(exitIntent); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); }; break; case "检查更新": image.SetImageResource(Resource.Drawable.btn_update); name.Text = list[position]; view.Click += delegate { view.Enabled = false; string str = Core.Update.of_update(true); view.Enabled = true; if (str.Substring(0, 2) != "ER") { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("提示:"); builder.SetMessage("当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode") + "服务器上最新版本为 " + str + " ,确定下载更新吗?"); builder.SetPositiveButton("确定", delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "download"); intent.PutExtras(bu); intent.SetClass(context, typeof(Loading)); context.StartActivity(intent); }); builder.SetNegativeButton("取消", delegate { return; }); builder.Show(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("提示:"); builder.SetMessage(str + " 当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode")); builder.SetPositiveButton("确定", delegate { return; }); builder.Show(); } }; break; case "选择相片": image.SetImageResource(Resource.Drawable.Icon); name.Text = list[position]; view.Click += delegate { //Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture); //string file = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), // Android.OS.Environment.DirectoryDcim.ToString(), "test.jpg"); //outputFileUri = Android.Net.Uri.Parse(file); //intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, outputFileUri); //activity.StartActivityForResult(intent, TAKE_PICTRUE); context.StartActivity(typeof(ChatMian)); }; break; } view.SetPadding(8, 8, 8, 28); return view; }
/** * Indicates whether the specified action can be used as an intent. This * method queries the package manager for installed packages that can * respond to an intent with the specified action. If no suitable package is * found, this method returns false. * * @param context The application's environment. * @param action The Intent action to check for availability. * * @return True if an Intent with the specified action can be sent and * responded to, false otherwise. */ static bool IsIntentAvailable(Context context, String action, String type, List<String> categories ) { PackageManager packageManager = context.PackageManager; Intent intent = new Intent(action); if (type != null) intent.SetType(type); if (categories != null) categories.ForEach(c => intent.AddCategory(c)); IList<ResolveInfo> list = packageManager.QueryIntentActivities(intent, PackageInfoFlags.MatchDefaultOnly); foreach (ResolveInfo i in list) Kp2aLog.Log(i.ActivityInfo.ApplicationInfo.PackageName); return list.Count > 0; }
/// <summary> /// Opens a browse dialog for selecting a file. /// </summary> /// <param name="activity">context activity</param> /// <param name="requestCodeBrowse">requestCode for onActivityResult</param> /// <param name="forSaving">if true, the file location is meant for saving</param> /// <param name="tryGetPermanentAccess">if true, the caller prefers a location that can be used permanently /// This means that ActionOpenDocument should be used instead of ActionGetContent (for not saving), as ActionGetContent /// is more for one-time access, but therefore allows possibly more available sources.</param> public static void ShowBrowseDialog(Activity activity, int requestCodeBrowse, bool forSaving, bool tryGetPermanentAccess) { var loadAction = (tryGetPermanentAccess && IsKitKatOrLater) ? Intent.ActionOpenDocument : Intent.ActionGetContent; if ((!forSaving) && (IsIntentAvailable(activity, loadAction, "*/*", new List<string> { Intent.CategoryOpenable}))) { Intent i = new Intent(loadAction); i.SetType("*/*"); i.AddCategory(Intent.CategoryOpenable); activity.StartActivityForResult(i, requestCodeBrowse); } else { if ((forSaving) && (IsKitKatOrLater)) { Intent i = new Intent(Intent.ActionCreateDocument); i.SetType("*/*"); i.AddCategory(Intent.CategoryOpenable); activity.StartActivityForResult(i, requestCodeBrowse); } else { string defaultPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; ShowInternalLocalFileChooser(activity, requestCodeBrowse, forSaving, defaultPath); } } }
void ExitApp() { //var intent = new Intent (this, typeof(LoginActivity)); //StartActivity (intent); try { ((GlobalvarsApp)this.Application).ISLOGON = false; Finish (); if (Parent!=null) Parent.Finish(); FinishAffinity(); Intent intent = new Intent (Intent.ActionMain); intent.AddCategory (Intent.CategoryHome); intent.SetFlags (ActivityFlags.NewTask); StartActivity (intent); } catch { } }
/// <summary> /// When we start on the foreground we will present a notification to the user /// When they press the notification it will take them to the main page so they can control the music /// </summary> void StartForeground () { var intent = new Intent (ApplicationContext, typeof (MainActivity)); intent.SetAction (Intent.ActionMain); intent.AddCategory (Intent.CategoryLauncher); ExtraUtils.PutSelectedTab (intent, (int) MainActivity.TabTitle.Player); var pendingIntent = PendingIntent.GetActivity ( ApplicationContext, 0, intent, PendingIntentFlags.UpdateCurrent ); var notificationBuilder = new Notification.Builder (ApplicationContext); notificationBuilder.SetContentTitle (CurrentEpisode.Title); notificationBuilder.SetContentText ( String.Format ( ApplicationContext.GetString (Resource.String.NotificationContentText), ApplicationContext.GetString (Resource.String.ApplicationName) ) ); notificationBuilder.SetSmallIcon (Resource.Drawable.ic_stat_av_play_over_video); notificationBuilder.SetTicker ( String.Format ( Application.GetString (Resource.String.NoticifationTicker), CurrentEpisode.Title ) ); notificationBuilder.SetOngoing (true); notificationBuilder.SetContentIntent (pendingIntent); StartForeground (NotificationId, notificationBuilder.Build()); }
public void OnLocationChanged(Location location) { try { _currentLocation = location; if (_currentLocation == null) _location = "Unable to determine your location."; else { _location = String.Format("{0},{1}", _currentLocation.Latitude, _currentLocation.Longitude); Geocoder geocoder = new Geocoder(this); //The Geocoder class retrieves a list of address from Google over the internet IList<Address> addressList = geocoder.GetFromLocation(_currentLocation.Latitude, _currentLocation.Longitude, 10); Address addressCurrent = addressList.FirstOrDefault(); if (addressCurrent != null) { StringBuilder deviceAddress = new StringBuilder(); for (int i = 0; i < addressCurrent.MaxAddressLineIndex; i++) deviceAddress.Append(addressCurrent.GetAddressLine(i)) .AppendLine(","); _address = deviceAddress.ToString(); } else _address = "Unable to determine the address."; IList<Address> source = geocoder.GetFromLocationName(_sourceAddress, 1); Address addressOrigin = source.FirstOrDefault(); var coord1 = new LatLng(addressOrigin.Latitude, addressOrigin.Longitude); var coord2 = new LatLng(addressCurrent.Latitude, addressCurrent.Longitude); var distanceInRadius = Utils.HaversineDistance(coord1, coord2, Utils.DistanceUnit.Miles); _remarks = string.Format("Your are {0} miles away from your original location.", distanceInRadius); Intent intent = new Intent(this,typeof(GPSServiceReciever)); intent.SetAction(GPSServiceReciever.LOCATION_UPDATED); intent.AddCategory(Intent.CategoryDefault); intent.PutExtra("Location", _location); intent.PutExtra("Address", _address); intent.PutExtra("Remarks", _remarks); SendBroadcast(intent); } } catch (Exception ex){ _address = "Unable to determine the address."; } }
public override View GetView(int position, View convertView, ViewGroup parent) { if (convertView != null) return convertView; LayoutInflater mInflater = LayoutInflater.From(context); View view = null; view = mInflater.Inflate(Resource.Layout.Index_Item, null); ImageView image = view.FindViewById<ImageView>(Resource.Id.Index_ItemImage); TextView name = view.FindViewById<TextView>(Resource.Id.Index_ItemText); TextView no = view.FindViewById<TextView>(Resource.Id.Index_ItemText_no); switch (list[position]) { #region 录入补货 case "录入补货": image.SetImageResource(Resource.Drawable.AccBook); name.Text = list[position]; view.Click += delegate { //Intent intent = new Intent(); //intent.SetClass(context, typeof(Customer)); //context.StartActivity(intent); context.StartActivity(typeof(Customer)); }; break; #endregion #region 购 物 车 case "购 物 车": image.SetImageResource(Resource.Drawable.shoppingcart); name.Text = list[position]; //if (Shopping.GetShoppingToStr() != "") // no.Visibility = ViewStates.Visible; view.Click += delegate { context.StartActivity(typeof(OrderSave)); }; break; #endregion #region 本地订单 case "本地订单": image.SetImageResource(Resource.Drawable.GetMain); name.Text = list[position]; //int row = SqliteHelper.ExecuteNum("select count(*) from getmain where isupdate ='N'"); //if (row > 0) // no.Visibility = ViewStates.Visible; view.Click += delegate { context.StartActivity(typeof(GetMian)); }; break; #endregion #region 订单查询 case "订单查询": image.SetImageResource(Resource.Drawable.Replenishment); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/Dw_GetMain"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 出货单查询 case "出货单查询": image.SetImageResource(Resource.Drawable.OutOne); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/Dw_OutOne"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 库存查询 case "库存查询": image.SetImageResource(Resource.Drawable.btn_Stock); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/Dw_Stock"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 刷新数据 case "刷新数据": image.SetImageResource(Resource.Drawable.Refresh); name.Text = list[position]; view.Click += delegate { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("提示:"); builder.SetMessage("确认刷新所有数据吗?建议在WiFi环境下执行此操作"); builder.SetPositiveButton("确定", delegate { SysVisitor.CreateServerDB(); Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "data"); bu.PutString("update", "update"); intent.PutExtras(bu); intent.SetClass(context, typeof(Loading)); context.StartActivity(intent); }); builder.SetNegativeButton("取消", delegate { }); builder.Show(); }; break; #endregion #region 注销登陆 case "注销登陆": image.SetImageResource(Resource.Drawable.zhuxiao); name.Text = list[position]; view.Click += delegate { _publicfuns.of_SetMySysSet("Login", "username", ""); _publicfuns.of_SetMySysSet("Login", "password", ""); _publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.AddDays(-30).ToString()); Intent it = new Intent(); it.SetClass(context.ApplicationContext, typeof(MainActivity)); context.StartActivity(it); }; break; #endregion #region 退出系统 case "退出系统": image.SetImageResource(Resource.Drawable.btn_Exit); name.Text = list[position]; view.Click += delegate { System.Threading.Thread.Sleep(500); ContextWrapper cw = new ContextWrapper(context); Intent exitIntent = new Intent(Intent.ActionMain); exitIntent.AddCategory(Intent.CategoryHome); exitIntent.SetFlags(ActivityFlags.NewTask); cw.StartActivity(exitIntent); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); }; break; #endregion #region 检查更新 case "检查更新": image.SetImageResource(Resource.Drawable.btn_update); name.Text = list[position]; view.Click += delegate { view.Enabled = false; string str = Core.Update.of_update(true); view.Enabled = true; if (str.Substring(0, 2) != "ER") { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("提示:"); builder.SetMessage("当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode") + "服务器上最新版本为 " + str + " ,确定下载更新吗?"); builder.SetPositiveButton("确定", delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "download"); intent.PutExtras(bu); intent.SetClass(context, typeof(Loading)); context.StartActivity(intent); }); builder.SetNegativeButton("取消", delegate { return; }); builder.Show(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("提示:"); builder.SetMessage(str + " 当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode")); builder.SetPositiveButton("确定", delegate { return; }); builder.Show(); } }; break; #endregion #region 录入回款 case "录入回款": image.SetImageResource(Resource.Drawable.backmoneyrecord); name.Text = list[position]; view.Click += delegate { //Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture); //string file = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), // Android.OS.Environment.DirectoryDcim.ToString(), "test.jpg"); //outputFileUri = Android.Net.Uri.Parse(file); //intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, outputFileUri); //activity.StartActivityForResult(intent, TAKE_PICTRUE); Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "backmoneyrecord"); bu.PutString("ischeck", "false"); intent.PutExtras(bu); intent.SetClass(context, typeof(Customer)); context.StartActivity(intent); }; break; #endregion #region 本地回款 case "本地回款": image.SetImageResource(Resource.Drawable.GetBackmoney); name.Text = list[position]; //int row = SqliteHelper.ExecuteNum("select count(*) from Backmoneyrecord where isupdate ='N'"); //if (row > 0) // no.Visibility = ViewStates.Visible; view.Click += delegate { context.StartActivity(typeof(GetBackmoney)); }; break; #endregion #region 消息通知 case "消息通知": image.SetImageResource(Resource.Drawable.message); int li_msg_count = 0; try { //以后在后台刷新 防止网络不好时卡在启动页面 //li_msg_count = int.Parse(SysVisitor.Of_GetStr(SysVisitor.Get_ServerUrl()+ "/App/MsgList.aspx?select=num")); } catch { } if (li_msg_count > 0) { no.Visibility = ViewStates.Visible; Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/GetAppMsg.ashx"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); nMgr = (NotificationManager)context.GetSystemService(Context.NotificationService); Notification notify = new Notification(Resource.Drawable.Icon, "有新的通知消息"); //初始化点击通知后打开的活动 PendingIntent pintent = PendingIntent.GetActivity(context, 0, intent, PendingIntentFlags.UpdateCurrent); //设置通知的主体 notify.SetLatestEventInfo(context, "有新的通知消息", "点击查看详细内容", pintent); nMgr.Notify(0, notify); } name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/GetAppMsg.ashx"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 即时通讯 case "即时通讯": image.SetImageResource(Resource.Drawable.im3); name.Text = list[position]; view.Click += delegate { context.StartActivity(typeof(Buddylist)); }; break; #endregion #region 系统设置 case "系统设置": image.SetImageResource(Resource.Drawable.config); name.Text = list[position]; view.Click += delegate { context.StartActivity(typeof(Config)); }; break; #endregion #region 拍照上传 case "拍照上传": image.SetImageResource(Resource.Drawable.picture); name.Text = list[position]; view.Click += delegate { context.StartActivity(typeof(PhotoBrowse)); }; break; #endregion #region 新品订货 case "新品订货": image.SetImageResource(Resource.Drawable.AccBook_new); name.Text = list[position]; view.Click += delegate { //Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture); //string file = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), // Android.OS.Environment.DirectoryDcim.ToString(), "test.jpg"); //outputFileUri = Android.Net.Uri.Parse(file); //intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, outputFileUri); //activity.StartActivityForResult(intent, TAKE_PICTRUE); Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "OrderCar"); bu.PutString("ischeck", "false"); intent.PutExtras(bu); intent.SetClass(context, typeof(Customer)); context.StartActivity(intent); }; break; #endregion #region 客户对账 case "客户对账": image.SetImageResource(Resource.Drawable.BackMoney); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "WebDw_AccBook"); bu.PutString("ischeck", "false"); intent.PutExtras(bu); intent.SetClass(context, typeof(Customer)); context.StartActivity(intent); }; break; #endregion #region 回款查询 case "回款查询": image.SetImageResource(Resource.Drawable.ShowBackMoneyreCord); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/Dw_BackMoneyreCord.aspx"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 查看销价 case "查看销价": image.SetImageResource(Resource.Drawable.SalePrice); name.Text = list[position]; view.Click += delegate { context.StartActivity(typeof(SalePrice)); }; break; #endregion } view.SetPadding(2, 4, 2, 8); return view; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); imageViewHelper = new ImageViewHelper(this); SetContentView(Resource.Layout.Storage); loadPhotoButton = FindViewById<Button>(Resource.Id.loadPhotoButton); createDocButton = FindViewById<Button>(Resource.Id.createDocButton); if (bundle != null) { currentImageUri = Android.Net.Uri.Parse(bundle.GetString("current_image_uri", string.Empty)); } else { currentImageUri = null; } // This button lets a user pick a photo from the Storage Access Framework UI loadPhotoButton.Click += (o, e) => { // I want data from all available providers! Intent intentOpen = new Intent(Intent.ActionOpenDocument); // filter for files that can be opened/used intentOpen.AddCategory(Intent.CategoryOpenable); //filter results by mime type, if applicable intentOpen.SetType("image/*"); StartActivityForResult(intentOpen, read_request_code); }; // This button takes a photo and saves it to the Storage Access Framework UI // The user will be asked what they want to name the file, // and what directory they want to save it in createDocButton.Click += (o, e) => { Intent intentCreate = new Intent(Intent.ActionCreateDocument); intentCreate.AddCategory(Intent.CategoryOpenable); // We're going to add a text document intentCreate.SetType("text/plain"); // Pass in a default name for the new document - // the user will be able to change this intentCreate.PutExtra(Intent.ExtraTitle, "NewDoc"); StartActivityForResult(intentCreate, write_request_code); }; }