public void CriarChamada(Activity activity) { isRecording = !isRecording; if (isRecording) { // Cria o INTENT var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); // Abre um modal com uma mensagem de voz voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, "Diga o nome da pessoa"); // Se passar de 5.5s considera que não há mensagem falada voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 5500); voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500); voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000); voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1); // Para chamadas em outras líguas // voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.German); // if you wish it to recognise the default Locale language and German // if you do use another locale, regional dialects may not be recognised very well voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default); activity.StartActivityForResult(voiceIntent, Constants.VOICE); } }
public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId) { // start your service logic here Log.Debug(TAG, "StartCommandResult"); Uri requestUri = intent.Data; if (requestUri == null) { StopSelf(); Log.Debug(TAG, "Request URI was NULL"); } else { Log.Debug(TAG, $"OnStartCommand requestUri {requestUri}, flags={flags}, startid={startId}"); DisplayNotification(); DisplayToastToUser(); // <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> ConnectivityManager connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService); NetworkInfo networkInfo = connectivityManager.ActiveNetworkInfo; if (networkInfo.IsConnected) { var jsonResponse = GetRemoteJSONStringData(requestUri); } StopSelf(); //Stop (and destroy) the service } // Return the correct StartCommandResult for the type of service you are building return(StartCommandResult.NotSticky); }
private void ImageChooserCallback(int requestCode, Result resultCode, Intent intent) { if (resultCode == Result.Ok) { if (ImageSelected != null) { Android.Net.Uri uri = intent.Data; if (ImageSelected != null) { ImageSource imageSource = ImageSource.FromStream(() => Forms.Context.ContentResolver.OpenInputStream(uri)); ImageSelected.Invoke(this, new ImageSourceEventArgs(imageSource)); string doc_id = ""; using (var c1 = Forms.Context.ContentResolver.Query (uri, null, null, null, null)) { c1.MoveToFirst (); string document_id = c1.GetString (0); doc_id = document_id.Substring (document_id.LastIndexOf (":") + 1); } string selection = Android.Provider.MediaStore.Images.Media.InterfaceConsts.Id + " =? "; var cursor = Forms.Context.ContentResolver.Query (MediaStore.Images.Media.ExternalContentUri, null, selection, new string[] {doc_id}, null); var colIndex = cursor.GetColumnIndex(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data); cursor.MoveToFirst(); App.imagePath = cursor.GetString (colIndex); cursor.Close (); } } } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment var view = inflater.Inflate(Resource.Layout.HeaderFragmentLayout, container, false); var homeBtn = view.FindViewById<ImageView>(Resource.Id.HeaderLogo); var overlayBtn = view.FindViewById<ImageView>(Resource.Id.HeaderOverlay); var animIn = AnimationUtils.LoadAnimation(Activity.BaseContext, Resource.Animation.Overlay_animIn); homeBtn.Click += delegate { if (!(Activity is MainActivity)) { var i = new Intent(Activity, typeof(MainActivity)); i.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop); Activity.StartActivity(i); } }; overlayBtn.Click += delegate { overlay.View.StartAnimation(animIn); overlay.Initialize(); overlay.View.Visibility = ViewStates.Visible; }; return view; }
public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId) { if (!_initted) { // This can be a program entry point. Log.SetLogger(new LogAndroid()); Log.Info(LogTag, "Started LifeSharp service"); s_instance = this; _settings = new Settings(this.ApplicationContext); foreach (var service in s_services) { service.start(this.ApplicationContext, _settings); } _initted = true; } else { foreach (var service in s_services) { service.kick(this.ApplicationContext, _settings); } } return(StartCommandResult.Sticky); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); //League league = new League (); Spinner chooseTeamSpinner = FindViewById<Spinner> (Resource.Id.chooseTeamSpinner); chooseTeamSpinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (chooseTeamSpinner_ItemSelected); var adapter = ArrayAdapter.CreateFromResource ( this, Resource.Array.teams_array, Android.Resource.Layout.SimpleSpinnerItem); adapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem); chooseTeamSpinner.Adapter = adapter; // Get our button from the layout resource, // and attach an event to it Button beginSeasonButton = FindViewById<Button> (Resource.Id.beginSeasonButton); beginSeasonButton.Click += (sender, e) => { var intent = new Intent(this, typeof(SeasonActivity)); intent.PutExtra("userTeam", userTeam); StartActivity(intent); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); // Create your application here SetContentView (Resource.Layout.Login); EditText txtIPAddress = (EditText)FindViewById (Resource.Id.txtIPAddress); txtIPAddress.Text = this.GetPreference ("preference_q16_address"); Button btnOk = (Button)FindViewById (Resource.Id.btnOk); btnOk.Click += (sender, e) => { this.SetPreference("preference_q16_address", txtIPAddress.Text); var main = new Intent(this, typeof(MainActivity)); main.PutExtra("address", txtIPAddress.Text); main.PutExtra("demo", false); StartActivity(main); }; Button btnDemo = (Button)FindViewById (Resource.Id.btnDemo); btnDemo.Click += (sender, e) => { var main = new Intent(this, typeof(MainActivity)); main.PutExtra("address", "demo"); main.PutExtra("demo", true); StartActivity(main); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.ListaLabs); var user = FindViewById <TextView>(Resource.Id.tvUSER); user.Text = Intent.GetStringExtra("dato"); var token = Intent.GetStringExtra("token"); CargaLista(token); var ListViewDatos = FindViewById <ListView>(Resource.Id.listView1); ListViewDatos.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { var intent = new Android.Content.Intent(this, typeof(LabInfo)); intent.PutExtra("user", user.Text); intent.PutExtra("id", data.ListaCmp[e.Position].EvidenceID); intent.PutExtra("token", token); intent.PutExtra("labNom", Items[e.Position].Title); intent.PutExtra("labStatus", Items[e.Position].Status); // //Koush.UrlImageViewHelper.SetUrlDrawable(Widget, ImgUrl); StartActivity(intent); }; }
protected override void OnListItemClick(ListView l, View v, int position, long id) { var go = new Android.Content.Intent(this, typeof(ViewDetails)); go.PutExtra("Id", events[position].ID); StartActivity(go); }
public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId) { // start your service logic here // Return the correct StartCommandResult for the type of service you are building return(StartCommandResult.NotSticky); }
public override bool OnOptionsItemSelected(IMenuItem item) { int id = item.ItemId; if (id == Resource.Id.action_file) { if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) == Permission.Denied) { ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.WriteExternalStorage }, 1); } else { var intent = new Android.Content.Intent(this, typeof(Choose)); StartActivityForResult(intent, 2); } return(true); } if (id == Resource.Id.action_search) { SEARCHINANSWER = !SEARCHINANSWER; item.SetChecked(SEARCHINANSWER); FindingText(); FillList(); } return(base.OnOptionsItemSelected(item)); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Login); EditText userName = FindViewById <EditText> (Resource.Id.userNameText); EditText passWord = FindViewById <EditText> (Resource.Id.passWordText); Button loginButton = FindViewById <Button> (Resource.Id.LoginButton); loginButton.Click += async(sender, e) => { string url = "http://10.0.2.2:8080/Blog/loginFromApp.action?userName="******"&passWord="******"true") { var intent = new Android.Content.Intent(this, typeof(BlogListActivity)); StartActivity(intent); } else { Console.WriteLine("cc" + checkResult); string message = "wrong userId or passWord"; Toast.MakeText(ApplicationContext, message, ToastLength.Long).Show(); } }; }
private void ReceiveMessage() { while (true) { string hostName = Dns.GetHostName(); // Retrive the Name of HOST IPAddress ip = IPAddress.Parse(Dns.GetHostByName(hostName).AddressList[0].ToString()); IPEndPoint remoteIPEndPoint = new IPEndPoint(ip, port); byte[] content = udpClient.Receive(ref remoteIPEndPoint); if (content.Length > 0) { string message = Encoding.ASCII.GetString(content); if (message == "300") { // udpClient.Close(); StartActivity(typeof(TrwaAkcja)); } else if (message == "100" || message == "200") { Android.Content.Intent myIntent = new Android.Content.Intent(this, typeof(PierwszyEkran2)); myIntent.PutExtra("key", message); StartActivity(myIntent); } else if (message == "400") { message = "Ile możesz zaoszczędzić kupująć drugi produkt Polsatu Cyfrowego?\n A) 10% \n B) 20% " + "\n C) 40% \n D) 50% "; } } } }
public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId) { MemoTech.Scripts.Utility.ConnectLog.ConnectionCount = 0; var t = new Thread(() => { while (true) { Thread.Sleep(60000); BluetoothLEManager.Instance.BeginScanningForDevices(); Thread.Sleep(5000); BluetoothLEManager.Instance.StopScanningForDevices(); MemoTech.Scripts.Utility.ConnectLog.ConnectionCount += 1; Console.WriteLine("Scan!"); if (BluetoothLEManager.Instance.Check == MemoTech.Scripts.Utility.State.Share) { BluetoothLEManager.Instance.Check = MemoTech.Scripts.Utility.State.Start; StopSelf(); } } }); t.Start(); return(StartCommandResult.Sticky); }
private void ButtonOnClick(object sender, EventArgs eventArgs) { Intent = new Intent(); Intent.SetType("image/*"); Intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId); }
public override void OpenActivityOrFragment(Android.Content.Intent intent) { var pm = PackageManager; var resolveInfoList = pm.QueryIntentActivities(intent, PackageInfoFlags.MatchDefaultOnly); foreach (var resolveInfo in resolveInfoList) { FragmentReplaceInfo fri = OnSubstituteFragmentForActivityLaunch(resolveInfo.ActivityInfo.Name); if (fri != null) { Bundle arguments = IntentToFragmentArguments(intent); FragmentManager fm = SupportFragmentManager; try { Fragment fragment = (Fragment)fri.GetFragmentClass().NewInstance(); fragment.Arguments = arguments; FragmentTransaction ft = fm.BeginTransaction(); ft.Replace(fri.GetContainerId(), fragment, fri.GetFragmentTag()); OnBeforeCommitReplaceFragment(fm, ft, fragment); ft.Commit(); } catch (Exception e) { new Exception("Error creating new fragment." + e.Message); } return; } } base.OpenActivityOrFragment(intent); }
private void ShowDetails(int playId) { _currentPlayId = playId; if (_isDualPane) { // We can display everything in-place with fragments. // Have the list highlight this item and show the data. ListView.SetItemChecked(playId, true); // Check what fragment is shown, replace if needed. var details = FragmentManager.FindFragmentById(Resource.Id.details) as DetailsFragment; if (details == null || details.ShownPlayId != playId) { // Make new fragment to show this selection. details = DetailsFragment.NewInstance(playId); // Execute a transaction, replacing any existing // fragment with this one inside the frame. var ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.details, details); ft.SetTransition(FragmentTransit.FragmentFade); ft.Commit(); } } else { // Otherwise we need to launch a new activity to display // the dialog fragment with selected text. var intent = new Intent(); intent.SetClass(Activity, typeof(DetailsActivity)); intent.PutExtra("current_play_id", playId); StartActivity(intent); } }
public void InstallAPK_MoreThanAndroid7(Java.IO.File apkFileToInstall) { Android.Content.Intent intent = new Android.Content.Intent(); intent.SetAction(Android.Content.Intent.ActionView); if (string.IsNullOrWhiteSpace(mFileProvider_Authority)) { throw new Exception("mFileProvider_Authority为空值。请使用 SetFileProvider_Authority(string) 方法设置 mFileProvider_Authority 的值。"); } Android.Net.Uri uri = Android.Support.V4.Content.FileProvider.GetUriForFile ( context: mAppActivity.ApplicationContext, authority: mFileProvider_Authority, file: apkFileToInstall ); intent.SetDataAndType(uri, "application/vnd.android.package-archive"); intent.SetFlags(Android.Content.ActivityFlags.NewTask); // SetFlags 一定要在 Add Flags 之前, 否则 Add Flags 会被覆盖 intent.AddFlags(Android.Content.ActivityFlags.GrantReadUriPermission); intent.AddFlags(Android.Content.ActivityFlags.GrantWriteUriPermission); mAppActivity.Application.StartActivity(intent); }
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 button = FindViewById<Button> (Resource.Id.btnFoto); button.Click += delegate { Intent camera = new Intent (MediaStore.ActionImageCapture); IList<Android.Content.PM.ResolveInfo> availableActivities = this.PackageManager.QueryIntentActivities (camera, Android.Content.PM.PackageInfoFlags.MatchDefaultOnly); if (availableActivities != null && availableActivities.Count > 0) { var dir = new Java.IO.File ( Android.OS.Environment.GetExternalStoragePublicDirectory ( Android.OS.Environment.DirectoryPictures), "CameraAppDemo"); if (!dir.Exists ()) { dir.Mkdirs (); } _file = new Java.IO.File (dir, String.Format ("myPhoto{0}.jpg", Guid.NewGuid ())); camera.PutExtra (MediaStore.ExtraOutput, Android.Net.Uri.FromFile (_file)); StartActivityForResult (camera, 0); } }; }
private void CheckGpsAvailable() { bool gpsAvailable = DependencyService.Get <IGpsService>().IsGpsAvailable(); if (!gpsAvailable) { AlertDialog.Builder alert = new AlertDialog.Builder(this).SetCancelable(false); alert.SetPositiveButton(Resources.GetText(Resource.String.Common_Yes), (senderAlert, args) => { //DependencyService.Get<IGpsService>().OpenSettings(this); Intent intent = new Android.Content.Intent(Android.Provider.Settings.ActionLocationSourceSettings); intent.AddFlags(ActivityFlags.BroughtToFront); StartActivityForResult(intent, REQUEST_GPS_SETTINGS); }); alert.SetNegativeButton(Resources.GetText(Resource.String.Common_No), (senderAlert, args) => { StartMainActivity(); }); alert.SetMessage(Resources.GetText(Resource.String.Main_EnableGpsQuestion)); var answer = alert.Show(); } else { StartMainActivity(); } }
public override void OnReceive(Context context, Intent intent) { Android.Util.Log.Info("MonoGame", intent.Action.ToString()); if(intent.Action == Intent.ActionScreenOff) { ScreenReceiver.ScreenLocked = true; MediaPlayer.IsMuted = true; } else if(intent.Action == Intent.ActionScreenOn) { // If the user turns the screen on just after it has automatically turned off, // the keyguard will not have had time to activate and the ActionUserPreset intent // will not be broadcast. We need to check if the lock is currently active // and if not re-enable the game related functions. // http://stackoverflow.com/questions/4260794/how-to-tell-if-device-is-sleeping KeyguardManager keyguard = (KeyguardManager)context.GetSystemService(Context.KeyguardService); if (!keyguard.InKeyguardRestrictedInputMode()) { ScreenReceiver.ScreenLocked = false; MediaPlayer.IsMuted = false; } } else if(intent.Action == Intent.ActionUserPresent) { // This intent is broadcast when the user unlocks the phone ScreenReceiver.ScreenLocked = false; MediaPlayer.IsMuted = false; } }
public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId) { const int pendingIntentId = 0; Intent Mainintent = new Intent(this, typeof(MainActivity)); pendingIntent = PendingIntent.GetActivity(this, pendingIntentId, Mainintent, PendingIntentFlags.OneShot); //StartForegroundService(); // This method executes on the main thread of the application. var notification = new Notification.Builder(this) .SetContentTitle(Resources.GetString(Resource.String.app_name)) .SetContentText(Resources.GetString(Resource.String.notification_text)) .SetSmallIcon(Resource.Drawable.ic_explore_black_18dp) .SetContentIntent(pendingIntent) .SetOngoing(true) //.AddAction(BuildRestartTimerAction()) //.AddAction(BuildStopServiceAction()) .Build(); StartForeground(SERVICE_RUNNING_NOTIFICATION_ID, notification); LocationManager = (LocationManager)GetSystemService(LocationService); SD = new SaveData(); GPS = new mygps(LocationManager, this, SD); Timer Btimer = new System.Timers.Timer(); Btimer.Interval = 30000; Btimer.Elapsed += Ontimedevent; Btimer.AutoReset = true; Btimer.Enabled = true; return(StartCommandResult.Sticky); }
/// <inheritdoc/> public override void OnActivityResult(int requestCode, int resultCode, Intent data) { ZTnTrace.Trace(MethodBase.GetCurrentMethod()); switch (requestCode) { case AddNewAccount: switch (resultCode) { case -1: var battleTag = data.GetStringExtra("battleTag"); var host = data.GetStringExtra("host"); D3Context.Instance.DbAccounts.Insert(battleTag, host); IListAdapter careerAdapter = new SimpleCursorAdapter(Activity, Android.Resource.Layout.SimpleListItem2, cursor, accountsFromColumns, accountsToId); Activity.FindViewById<ListView>(Resource.Id.AccountsListView) .Adapter = careerAdapter; Toast.MakeText(Activity, "Account added", ToastLength.Short) .Show(); break; } break; } base.OnActivityResult(requestCode, resultCode, data); }
void ProcessHttpRequest(HttpListenerContext context) { try { string barcodeFormatStr = context.Request?.QueryString? ["format"] ?? "QR_CODE"; string barcodeValue = context?.Request?.QueryString? ["value"] ?? ""; string barcodeUrl = context?.Request?.QueryString? ["url"] ?? ""; // Pass along the querystring values var intent = new Android.Content.Intent(this, typeof(MainActivity)); intent.PutExtra("FORMAT", barcodeFormatStr); intent.PutExtra("VALUE", barcodeValue); intent.PutExtra("URL", barcodeUrl); intent.AddFlags(ActivityFlags.NewTask); // Start the activity to show the values StartActivity(intent); // Return a success context.Response.StatusCode = (int)HttpStatusCode.OK; context.Response.StatusDescription = "OK"; context.Response.Close(); } catch (Exception e) { Console.WriteLine("Error " + e.Message); context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.Response.Close(); } }
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 button = FindViewById<Button>(Resource.Id.MyButton); button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; Button button1 = FindViewById<Button>(Resource.Id.button1); TextView textview = FindViewById<TextView>(Resource.Id.textView1); button1.Click += delegate { textview.Text = string.Format("{0} hello zzb!!", count); }; Button btnPhone = FindViewById<Button>(Resource.Id.btnPhone); btnPhone.Click += delegate { }; btnPhone.Click += BtnPhone_Click; Button btnToSec = FindViewById<Button>(Resource.Id.btnToSec); btnToSec.Click += delegate { Intent intent = new Intent(this, typeof(SecondActivity)); StartActivity(intent); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //Log.Debug(TAG, "OnCreate()"); Android.Content.Intent intent = Intent; Bundle extraBundle = intent.Extras; if (bundle == null) { /* * We can't add events here, because during the orientation change, the View gets replaced and * the ViewModel events will be notified to the old view... (SupportFragmentManager.IsDestroyed = true) * BaseVM.PropertyChanged += BaseVM_PropertyChanged; */ } //if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1) { // IsDestroyed has been introduced since API Level 17 if (SupportFragmentManager.IsDestroyed) { //Log.Error(TAG, "Activity has been already destroyed"); return; } }
public override Android.OS.IBinder OnBind(Android.Content.Intent intent) { System.Diagnostics.Debug.WriteLine("Sticky Service - Binded"); //Toast.MakeText(this, "Service started", ToastLength.Long).Show(); return(null); }
public static bool OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent intent) { try { if (intent == null || string.IsNullOrWhiteSpace(intent.Data?.ToString())) { return(false); } var uri = new Uri(intent.Data.ToString()); // Only handle schemes we expect var scheme = uri.Scheme; if (!authenticators.TryGetValue(scheme, out var authenticator)) { return(false); } if (authenticator.Authenticator.CheckUrl(uri, null)) { authenticators.Remove(scheme); return(true); } return(false); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
public void RecordNotificationReceived(Intent message) { var id = message.GetStringExtra(PlatformAccess.BuddyPushKey); if (!String.IsNullOrEmpty(id)) { PlatformAccess.Current.OnNotificationReceived(id); } }
public static void HandleItemShowEpisodeClick(object item, Context context) { var pageLink = string.Empty; var canGoBackToSeriesHome = false; if (item is CalenderScheduleList calenderItem) { pageLink = calenderItem.PageLink; } else if (item is ShowList showItem) { pageLink = showItem.PageLink; } else if (item is SearchList searchItem) { pageLink = searchItem.PageLink; } else if (item is EpisodeList episodeItem) { pageLink = episodeItem.PageLink; } else if (item is SearchSuggestionsData searchSuggestion) { pageLink = searchSuggestion.ItemLink; } else if (item is GenresShow genreShow) { pageLink = genreShow.PageLink; } else if (item is ShowEpisodeDetails episodeDetailLink) { pageLink = episodeDetailLink.EpisodeLink; canGoBackToSeriesHome = true; } else if (item is SeriesDetails seriesDetailLink) { pageLink = seriesDetailLink.SeriesLink; } if (string.IsNullOrEmpty(pageLink)) { Error.Instance.ShowErrorTip("Link is empty.", context); return; } if (pageLink.Contains("/serie/")) { // tv show detail var intent = new Android.Content.Intent(context, typeof(ShowDetailActivity)); intent.PutExtra("itemLink", pageLink); context.StartActivity(intent); } else { // tv episode detail var intent = new Android.Content.Intent(context, typeof(EpisodeDetailActivity)); intent.PutExtra("itemLink", pageLink); intent.PutExtra("canGoBackToSeriesHome", canGoBackToSeriesHome); context.StartActivity(intent); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); comicListView = FindViewById<ListView>(Resource.Id.ComicList); comicListView.ChoiceMode = ChoiceMode.Multiple; comicListView.FastScrollEnabled = true; data = new ComicList (new CSVParser (Assets.Open ("Data/titles.csv"))); // wire up task click handler if(comicListView != null) { comicListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { // Starting to think I should just serialize this var comicDetails = new Intent (this, typeof (ComicDetailsActivity)); comicDetails.PutExtra("ComicName", data[e.Position].Name); comicDetails.PutExtra("ComicDescription", data[e.Position].Description); comicDetails.PutExtra("ComicPublisher", data[e.Position].Publisher); comicDetails.PutExtra("ComicDate", data[e.Position].Date); comicDetails.PutExtra("ID", data[e.Position].ID); comicDetails.PutExtra("Favourite", data.IsFavourite(e.Position)); comicDetails.PutExtra("OtherComics", data.GetPublisherCount(data[e.Position].Publisher) - 1); StartActivity (comicDetails); }; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); FindViewById <BootstrapButton>(Resource.Id.github_btn).SetOnClickListener(new ViewOnClick(v => { var intent = new Android.Content.Intent(Intent.ActionView); //StartActivity(intent); intent.SetData(Android.Net.Uri.Parse("https://github.com/code-jar/Android-Bootstrap")); StartActivity(intent); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_button).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapButtonExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_fontawesometext).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(AwesomeTextViewExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_label).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapLabelExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_progress).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapProgressBarExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_progress_group).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapProgressBarGroupExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_btn_group).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapButtonGroupExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_cricle_thumbnail).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapCircleThumbnailExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_edit_text).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapEditTextExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_thumbnail).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapThumbnailExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_well).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapWellExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_dropdown).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapDropDownExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_alert).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapAlertExample))); })); FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_badge).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapBadgeExample))); })); }
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data) { try { FacebookSdk.SdkInitialize(this); // FacebookSdk.ApplicationId = "444917649791842"; //pune el id de la app de facebook AppEventsLogger.ActivateApp(Application); //no se que hace esta linea mprofileTracker = new MyProfileTracker(); mprofileTracker.mOnProfileChanged += MprofileTracker_mOnProfileChanged; mprofileTracker.StartTracking(); // Set our view from the "main" layout resource // SetContentView(Resource.Layout.configCuenta); //BtnFBLogin = FindViewById<LoginButton>(Resource.Id.fb_btn); BtnFBLogin.SetReadPermissions(new List <string> { "public_profile", "user_friends", "email", "user_birthday" }); mFBCallManager = CallbackManagerFactory.Create(); BtnFBLogin.RegisterCallback(mFBCallManager, this); //base.OnActivityResult(requestCode, resultCode, data); mFBCallManager.OnActivityResult(requestCode, (int)resultCode, data); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); } }
public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId) { StartServiceInForeground(); binder.GetDemoService().startThread = true; DoWork(); return(StartCommandResult.NotSticky); }
public void PushPresenter(object presenter) { object oldPresenter = application.Presenter; if(presenter != oldPresenter) { application.Presenter = presenter; Intent i = null; if(presenter is SearchResultsPresenter) { i = new Intent(application.CurrentActivity, typeof(SearchResultsView)); } else if(presenter is PropertyPresenter) { i = new Intent(application.CurrentActivity, typeof(PropertyView)); } else if(presenter is FavouritesPresenter) { i = new Intent(application.CurrentActivity, typeof(FavouritesView)); } if(i != null) application.CurrentActivity.StartActivity(i); } }
public override void OnReceive(Android.Content.Context context, Android.Content.Intent intent) { try { string action = intent.Action; switch (action) { case BluetoothDevice.ActionAclConnected: case BluetoothDevice.ActionAclDisconnected: { BluetoothDevice device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice); if (device != null) { if (!string.IsNullOrEmpty(_connectDeviceAddress) && string.Compare(device.Address, _connectDeviceAddress, StringComparison.OrdinalIgnoreCase) == 0) { _deviceConnected = action == BluetoothDevice.ActionAclConnected; ConnectedEvent.Set(); } } break; } } } catch (Exception) { // ignored } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var root = inflater.Inflate(Resource.Layout.fragment_contacts, container, false); refresher = root.FindViewById<SwipeRefreshLayout>(Resource.Id.refresher); refresher.SetColorScheme(Resource.Color.blue); refresher.Refresh += async delegate { if (viewModel.IsBusy) return; await viewModel.GetContactsAsync(); Activity.RunOnUiThread(() => { ((BaseAdapter)listView.Adapter).NotifyDataSetChanged(); }); }; viewModel.PropertyChanged += PropertyChanged; listView = root.FindViewById<ListView>(Resource.Id.list); listView.Adapter = new ContactAdapter(Activity, viewModel); listView.ItemLongClick += ListViewItemLongClick; listView.ItemClick += ListViewItemClick; var fab = root.FindViewById<FloatingActionButton>(Resource.Id.fab); fab.AttachToListView(listView); fab.Click += (sender, args) => { ContactDetailsActivity.ViewModel = null; var intent = new Intent(Activity, typeof(ContactDetailsActivity)); StartActivity(intent); }; return root; }
internal static bool IsIntentSupported(AndroidIntent intent) { var manager = AppContext.PackageManager; var activities = manager.QueryIntentActivities(intent, PackageInfoFlags.MatchDefaultOnly); return(activities.Any()); }
private void OnItemClick(object sender, AdapterView.ItemClickEventArgs e) { var person = _people[e.Position]; var intent = new Intent(this, typeof(PersonDetailActivity)); intent.PutExtra("PersonId", person.Id); StartActivity(intent); }
protected override void OnNewIntent(Android.Content.Intent intent) { NotificationCenter.NotifyNotificationTapped(intent); Push.CheckLaunchedFromNotification(this, intent); base.OnNewIntent(intent); }
public void SetHeader(String title, bool btnHomeVisible, bool btnFeedbackVisible) { ViewStub stub = (ViewStub) FindViewById(Resource .Id .vsHeader); View inflated = stub.Inflate(); TextView txtTitle = (TextView) inflated.FindViewById(Resource.Id.txtHeading ); txtTitle.Text=title; Button btnHome = (Button) inflated.FindViewById(Resource .Id.btnHome ); if(!btnHomeVisible) btnHome.Visibility = Android.Views .ViewStates .Invisible ; btnHome .Click+= delegate(object sender, EventArgs e) { Intent intent = new Intent(this.ApplicationContext , typeof (HomeActivity )); intent.SetFlags (ActivityFlags.ClearTop ); StartActivity(intent); }; Button btnFeedback = (Button) inflated.FindViewById( Resource.Id.btnFeedback); if(!btnFeedbackVisible) btnFeedback.Visibility = Android.Views .ViewStates .Invisible ; btnFeedback .Click += delegate(object sender, EventArgs e) { Intent intent = new Intent(this.ApplicationContext , typeof (ActivityFeedback)); intent.SetFlags (ActivityFlags.ClearTop ); StartActivity(intent); }; }
/// <summary> /// Start to select photo. /// </summary> /// <param name="requestCode"> identity of the requester activity. </param> public void ForResult(int requestCode) { if (engine == null) { throw new ExceptionInInitializerError(LoadEngine.INITIALIZE_ENGINE_ERROR); } Activity activity = Activity; if (activity == null) { return; // cannot continue; } mSelectionSpec.MimeTypes = MimeTypes; mSelectionSpec.Engine = engine; Intent intent = new Intent(activity, typeof(ImageSelectActivity)); intent.PutExtra(ImageSelectActivity.EXTRA_SELECTION_SPEC, mSelectionSpec); // intent.putExtra(ImageSelectActivity.EXTRA_ENGINE, (Serializable) engine); intent.PutParcelableArrayListExtra(ImageSelectActivity.EXTRA_RESUME_LIST, mResumeList.AsIParcelableList()); Fragment fragment = Fragment; if (fragment != null) { fragment.StartActivityForResult(intent, requestCode); } else { activity.StartActivityForResult(intent, requestCode); } hasInitPicker = false; }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { if (requestCode == 111 && resultCode == Result.Ok) { Console.WriteLine (data.Data); } base.OnActivityResult (requestCode, resultCode, data); }
//http://forums.xamarin.com/discussion/19362/xamarin-forms-splashscreen-in-android protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); string databasePath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); string databaseFull = System.IO.Path.Combine (databasePath, Global.databaseName); if (File.Exists (databaseFull) == true) { //it's not the first time var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid (); var cn = new SQLite.Net.SQLiteConnection (plat, databaseFull); var m = cn.Table<MacroCategories> ().ToList (); Global.k_MacroCategories = new MyObservableCollection<MacroCategories> (m); var c = cn.Table<Categories> ().ToList (); Global.K_Categories = new MyObservableCollection<Categories> (c); var p = cn.Table<POIs> ().ToList (); Global.K_POIs = new MyObservableCollection<POIs> (p); var cp = cn.Table<Categories_POIs> ().ToList (); Global.K_Categories_POIs = new MyObservableCollection<Categories_POIs> (cp); var pg = cn.Table<POIsPictures> ().ToList (); Global.K_POIsPictures = new MyObservableCollection<POIsPictures> (pg); Global.K_CCFs = Global.createCCFs (); Thread.Sleep (1); // Simulate a long loading process on app startup } else { Thread.Sleep (2000); // Simulate a long loading process on app startup } var intent = new Intent (this, typeof(MainActivity)); StartActivity (intent); Finish (); // Create your application here }
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 (); }
public static Task StartLocationService() { if (_isRunning) return Task.FromResult(true); _isRunning = true; // Starting a service like this is blocking, so we want to do it on a background thread return Task.Run(() => { // Start our main service Log.Debug("App", "Calling StartService"); Android.App.Application.Context.StartService(new Intent(Android.App.Application.Context, typeof (GeolocationService))); // bind our service (Android goes and finds the running service by type, and puts a reference // on the binder to that service) // The Intent tells the OS where to find our Service (the Context) and the Type of Service // we're looking for (LocationService) var locationServiceIntent = new Intent(Android.App.Application.Context, typeof (GeolocationService)); Log.Debug("App", "Calling service binding"); // Finally, we can bind to the Service using our Intent and the ServiceConnection we // created in a previous step. Android.App.Application.Context.BindService(locationServiceIntent, LocationServiceConnection, Bind.AutoCreate); }); }
async void TakePhotoButtonTapped(object sender, EventArgs e) { camera.StopPreview(); var image = textureView.Bitmap; try { var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath; var folderPath = absolutePath + "/Camera"; var filePath = System.IO.Path.Combine(folderPath, string.Format("photo_{0}.jpg", Guid.NewGuid())); var fileStream = new FileStream(filePath, FileMode.Create); await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 50, fileStream); fileStream.Close(); image.Recycle(); var intent = new Android.Content.Intent(Android.Content.Intent.ActionMediaScannerScanFile); var file = new Java.IO.File(filePath); var uri = Android.Net.Uri.FromFile(file); intent.SetData(uri); MainActivity.Instance.SendBroadcast(intent); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(@" ", ex.Message); } camera.StartPreview(); }
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data) { const int IMAGE_PICKER_REQUEST_CODE = 100; const String IMAGE_PICKER_ARRAY_LIST_EXTRA = "ImagePickerImages"; if (resultCode == Result.Ok && requestCode == IMAGE_PICKER_REQUEST_CODE) { var pickedImages = data.GetParcelableArrayListExtra(IMAGE_PICKER_ARRAY_LIST_EXTRA); if (imagePickerThumbnail) { ImageView thumbnail = FindViewById <ImageView>(Resource.Id.thumbnail); String imagePath = ((Com.Nguyenhoanglam.Imagepicker.Model.Image)pickedImages[0]).Path; thumbnail.SetImageURI(Android.Net.Uri.Parse(imagePath)); } else { UserPhotoFragment addPhoto = new UserPhotoFragment(); addPhoto.PhotoPath = ((Com.Nguyenhoanglam.Imagepicker.Model.Image)pickedImages[0]).Path; addPhoto.AddPhotoFragment = false; addPhoto.UserPhotoClick = this; userPhotosAdapter.UserPhotosFragments.Add(addPhoto); userPhotosAdapter.NotifyDataSetChanged(); } } }
/// <summary> /// Helper method to extract the full Push JSON provided to LeanCloud, including any /// non-visual custom information. /// </summary> /// <param name="intent"><see cref="Android.Content.Intent"/> received typically /// from a <see cref="Android.Content.BroadcastReceiver"/></param> /// <returns>Returns the push payload in the intent. Returns an empty dictionary if the intent /// doesn't contain push payload.</returns> internal static IDictionary<string, object> PushJson(Intent intent) { IDictionary<string, object> result = new Dictionary<string, object>(); string messageType = intent.GetStringExtra("message_type"); if (messageType != null) { // The GCM docs reserve the right to use the message_type field for new actions, but haven't // documented what those new actions are yet. For forwards compatibility, ignore anything // with a message_type field. } else { string pushDataString = intent.GetStringExtra("data"); IDictionary<string, object> pushData = null; // We encode the data payload as JSON string. Deserialize that string now. if (pushDataString != null) { pushData = Json.Parse(pushDataString) as IDictionary<string, object>; } if (pushData != null) { result = pushData; } } return result; }
public void DidEnterRegion(AltBeaconOrg.BoundBeacon.Region region) { // In this example, this class sends a notification to the user whenever a Beacon // matching a Region (defined above) are first seen. Log.Debug(TAG, "did enter region."); if (!haveDetectedBeaconsSinceBoot) { Log.Debug(TAG, "auto launching MonitoringActivity"); // The very first time since boot that we detect an beacon, we launch the // MainActivity var intent = new Intent(this, typeof(MainActivity)); intent.SetFlags(ActivityFlags.NewTask); // Important: make sure to add android:launchMode="singleInstance" in the manifest // to keep multiple copies of this activity from getting created if the user has // already manually launched the app. this.StartActivity(intent); haveDetectedBeaconsSinceBoot = true; } else { if (mainActivity != null) { Log.Debug(TAG, "I see a beacon again"); } else { // If we have already seen beacons before, but the monitoring activity is not in // the foreground, we send a notification to the user on subsequent detections. Log.Debug(TAG, "Sending notification."); SendNotification(); } } }
public void Dispatch(nView view) { Activity context = (Activity) view.Action.Params[nAndroidView.CONTEXT]; Type target = (Type) view.Action.Params[nAndroidView.TARGET]; var intent = new Intent(context, target); context.StartActivity(intent); }
public AddEventToCalAction(Context context, Intent intent, int drawable, string url) { Drawable = drawable; Context = context; Intent = intent; Url = url; }
public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId) { CreateNotificationChannel(); WireAlarm(intent); return(StartCommandResult.Sticky); }
internal void InitMediaSession(string packageName, MediaServiceBinder binder) { try { if (mediaSessionCompat == null) { Intent nIntent = new Intent(applicationContext, typeof(MediaPlayer)); PendingIntent pIntent = PendingIntent.GetActivity(applicationContext, 0, nIntent, 0); RemoteComponentName = new ComponentName(packageName, new RemoteControlBroadcastReceiver().ComponentName); mediaSessionCompat = new MediaSessionCompat(applicationContext, "XamarinStreamingAudio", RemoteComponentName, pIntent); mediaControllerCompat = new MediaControllerCompat(applicationContext, mediaSessionCompat.SessionToken); NotificationManager = new MediaNotificationManagerImplementation(applicationContext, CurrentSession.SessionToken, _serviceType); } mediaSessionCompat.Active = true; mediaSessionCompat.SetCallback(binder.GetMediaPlayerService<MediaServiceBase>().AlternateRemoteCallback ?? new MediaSessionCallback(this)); mediaSessionCompat.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls); _packageName = packageName; _binder = binder; } catch (Exception ex) { Console.WriteLine(ex); } }
private Intent GetShareIntent() { var intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraText, feedItem.Title + " " + feedItem.Link + " #PlanetXamarin"); return intent; }
void Buy_Click(object sender, EventArgs e) { var intent = new Intent (this, typeof(FinalDialog)); intent.PutExtra ("Extra_Link", _VideoLink); StartActivity(intent); }
protected override void OnListItemClick(ListView l, View v, int position, long id) { var url = _adapter.GetMapUrl (position); var intent = new Intent (Intent.ActionView, Uri.Parse(url)); StartActivity (intent); }
private void Checkbutton_Click(object sender, EventArgs e) { Intent itent = new Android.Content.Intent((this), typeof(MainActivity)); var temp = radioGroup.CheckedRadioButtonId; if (temp == radioButton1.Id) { Toast.MakeText(this, "English", ToastLength.Short).Show(); templish[0] = "English"; itent.PutStringArrayListExtra("settings", templish); } else if (temp == radioButton2.Id) { Toast.MakeText(this, "Russian", ToastLength.Short).Show(); templish[0] = "Russian"; itent.PutStringArrayListExtra("settings", templish); } else { Toast.MakeText(this, "Ukraine", ToastLength.Short).Show(); templish[0] = "Ukraine"; itent.PutStringArrayListExtra("settings", templish); } // itent.PutStringArrayListExtra("settings", list); StartActivity(itent); }
void GridOnItemClick(object sender, AdapterView.ItemClickEventArgs itemClickEventArgs) { var intent = new Intent(Activity, typeof(FriendActivity)); intent.PutExtra("Title", friends[itemClickEventArgs.Position].Title); intent.PutExtra("Image", friends[itemClickEventArgs.Position].Image); StartActivity(intent); }
private void LaunchFile(int index) { Bundle bundle; if (AppConstant.IsQPOffline(SystemPath.GetFileName(semesters[semesterIndex].Years[yearIndex].QuestionPapers[index].FileLink.ToString()))) { bundle = new Bundle(); bundle.PutBoolean("IsFileOffline", true); bundle.PutString("PATH", SystemPath.Combine(AppConstant.QPFolderPath, SystemPath.GetFileName(semesters[semesterIndex].Years[yearIndex].QuestionPapers[index].FileLink.ToString()))); } else { bundle = new Bundle(); bundle.PutBoolean("IsFileOffline", false); bundle.PutString("URL", semesters[semesterIndex].Years[yearIndex].QuestionPapers[index].FileLink.ToString()); bundle.PutBoolean("IsFileNotice", false); } if (Looper.MyLooper() == null) { Looper.Prepare(); } Android.Content.Intent i = new Android.Content.Intent(this, typeof(PDFViewerActivity)); i.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop); i.PutExtras(bundle); StartActivity(i); }