public override bool OnShowFileChooser(WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams) { if (_activity.mUploadMessage != null) { _activity.mUploadMessage.OnReceiveValue(null); } _activity.mUploadMessage = filePathCallback; try { File file = createImageFile(); imageUri = Uri.FromFile(file); _activity.mCameraPhotoPath = imageUri; Intent captureIntent = new Intent(MediaStore.ActionImageCapture); captureIntent.PutExtra(MediaStore.ExtraOutput, imageUri); Intent i = new Intent(Intent.ActionGetContent); i.AddCategory(Intent.CategoryOpenable); i.SetType("image/*"); Intent chooserIntent = Intent.CreateChooser(i, "이미지 선택기"); chooserIntent.PutExtra(Intent.ExtraInitialIntents, new IParcelable[] { captureIntent }); _activity.StartActivityForResult(chooserIntent, MainActivity.FILECHOOSER_RESULTCODE); } catch (System.Exception e) { System.Console.WriteLine(e.Message); } return(true); }
public void Launch() { // Launches phone app with contacts tab selected Intent intent = new Intent(); intent.SetComponent(new ComponentName("com.android.contacts", "com.android.contacts.DialtactsContactsEntryActivity")); intent.SetAction("android.intent.action.MAIN"); intent.AddCategory("android.intent.category.LAUNCHER"); intent.AddCategory("android.intent.category.DEFAULT"); this.CurrentActivity.StartActivity(intent); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //version control Context context = this.ApplicationContext; Values.Version = context.PackageManager.GetPackageInfo(context.PackageName, 0).VersionName; ApplicationInfo ai = PackageManager.GetApplicationInfo(context.PackageName, 0); ZipFile zf = new ZipFile(ai.SourceDir); ZipEntry ze = zf.GetEntry("classes.dex"); long time = ze.Time; System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); dtDateTime = dtDateTime.AddSeconds(Math.Round(time / 1000D)).ToLocalTime(); zf.Close(); Values.Version = string.Format("{0}.{1}", Values.Version, dtDateTime.ToString("yyyyMMdd.Hmmss")); var intent = new Intent(this, typeof(LogonScreenClass)); intent.SetAction(Intent.ActionMain); intent.AddCategory(Intent.CategoryLauncher); intent.PutExtra("ConnectionType", "Socks"); intent.PutExtra("Version", Values.Version); intent.PutExtra("PackageName", "Radio Deliveries"); StartActivityForResult(intent, 0); Values.WorkMode = WorkModes.READING; }
private void GoHome() { Intent intent = new Intent(Intent.ActionMain); intent.AddCategory(Intent.CategoryHome); MainActivity.CurrentContext.StartActivity(intent); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); context = Application.Context; var intent = new Intent(Intent.ActionGetContent); intent.SetType("*/*"); string[] allowedTypes = Intent.GetStringArrayExtra("allowedTypes")?. Where(o => !string.IsNullOrEmpty(o) && o.Contains("/")).ToArray(); if (allowedTypes != null && allowedTypes.Any()) { intent.PutExtra(Intent.ExtraMimeTypes, allowedTypes); } intent.AddCategory(Intent.CategoryOpenable); try { StartActivityForResult(Intent.CreateChooser(intent, "Select file"), 0); } catch (Exception exAct) { System.Diagnostics.Debug.Write(exAct); } }
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(ApiDemo.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); }
/** * Initiates a scan only for a certain set of barcode types, given as strings corresponding * to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants * like {@link #PRODUCT_CODE_TYPES} for example. * * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise */ public AlertDialog InitiateScan(List <String> desiredBarcodeFormats) { Intent intentScan = new Intent(BS_PACKAGE + ".SCAN"); intentScan.AddCategory(Intent.CategoryDefault); // check which types of codes to scan for if (desiredBarcodeFormats != null) { // set the desired barcode types StringBuilder joinedByComma = new StringBuilder(); foreach (String format in desiredBarcodeFormats) { if (joinedByComma.Length > 0) { joinedByComma.Append(','); } joinedByComma.Append(format); } intentScan.PutExtra("SCAN_FORMATS", joinedByComma.ToString()); } String targetAppPackage = FindTargetAppPackage(intentScan); if (targetAppPackage == null) { return(ShowDownloadDialog()); } intentScan.SetPackage(targetAppPackage); intentScan.AddFlags(ActivityFlags.ClearTop); intentScan.AddFlags(ActivityFlags.ClearWhenTaskReset); AttachMoreExtras(intentScan); StartActivityForResult(intentScan, REQUEST_CODE); return(null); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var openDemoDocumentButton = FindViewById <Button> (Resource.Id.main_btn_open_example); var openDocumentButton = FindViewById <Button> (Resource.Id.main_btn_open_document); // Opens a demo document from assets directory openDemoDocumentButton.Click += (sender, e) => { // On Marshmallow devices the user must grant write permission to the extrnal storage. const string permission = Manifest.Permission.WriteExternalStorage; if (ContextCompat.CheckSelfPermission(this, permission) == (int)Permission.Granted) { ShowDocumentFromAssets(); return; } ActivityCompat.RequestPermissions(this, PermissionsExternalStorage, RequestWritePermission); }; // Opens a document from Android document provider openDocumentButton.Click += (sender, e) => { var openIntent = new Intent(Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat ? Intent.ActionOpenDocument : Intent.ActionGetContent); openIntent.AddCategory(Intent.CategoryOpenable); openIntent.SetType("application/*"); StartActivityForResult(openIntent, RequestOpenDocument); }; }
private void GoToBluetoothSettings() { try { Current.Activity.StartActivityForResult(new Intent().SetAction(Settings.ActionBluetoothSettings), BluetoothRequestCode); } catch (Exception e) { LogUtils.LogException(LogSeverity.WARNING, e, $"{nameof(PermissionUtils)}.{nameof(GoToBluetoothSettings)}: Failed to go to bluetooth settings. Trying other intent."); try { // This is needed for some Samsung devices as the previous solution // requires BLUETOOTH_ADMIN permissions and we do not want to use them. Intent intent = new Intent(Intent.ActionMain, null); intent.AddCategory(Intent.CategoryLauncher); ComponentName cn = new ComponentName( "com.android.settings", "com.android.settings.bluetooth.BluetoothSettings"); intent.SetComponent(cn); intent.SetFlags(ActivityFlags.NewTask); Current.AppContext.StartActivity(intent); } catch (Exception ex) { LogUtils.LogException(LogSeverity.WARNING, ex, $"{nameof(PermissionUtils)}.{nameof(GoToBluetoothSettings)}: Failed to go to bluetooth settings. Skipping."); } } }
/// <summary> /// 防止华为机型未加入白名单时按返回键回到桌面再锁屏后几秒钟进程被杀 /// </summary> /// <param name="a"></param> public static void OnBackPressed(Activity a) { Intent launcherIntent = new Intent(Intent.ActionMain); launcherIntent.AddCategory(Intent.CategoryHome); a.StartActivity(launcherIntent); }
//Lang private void Lang_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { try { if (e.Handled) { Android.Preferences.ListPreference etp = (Android.Preferences.ListPreference)sender; var value = e.NewValue; Wo_Main_Settings.SetApplicationLang(value.ToString()); Toast.MakeText(_activityContext, this.GetText(Resource.String.Lbl_Closed_App), ToastLength.Long).Show(); Intent intent = new Intent(_activityContext, typeof(SpalshScreen_Activity)); intent.AddCategory(Intent.CategoryHome); intent.SetAction(Intent.ActionMain); intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask); _activityContext.StartActivity(intent); _activityContext.FinishAffinity(); } } catch (Exception exception) { Console.WriteLine(exception); } }
public void OpenInbox() { Intent intent = new Intent(Intent.ActionMain); intent.AddCategory(Intent.CategoryAppEmail); Android.App.Application.Context.StartActivity(intent); }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.action_add: edtAuthor = new EditText(this); Android.Support.V7.App.AlertDialog alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Add New Author") .SetView(edtAuthor) .SetPositiveButton("Add", OkAction) .SetNegativeButton("Cancel", CancelAction) .Create(); alertDialog.Show(); return(true); case Resource.Id.action_cancel: Intent startMain = new Intent(Intent.ActionMain); startMain.AddCategory(Intent.CategoryHome); startMain.SetFlags(ActivityFlags.NewTask); StartActivity(startMain); return(true); } return(base.OnOptionsItemSelected(item)); }
private async void OpenFileButton_Click(object sender, EventArgs e) { var PermissionStatus = await CheckAndRequestStoragePermission(); if (PermissionStatus != PermissionStatus.Granted) { ShowDialog("Permission Error", "Storage permission is required to decrypt files."); return; } try { if (!String.IsNullOrEmpty(TextInputEditor.Text)) { fileData = null; ShowDialog("Error", "You can decrypt either file or text at a time. First, clear the text!"); return; } OpenFileButton.Enabled = false; DecryptButton.Enabled = false; RemoveButton.Visibility = ViewStates.Invisible; SelectedFileNameLabel.Text = "No file selected"; Intent intent = new Intent(Intent.ActionOpenDocument); intent.AddCategory(Intent.CategoryOpenable); intent.SetType("*/*"); StartActivityForResult(intent, 5); } catch (Exception ex) { ShowDialog("Error", "Unable to open file. Ensure that storage permission is granted."); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); int _id = Intent.GetIntExtra("id", 0); Intent intent = new Intent(); if (_id == 1) { intent.SetAction(MediaStore.ActionImageCapture); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(file)); StartActivityForResult(intent, _id); } else if (_id == 2) { if (Build.VERSION.SdkInt < BuildVersionCodes.Kitkat) { intent = new Intent(); intent.SetType("image/*"); intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(intent, "Select Picture"), 2); } else { intent = new Intent(); intent.SetType("image/*"); intent.SetAction(Intent.ActionOpenDocument); intent.AddCategory(Intent.CategoryOpenable); StartActivityForResult(Intent.CreateChooser(intent, "Select Picture"), 2); } } else { Finish(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); _numInput = FindViewById <EditText>(Resource.Id.numInput); _btnSetBadge = FindViewById <Button>(Resource.Id.btnSetBadge); _btnSetBadge.Click += Button_Click; _removeBadgeBtn = FindViewById <Button>(Resource.Id.btnRemoveBadge); _removeBadgeBtn.Click += RemoveBadgeBtn_Click; //find the home launcher Package var intent = new Intent(Intent.ActionMain); intent.AddCategory(Intent.CategoryHome); ResolveInfo resolveInfo = PackageManager.ResolveActivity(intent, PackageInfoFlags.MatchDefaultOnly); var currentHomePackage = resolveInfo.ActivityInfo.PackageName; TextView textViewHomePackage = FindViewById <TextView>(Resource.Id.textViewHomePackage); textViewHomePackage.Text = "launcher:" + currentHomePackage; }
void pickFile() { Intent intent = null; intent = new Intent(Intent.ActionGetContent); //if (Build.VERSION.SdkInt < Build.VERSION_CODES.Kitkat) //{ // intent = new Intent(Intent.ActionGetContent); //} //else //{ // intent = new Intent(Intent.ActionOpenDocument); //} // The MIME data type filter //intent.SetType("audio/*"); intent.SetType("*/*"); intent.AddCategory(Intent.CategoryOpenable); //intent.SetAction(Intent.ActionGetContent); //intent.SetType("audio/*"); //intent.PutExtra(Intent.ExtraLocalOnly, true); StartActivityForResult(Intent.CreateChooser(intent, "Select ,Music"), REQUEST_CHOOSER); }
public AlertDialog ShareText(string text, string type) { Intent intent = new Intent(); intent.AddCategory(Intent.CategoryDefault); intent.SetAction(BS_PACKAGE + ".ENCODE"); intent.PutExtra("ENCODE_TYPE", type); intent.PutExtra("ENCODE_DATA", text); string targetAppPackage = FindTargetAppPackage(intent); if (targetAppPackage == null) { return(ShowDownloadDialog()); } intent.SetPackage(targetAppPackage); intent.AddFlags(ActivityFlags.ClearTop); intent.AddFlags(FLAG_NEW_DOC); AttachMoreExtras(intent); if (_fragment == null) { _activity.StartActivity(intent); } else { _fragment.StartActivity(intent); } return(null); }
//Lang private void LangPref_OnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { if (eventArgs.Handled) { var etp = (ListPreference)sender; var value = eventArgs.NewValue; Settings.Lang = value.ToString(); WowTime_Main_Settings.SetApplicationLang(Activity, Settings.Lang); Toast.MakeText(ActivityContext, GetText(Resource.String.Lbl_Application_Restart), ToastLength.Long).Show(); var intent = new Intent(Activity, typeof(SpalshScreen_Activity)); intent.AddCategory(Intent.CategoryHome); intent.SetAction(Intent.ActionMain); intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask); Activity.StartActivity(intent); Activity.FinishAffinity(); Settings.Lang = value.ToString(); } } catch (Exception e) { Crashes.TrackError(e); } }
public void CloseApp() { Intent startMain = new Intent(Intent.ActionMain); startMain.AddCategory(Intent.CategoryHome); CrossCurrentActivity.Current.Activity.StartActivity(startMain); }
/// <summary> /// Sends an intent to start the FilePicker /// </summary> private void StartPicker() { var intent = new Intent( Build.VERSION.SdkInt < BuildVersionCodes.Kitkat ? Intent.ActionGetContent : Intent.ActionOpenDocument); intent.SetType("*/*"); string[] allowedTypes = Intent.GetStringArrayExtra(ExtraAllowedTypes)?. Where(o => !string.IsNullOrEmpty(o) && o.Contains("/")).ToArray(); if (allowedTypes != null && allowedTypes.Any()) { intent.PutExtra(Intent.ExtraMimeTypes, allowedTypes); } if (Build.VERSION.SdkInt < BuildVersionCodes.Kitkat) { intent.AddCategory(Intent.CategoryOpenable); } else { intent.AddFlags(ActivityFlags.GrantPersistableUriPermission); } try { this.StartActivityForResult(Intent.CreateChooser(intent, "Select file"), 0); } catch (Exception ex) { System.Diagnostics.Debug.Write(ex); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.AppSelect); // アプリ一覧を取得 参考: // http://furuya02.hatenablog.com/entry/20140528/1401224919 var mainIntent = new Intent(Intent.ActionMain, null); mainIntent.AddCategory(Intent.CategoryLauncher); var ar = PackageManager.QueryIntentActivities(mainIntent, 0); foreach (var a in ar) { tableItems.Add(new AppInfo() { Icon = a.ActivityInfo.LoadIcon(PackageManager), LoadLabel = a.LoadLabel(PackageManager), ClassName = a.ActivityInfo.Name, PackageName = a.ActivityInfo.PackageName }); } // アプリ一覧をリストに表示 var listview = FindViewById <ListView>(Resource.Id.list_App); listview.Adapter = new AppSelectAdapter(this, tableItems); listview.ItemClick += Listview_ItemClick; }
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); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); string dbPath = Path.Combine(System. Environment.GetFolderPath (System.Environment.SpecialFolder.Personal), "dbTest.db3"); SetContentView(Resource.Layout.User); EditText name = FindViewById <EditText>(Resource.Id.username); EditText password = FindViewById <EditText>(Resource.Id.userPassword); Button login = FindViewById <Button>(Resource.Id.login); ImageView userImage = FindViewById <ImageView>(Resource.Id.userImage); //userImage.SetAdjustViewBounds(true); login.Click += delegate { //setup connection db = new SQLiteConnection(dbPath); db.CreateTable <UserModel>(); //MakeupModel makeup = new MakeupModel(); UserModel user = new UserModel(); user.UserId = DatabaseList().ToArray().Count() + 1; user.UserName = name.Text; user.UserPassWord = password.Text; //Uri path = new Uri().LocalPath(userImage); //user.UserImage = path.ToString(); db.Insert(user); db.Close(); AlertDialog.Builder builder = new AlertDialog.Builder (this, Android.Resource.Style.ThemeMaterialDialogAlert); builder.SetTitle(Resource.String.login_complete) .SetMessage("Your Id is " + user.UserId + ", your profilename is " + user.UserName + " and your image is " + user.UserImage + " and your password is " + user.UserPassWord) .SetPositiveButton("Ok!", OkAction) .Show(); }; userImage.Click += delegate { Intent intent = new Intent(Intent.ActionOpenDocument); intent.AddCategory(Intent.CategoryOpenable); intent.SetType("image/*"); StartActivityForResult(intent, 1); }; /*userImage.Click += delegate { * ViewModel.GoCommand.Execute(name); * };*/ }
public static string GetLauncherClassName(Context context) { Intent intent = new Intent(Intent.ActionMain); intent.AddCategory(Intent.CategoryLauncher); intent.SetPackage(context.PackageName); var resolveInfos = context.PackageManager.QueryIntentActivities(intent, 0); foreach (var resolveInfo in resolveInfos) { var pkgName = resolveInfo.ActivityInfo.ApplicationInfo.PackageName; if (pkgName.Equals(context.PackageName, StringComparison.InvariantCultureIgnoreCase)) { var className = resolveInfo.ActivityInfo.Name; return(className); } } if (resolveInfos != null && resolveInfos.Count > 0) { return(resolveInfos[0].ActivityInfo.Name); } return(null); }
protected override void OnCreate(Bundle bundle) { var a = CP1252.GetEncoding("utf-32"); base.OnCreate(bundle); //for the image barcode scanner MobileBarcodeScanner.Initialize(Application); //version control Context context = this.ApplicationContext; Values.Version = context.PackageManager.GetPackageInfo(context.PackageName, 0).VersionName; ApplicationInfo ai = PackageManager.GetApplicationInfo(context.PackageName, 0); ZipFile zf = new ZipFile(ai.SourceDir); ZipEntry ze = zf.GetEntry("classes.dex"); long time = ze.Time; System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); dtDateTime = dtDateTime.AddSeconds(Math.Round(time / 1000D)).ToLocalTime(); zf.Close(); Values.Version = string.Format("{0}.{1}", Values.Version, dtDateTime.ToString("yyyyMMdd.Hmmss")); var intent = new Intent(this, typeof(LoginActivityClass)); intent.SetAction(Intent.ActionView); intent.AddCategory(Intent.CategoryLauncher); intent.PutExtra("Version", Values.Version); intent.PutExtra("PackageName", "Partnumber Info"); StartActivityForResult(intent, 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) { //even though GetContent is not well supported (since Android 7, see https://commonsware.com/Android/previews/appendix-b-android-70) //we still offer it. 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); } } }
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 WebView = FindViewById <WebView> (Resource.Id.webView); var wvc = new CCWebViewClient(this); var chrome = new CCWebChromeClient((uploadMsg, acceptType, capture) => { mUploadMessage = uploadMsg; var i = new Intent(Intent.ActionGetContent); i.AddCategory(Intent.CategoryOpenable); i.SetType("video/*;image/*"); StartActivityForResult(Intent.CreateChooser(i, "文件选择"), FILECHOOSER_RESULTCODE); }); WebView.Settings.JavaScriptEnabled = true; WebView.Settings.CacheMode = CacheModes.Normal; WebView.Settings.AllowContentAccess = true; WebView.Settings.AllowFileAccess = true; WebView.Settings.AllowUniversalAccessFromFileURLs = true; WebView.Settings.AllowFileAccessFromFileURLs = true; WebView.Settings.JavaScriptCanOpenWindowsAutomatically = true; WebView.Settings.LoadWithOverviewMode = true; WebView.SetWebViewClient(wvc); WebView.SetWebChromeClient(chrome); WebView.LoadUrl("http://221.208.208.32:7532/Mobile"); }
public bool OpenAppSettings() { var context = Platform.CurrentContext; if (context == null) { return(false); } try { var settingsIntent = new Intent(); settingsIntent.SetAction(global::Android.Provider.Settings.ActionApplicationDetailsSettings); settingsIntent.AddCategory(Intent.CategoryDefault); settingsIntent.SetData(global::Android.Net.Uri.Parse("package:" + context.PackageName)); settingsIntent.AddFlags(ActivityFlags.NewTask); settingsIntent.AddFlags(ActivityFlags.NoHistory); settingsIntent.AddFlags(ActivityFlags.ExcludeFromRecents); context.StartActivity(settingsIntent); return(true); } catch { return(false); } }
/// <summary> /// Show a local notification in the Notification Area and Drawer. /// </summary> /// <param name="title">Title of the notification</param> /// <param name="body">Body or description of the notification</param> /// <param name="id">Id of notifications</param> public void Show(string title, string body, int id = 0) { var builder = new NotificationCompat.Builder(Application.Context); builder.SetContentTitle(title); builder.SetContentText(body); builder.SetOngoing(true); builder.SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)); if (NotificationIconId != 0) { builder.SetSmallIcon(NotificationIconId); } else { builder.SetSmallIcon(Resource.Drawable.icon); } var resumeIntent = new Intent(Application.Context, typeof(MainActivity)); resumeIntent.SetAction(Intent.ActionMain); resumeIntent.AddCategory(Intent.CategoryLauncher); var resultPendingIntent = PendingIntent.GetActivity(Application.Context, 0, resumeIntent, PendingIntentFlags.UpdateCurrent); builder.SetContentIntent(resultPendingIntent); var notificationManager = NotificationManagerCompat.From(Application.Context); var notifcation = builder.Build(); notifcation.Flags = NotificationFlags.OngoingEvent; notificationManager.Notify(id, builder.Build()); }