public setAction ( java arg0 ) : global::android.content.Intent | ||
arg0 | java | |
Результат | global::android.content.Intent |
// http://stackoverflow.com/questions/6274141/trigger-background-service-at-a-specific-time-in-android // http://stackoverflow.com/questions/7144908/how-is-an-intent-service-declared-in-the-android-manifest // http://developer.android.com/guide/topics/manifest/service-element.html protected override void onCreate(global::android.os.Bundle savedInstanceState) { // http://developer.android.com/guide/topics/ui/notifiers/notifications.html base.onCreate(savedInstanceState); ScrollView sv = new ScrollView(this); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); sv.addView(ll); #region startservice var startservice = new Button(this); startservice.setText("Start Service to send Notification"); startservice.AtClick( delegate { this.ShowToast("startservice_onclick"); var intent = new Intent(this, typeof(NotifyService).ToClass()); this.startService(intent); } ); ll.addView(startservice); #endregion #region stopservice var stopservice = new Button(this); stopservice.setText("Stop Service"); stopservice.AtClick( delegate { this.ShowToast("stopservice_onclick"); Intent intent = new Intent(); intent.setAction(NotifyService.ACTION); intent.putExtra("RQS", NotifyService.RQS_STOP_SERVICE); this.sendBroadcast(intent); } ); ll.addView(stopservice); #endregion this.setContentView(sv); this.ShowToast("http://jsc-solutions.net"); }
protected override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); var sv = new ScrollView(this); var ll = new LinearLayout(this); //ll.setOrientation(LinearLayout.VERTICAL); sv.addView(ll); var b = new Button(this); ll.addView(b); var p = new Preview(this); b.WithText("take a picture"); p.oncamera = camera => b.AtClick( v => { camera.takePicture(null, null, new takePicture_handler { handler = data => { b.WithText("at click"); try { // http://stackoverflow.com/questions/11874273/android-nexus-7-jelly-bean-startpreview-takepicture-calling-getcamerastereomode //E/NvOmxCamera( 126): OMX_ERRORTYPE android::NvOmxCamera::getCameraStereoMode(NvxComponent*, NvOmxCameraUserStereoMode&): Error: invalid NVX mode 0. //E/NvOmxCamera( 126): OMX_ERRORTYPE android::NvOmxCamera::getCameraStereoModeAndCaptureInfo(NvxComponent*, NvOmxCameraUserStereoMode&, NVX_STEREOCAPTUREINFO&): getCameraStereoMode failed with 0x00000000 //D/NvOsDebugPrintf( 126): NvMMLiteJPEGEncSetAttribute: Incorrect value 0 for stereo capture type //E/NvOmxCameraSettings( 126): OMX_ERRORTYPE android::programStereoInfo(OMX_HANDLETYPE, const NVX_STEREOCAPTUREINFO&, android::NvxWrappers*): pNvxWrappers->OMX_SetConfigIL failed with 0x80001005 //D/NvOsDebugPrintf( 126): Tryproc: INBuffer-Values of Width and Height 1280 960 //D/dalvikvm(29535): GC_FOR_ALLOC freed 6686K, 52% free 7716K/15943K, paused 25ms, total 27ms var SAVE_PATH = android.os.Environment.getExternalStoragePublicDirectory( android.os.Environment.DIRECTORY_PICTURES ); SAVE_PATH.mkdirs(); var bmp = android.graphics.BitmapFactory.decodeByteArray(data, 0, data.Length); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bmp.compress(android.graphics.Bitmap.CompressFormat.JPEG, 100, bytes); File f = new File(SAVE_PATH.ToString() + "/hello2.jpg"); f.createNewFile(); FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); var imgUri = android.net.Uri.fromFile(f); intent.setDataAndType(imgUri, "image/*"); b.WithText("done!"); startActivity(intent); } // Error 1 The type caught or thrown must be derived from System.Exception y:\jsc.svn\examples\java\android\AndroidCameraActivity\AndroidCameraActivity\ApplicationActivity.cs 154 52 AndroidCameraActivity catch (Exception ex) { b.WithText("saving.. error! " + ex.Message); //throw; } } } ); } ); this.setContentView(p); this.addContentView(sv, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
// https://github.com/opersys/raidl // http://stackoverflow.com/questions/6274141/trigger-background-service-at-a-specific-time-in-android // http://stackoverflow.com/questions/7144908/how-is-an-intent-service-declared-in-the-android-manifest // http://developer.android.com/guide/topics/manifest/service-element.html // https://github.com/android/platform_frameworks_base/blob/master/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java //AtBootCompleted hack1; protected override void onCreate(global::android.os.Bundle savedInstanceState) { // http://developer.android.com/guide/topics/ui/notifiers/notifications.html base.onCreate(savedInstanceState); var sv = new ScrollView(this); var ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); sv.addView(ll); #region startservice var startservice = new Button(this); startservice.setText("Start Service to send Notification"); startservice.AtClick( delegate { startservice.setEnabled(false); //this.ShowToast("startservice_onclick"); //var intent = new Intent(this, NotifyService.Class); var intent = new Intent(this, typeof(NotifyService).ToClass()); this.startService(intent); // http://developer.android.com/reference/android/app/Activity.html#recreate%28%29 this.recreate(); } ); ll.addView(startservice); #endregion #region stopservice var stopservice = new Button(this); stopservice.setText("Stop Service"); stopservice.AtClick( delegate { this.ShowToast("stopservice_onclick"); var intent = new Intent(); intent.setAction(NotifyService.ACTION); intent.putExtra("RQS", NotifyService.RQS_STOP_SERVICE); this.sendBroadcast(intent); // seems stop takes a while //Task.Delay(100); Thread.Sleep(30); this.recreate(); } ); ll.addView(stopservice); #endregion stopservice.setEnabled(false); // http://stackoverflow.com/questions/12891903/android-check-if-my-service-is-running-in-the-background var m = (ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE); Console.WriteLine("getRunningServices"); var s = m.getRunningServices(1000); Console.WriteLine("getRunningServices " + s.size()); var se = // http://stackoverflow.com/questions/7170730/how-to-set-a-control-panel-for-my-service-in-android from i in Enumerable.Range(0, s.size()) let rsi = (android.app.ActivityManager.RunningServiceInfo)s.get(i) let cn = rsi.service.getClassName() let cp = m.getRunningServiceControlPanel(rsi.service) //orderby cn orderby cp != null select new { i, rsi, cn, cp }; //java.lang.JavaSystem.ex // I/System.Console( 1617): { i = 45, cn = android.hardware.location.GeofenceHardwareService, cp = } //I/System.Console( 1617): { i = 17, cn = ccc71.at.services.at_service, cp = } //I/System.Console( 1617): { i = 34, cn = com.android.bluetooth.a2dp.A2dpService, cp = } //I/System.Console( 1617): { i = 13, cn = com.android.bluetooth.btservice.AdapterService, cp = } //I/System.Console( 1617): { i = 23, cn = com.android.bluetooth.gatt.GattService, cp = } //I/System.Console( 1617): { i = 68, cn = com.android.bluetooth.hfp.HeadsetService, cp = } //I/System.Console( 1617): { i = 0, cn = com.android.bluetooth.hid.HidService, cp = } //I/System.Console( 1617): { i = 84, cn = com.android.bluetooth.pan.PanService, cp = } //I/System.Console( 1617): { i = 80, cn = com.android.defcontainer.DefaultContainerService, cp = } //I/System.Console( 1617): { i = 37, cn = com.android.incallui.InCallServiceImpl, cp = } //I/System.Console( 1617): { i = 71, cn = com.android.incallui.MCIDService, cp = } //I/System.Console( 1617): { i = 55, cn = com.android.incallui.SecInCallService, cp = } //I/System.Console( 1617): { i = 73, cn = com.android.internal.backup.LocalTransportService, cp = } //I/System.Console( 1617): { i = 81, cn = com.android.phone.TelephonyDebugService, cp = } //I/System.Console( 1617): { i = 66, cn = com.android.providers.media.MtpService, cp = } //I/System.Console( 1617): { i = 65, cn = com.android.server.DrmEventService, cp = } //I/System.Console( 1617): { i = 57, cn = com.android.server.telecom.BluetoothPhoneService, cp = } //I/System.Console( 1617): { i = 50, cn = com.android.server.telecom.BluetoothVoIPService, cp = } //I/System.Console( 1617): { i = 62, cn = com.android.stk.StkAppService, cp = } //I/System.Console( 1617): { i = 15, cn = com.android.systemui.ImageWallpaper, cp = PendingIntent{2759cef2: android.os.BinderProxy@181ef173} } //I/System.Console( 1617): { i = 44, cn = com.android.systemui.SystemUIService, cp = } //I/System.Console( 1617): { i = 12, cn = com.android.systemui.keyguard.KeyguardService, cp = } //I/System.Console( 1617): { i = 21, cn = com.dsi.ant.server.AntService, cp = } //I/System.Console( 1617): { i = 48, cn = com.fmm.dm.XDMService, cp = } //I/System.Console( 1617): { i = 22, cn = com.google.android.gms.analytics.service.AnalyticsService, cp = } //I/System.Console( 1617): { i = 51, cn = com.google.android.gms.auth.trustagent.GoogleTrustAgent, cp = } //I/System.Console( 1617): { i = 86, cn = com.google.android.gms.backup.BackupTransportService, cp = } //I/System.Console( 1617): { i = 4, cn = com.google.android.gms.car.CarService, cp = } //I/System.Console( 1617): { i = 76, cn = com.google.android.gms.clearcut.service.ClearcutLoggerService, cp = } //I/System.Console( 1617): { i = 75, cn = com.google.android.gms.common.stats.GmsCoreStatsService, cp = } //I/System.Console( 1617): { i = 67, cn = com.google.android.gms.deviceconnection.service.DeviceConnectionServiceBroker, cp = } //I/System.Console( 1617): { i = 19, cn = com.google.android.gms.gcm.GcmService, cp = } //I/System.Console( 1617): { i = 38, cn = com.google.android.gms.gcm.http.GoogleHttpService, cp = } //I/System.Console( 1617): { i = 74, cn = com.google.android.gms.playlog.service.PlayLogBrokerService, cp = } //I/System.Console( 1617): { i = 18, cn = com.google.android.gms.trustagent.api.trustagent.GoogleTrustAgentService, cp = } //I/System.Console( 1617): { i = 25, cn = com.google.android.gms.usagereporting.service.UsageReportingService, cp = } //I/System.Console( 1617): { i = 82, cn = com.google.android.gms.wearable.service.WearableService, cp = } //I/System.Console( 1617): { i = 40, cn = com.google.android.hotword.service.HotwordService, cp = } //I/System.Console( 1617): { i = 60, cn = com.google.android.libraries.hangouts.video.VideoChatService, cp = } //I/System.Console( 1617): { i = 30, cn = com.google.android.location.fused.FusedLocationService, cp = } //I/System.Console( 1617): { i = 16, cn = com.google.android.location.geocode.GeocodeService, cp = } //I/System.Console( 1617): { i = 39, cn = com.google.android.location.geofencer.service.GeofenceProviderService, cp = } //I/System.Console( 1617): { i = 63, cn = com.google.android.location.internal.GoogleLocationManagerService, cp = } //I/System.Console( 1617): { i = 54, cn = com.google.android.location.internal.PendingIntentCallbackService, cp = } //I/System.Console( 1617): { i = 58, cn = com.google.android.location.internal.server.GoogleLocationService, cp = } //I/System.Console( 1617): { i = 61, cn = com.google.android.location.network.NetworkLocationService, cp = } //I/System.Console( 1617): { i = 3, cn = com.google.android.music.dial.DialMediaRouteProviderService, cp = } //I/System.Console( 1617): { i = 6, cn = com.google.android.search.core.service.BroadcastListenerService, cp = } //I/System.Console( 1617): { i = 35, cn = com.google.android.search.core.service.SearchService, cp = } //I/System.Console( 1617): { i = 69, cn = com.google.android.voiceinteraction.GsaVoiceInteractionService, cp = } //I/System.Console( 1617): { i = 85, cn = com.ime.framework.spellcheckservice.SamsungIMESpellCheckerService, cp = } //I/System.Console( 1617): { i = 49, cn = com.samsung.android.MtpApplication.MtpService, cp = } //I/System.Console( 1617): { i = 78, cn = com.samsung.android.app.catchfavorites.catchnotifications.CatchNotificationsService, cp = PendingIntent{1f770943: android.os.BinderProxy@6924ca9} } //I/System.Console( 1617): { i = 56, cn = com.samsung.android.app.edge.nightclock.NightClockService, cp = } //I/System.Console( 1617): { i = 59, cn = com.samsung.android.app.galaxyfinder.recommended.RecommendedService, cp = } //I/System.Console( 1617): { i = 53, cn = com.samsung.android.app.galaxyfinder.tag.TagReadyService, cp = } //I/System.Console( 1617): { i = 72, cn = com.samsung.android.app.shealth.tracker.pedometer.service.PedometerService, cp = } //I/System.Console( 1617): { i = 32, cn = com.samsung.android.app.shealth.tracker.sport.livetracker.LiveTrackerService, cp = } //I/System.Console( 1617): { i = 79, cn = com.samsung.android.beaconmanager.BeaconService, cp = } //I/System.Console( 1617): { i = 42, cn = com.samsung.android.health.wearable.service.WearableService, cp = } //I/System.Console( 1617): { i = 70, cn = com.samsung.android.providers.context.ContextService, cp = } //I/System.Console( 1617): { i = 24, cn = com.samsung.android.scloud.auth.RelayService, cp = } //I/System.Console( 1617): { i = 26, cn = com.samsung.android.sconnect.periph.PeriphService, cp = } //I/System.Console( 1617): { i = 29, cn = com.samsung.android.sensor.framework.SensorService, cp = } //I/System.Console( 1617): { i = 64, cn = com.samsung.android.service.health.HealthService, cp = } //I/System.Console( 1617): { i = 14, cn = com.samsung.android.service.peoplestripe.PeopleNotiListenerService, cp = PendingIntent{17538bc0: android.os.BinderProxy@6924ca9} } //I/System.Console( 1617): { i = 77, cn = com.samsung.android.service.peoplestripe.PeopleStripeService, cp = } //I/System.Console( 1617): { i = 28, cn = com.samsung.android.sm.widgetapp.SMWidgetService, cp = } //I/System.Console( 1617): { i = 47, cn = com.samsung.android.thememanager.ThemeManagerService, cp = } //I/System.Console( 1617): { i = 52, cn = com.samsung.appcessory.server.SAPService, cp = } //I/System.Console( 1617): { i = 5, cn = com.samsung.hs20settings.WifiHs20UtilityService, cp = } //I/System.Console( 1617): { i = 41, cn = com.samsung.sec.android.application.csc.CscUpdateService, cp = } //I/System.Console( 1617): { i = 2, cn = com.sec.android.app.bluetoothtest.BluetoothBDTestService, cp = } //I/System.Console( 1617): { i = 31, cn = com.sec.android.app.launcher.services.LauncherService, cp = } //I/System.Console( 1617): { i = 10, cn = com.sec.android.daemonapp.ap.accuweather.WeatherClockService, cp = } //I/System.Console( 1617): { i = 8, cn = com.sec.android.inputmethod.SamsungKeypad, cp = PendingIntent{39a730f9: android.os.BinderProxy@2b45775c} } //I/System.Console( 1617): { i = 46, cn = com.sec.android.pagebuddynotisvc.PageBuddyNotiSvc, cp = } //I/System.Console( 1617): { i = 1, cn = com.sec.android.sensor.framework.SensorService, cp = } //I/System.Console( 1617): { i = 83, cn = com.sec.android.service.sm.service.SecurityManagerService, cp = } //I/System.Console( 1617): { i = 7, cn = com.sec.android.widgetapp.ap.weather.common.appservice.WeatherScreenService, cp = } //I/System.Console( 1617): { i = 11, cn = com.sec.android.widgetapp.ap.weather.common.appservice.WeatherService, cp = } //I/System.Console( 1617): { i = 36, cn = com.sec.android.widgetapp.ap.weather.widget.surfacewidget.WeatherSurfaceWidget, cp = } //I/System.Console( 1617): { i = 33, cn = com.sec.android.widgetapp.digitalclockeasy.DigitalClockEasyService, cp = } //I/System.Console( 1617): { i = 9, cn = com.sec.bcservice.BroadcastService, cp = } //I/System.Console( 1617): { i = 20, cn = com.sec.enterprise.mdm.services.simpin.EnterpriseSimPin, cp = } //I/System.Console( 1617): { i = 87, cn = com.sec.phone.SecPhoneService, cp = } //I/System.Console( 1617): { i = 43, cn = com.sec.spp.push.PushClientService, cp = } //I/System.Console( 1617): { i = 27, cn = org.simalliance.openmobileapi.service.SmartcardService, cp = } //I/System.Console( 5883): { i = 85, cn = com.google.android.gms.backup.BackupTransportService, process = com.google.android.gms.persistent } //I/System.Console( 5883): { i = 86, cn = com.sec.phone.SecPhoneService, process = com.sec.phone } //I/System.Console( 5883): { i = 7, cn = com.sec.android.inputmethod.SamsungKeypad, process = com.sec.android.inputmethod, cp = PendingIntent{e6c79e2: android.os.BinderProxy@181ef173}, describeContents = 0 } //I/System.Console( 5883): { i = 13, cn = com.samsung.android.service.peoplestripe.PeopleNotiListenerService, process = com.samsung.android.service.peoplestripe, cp = PendingIntent{24b00830: android.os.BinderProxy@6924ca9}, describeContents = 0 } //I/System.Console( 5883): { i = 14, cn = com.android.systemui.ImageWallpaper, process = com.android.systemui.imagewallpaper, cp = PendingIntent{135c522e: android.os.BinderProxy@1ced31cf}, describeContents = 0 } //I/System.Console( 5883): { i = 77, cn = com.samsung.android.app.catchfavorites.catchnotifications.CatchNotificationsService, process = com.samsung.android.app.catchfavorites, cp = PendingIntent{2b45775c: android.os.BinderProxy@6924ca9}, describeContents = 0 } // http://stackoverflow.com/questions/7170730/how-to-set-a-control-panel-for-my-service-in-android // The service's description and configuration intent can be set during a service binding foreach (var ss in se) { var cn = ss.cn; PendingIntent cp = ss.cp; // whats a ControlPanel ? // Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.app.PendingIntent.describeContents()' on a null object reference if (cp == null) Console.WriteLine(new { ss.i, cn, ss.rsi.process }); else Console.WriteLine(new { ss.i, cn, ss.rsi.process, cp, describeContents = cp.describeContents() }); // I/System.Console(17713): { cn = AndroidBootServiceNotificationActivity.Activities.NotifyService } if (cn == typeof(NotifyService).FullName) { // cannot find ourself? unless its running startservice.setEnabled(false); stopservice.setEnabled(true); // its running // http://stackoverflow.com/questions/7170730/how-to-set-a-control-panel-for-my-service-in-android // http://www.techques.com/question/1-7170730/How-to-set-a-control-panel-for-my-Service-in-Android // http://alvinalexander.com/java/jwarehouse/android/core/java/android/app/ActivityManagerNative.java.shtml } #region cp if (cp != null) { // could we not infer activity from code from application? new Button(this).WithText( cn ).AtClick( delegate { // http://codetheory.in/android-pending-intents/ try { cp.send(); } catch { } //this.startActivity( // cp //); } ).AttachTo(ll); } #endregion } this.setContentView(sv); //this.ShowToast("http://jsc-solutions.net"); new Button(this).WithText("exit").AttachTo(ll).AtClick( delegate { // will it be logged? System.Environment.Exit(13); // application still visible in tasks? } ); new Button(this).WithText("finish").AttachTo(ll).AtClick( delegate { //this.finishAndRemoveTask(); this.finish(); // will it be logged? //System.Environment.Exit(13); // application still visible in tasks? } ); new Button(this).WithText("finishAndRemoveTask").AttachTo(ll).AtClick( delegate { this.finishAndRemoveTask(); //this.finish(); // will it be logged? //System.Environment.Exit(13); // application still visible in tasks? } ); }
// gateway service process/ event thread / async enabled? public override int onStartCommand(Intent value0, int flags, int startId) { // Options that have been set in the service declaration in the manifest. // http://developer.android.com/reference/android/content/pm/ServiceInfo.html#FLAG_STOP_WITH_TASK Console.WriteLine("enter onStartCommand " + new { flags, startId }); // until wifi changes? var xipv4 = //from n in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() from n in AllNetworkInterfaces let IPProperties = n.GetIPProperties() let c = IPProperties.UnicastAddresses.Count from i in Enumerable.Range(0, c) let ip = IPProperties.UnicastAddresses[i] where ip.Address.AddressFamily == AddressFamily.InterNetwork //let loop = IPAddress.Loopback == ip.Address let loop = IPAddress.IsLoopback(ip.Address) orderby loop select new { n, ip, loop, ip.Address }; //I/System.Console(20546): 5042:0001 { n = ScriptCoreLibJava.BCLImplementation.System.Net.NetworkInformation.__NetworkInterface@37e1894a, ip = { Address = 192.168.1.126 }, loop = false, Address = 192.168.1.126 } //I/System.Console(20546): 5042:0001 { n = ScriptCoreLibJava.BCLImplementation.System.Net.NetworkInformation.__NetworkInterface@3c1830bb, ip = { Address = 127.0.0.1 }, loop = true, Address = 127.0.0.1 } xipv4.WithEach( Console.WriteLine ); var BestGuessHost = xipv4.FirstOrDefault(); Console.WriteLine(" " + new { BestGuessHost }); //var port = new Random().Next(8000, 30000); // cached by cloudflare? //var port = 80; var port = 8080; // https://github.com/NanoHttpd/nanohttpd/blob/master/core/src/main/java/fi/iki/elonen/NanoHTTPD.java var notifyServiceReceiver = new AsyncReplyReceiver { AtReceive = (cc, ii) => { Console.WriteLine("enter onReceive"); //android.content.IntentFilter //android.content.Intent.ACTION_BOOT_COMPLETED int rqs = ii.getIntExtra("RQS", 0); if (rqs == RQS_STOP_SERVICE) this.stopSelf(); if (ii.hasExtra("whats my port")) { // how do we reply? // sharedmemory implementation is missing and useless xipv4.WithEach( Console.WriteLine ); var intent = new Intent(); //intent.putExtra("host", BestGuessHost.Address.ToString()); // did we switch networks? intent.putExtra("host", xipv4.FirstOrDefault().ToString()); intent.putExtra("port", port); intent.setAction(GatewayService.ACTION + "reply"); this.sendBroadcast(intent); } } }; #region AtDestroy this.AtDestroy = delegate { Console.WriteLine("enter AtDestroy"); this.unregisterReceiver(notifyServiceReceiver); // I/System.Console( 8080): onDestroy { xmyPid = 8080 } //I/art ( 8080): System.exit called, status: 42 var xmyPid = android.os.Process.myPid(); Console.WriteLine("onDestroy " + new { xmyPid }); System.Environment.Exit(42); }; #endregion //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = ip6tnl0, Description = ip6tnl0, SupportsMulticast = false, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = rmnet4, Description = rmnet4, SupportsMulticast = true, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = rmnet2, Description = rmnet2, SupportsMulticast = true, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = rmnet3, Description = rmnet3, SupportsMulticast = true, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = rmnet7, Description = rmnet7, SupportsMulticast = true, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = rmnet5, Description = rmnet5, SupportsMulticast = true, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = rmnet6, Description = rmnet6, SupportsMulticast = true, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = rmnet1, Description = rmnet1, SupportsMulticast = true, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = rmnet0, Description = rmnet0, SupportsMulticast = true, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 1, Name = lo, Description = lo, SupportsMulticast = false, InetAddressesString = , ::1%1, 127.0.0.1 } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 2, Name = sit0, Description = sit0, SupportsMulticast = false, InetAddressesString = } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 1, Name = p2p0, Description = p2p0, SupportsMulticast = true, InetAddressesString = , fe80::e850:8bff:fe7d:277c%p2p0 } //I/System.Console( 9390): 24ae:0001 { OperationalStatus = 1, Name = wlan0, Description = wlan0, SupportsMulticast = true, InetAddressesString = , 2001:7d0:8414:3001:ea50:8bff:fe7d:277c%13, fe80::ea50:8bff:fe7d:277c%wlan0, 2001:7d0:8414:3001:b421:4790:ede8:826c%13, 192.168.1.126 } //I/System.Console(15259): 3b9b:0001 { OperationalStatus = 1, Name = lo, Description = lo, SupportsMulticast = false, InetAddressesString = , ::1%1, 127.0.0.1 } //I/System.Console(15259): 3b9b:0001 { OperationalStatus = 2, Name = dummy0, Description = dummy0, SupportsMulticast = false, InetAddressesString = } //I/System.Console(15259): 3b9b:0001 { OperationalStatus = 2, Name = sit0, Description = sit0, SupportsMulticast = false, InetAddressesString = } //I/System.Console(15259): 3b9b:0001 { OperationalStatus = 2, Name = ip6tnl0, Description = ip6tnl0, SupportsMulticast = false, InetAddressesString = } //I/System.Console(15259): 3b9b:0001 { OperationalStatus = 1, Name = p2p0, Description = p2p0, SupportsMulticast = true, InetAddressesString = , fe80::10bf:48ff:febe:6b7d%p2p0 } //I/System.Console(15259): 3b9b:0001 { OperationalStatus = 1, Name = wlan0, Description = wlan0, SupportsMulticast = true, InetAddressesString = , 2001:7d0:8414:3001:a06f:6dfe:8dfc:42b8%6, 2001:7d0:8414:3001:12bf:48ff:febe:6b7d%6, fe80::12bf:48ff:febe:6b7d%wlan0, 192.168.1.211 } // I/System.Console(11408): 2c90:0001 { OperationalStatus = 1, Name = rmnet0, Description = rmnet0, SupportsMulticast = true, InetAddressesString = , 83.187.193.24 } //Implementation not found for type import : //type: System.Net.NetworkInformation.UnicastIPAddressInformationCollection //method: System.Net.NetworkInformation.UnicastIPAddressInformation get_Item(Int32) //Did you forget to add the [Script] attribute? //Please double check the signature! // http://stackoverflow.com/questions/14182014/android-oncreate-or-onstartcommand-for-starting-service var myPid = android.os.Process.myPid(); var intentFilter = new IntentFilter(); intentFilter.addAction(ACTION); registerReceiver(notifyServiceReceiver, intentFilter); Func<TcpListener> ctor = delegate { TcpListener x = null; try { Console.WriteLine("774 TcpListener " + new { port }); x = new TcpListener(IPAddress.Any, port); Console.WriteLine("776 TcpListener "); // signal UI service is yet again available //Console.WriteLine("before Start "); // I/System.Console(25817): 64d9:0001 { err = java.lang.RuntimeException: bind failed: EACCES (Permission denied) } x.Start(); Console.WriteLine("782 TcpListener "); } catch (Exception err) { Console.WriteLine(new { err }); System.Environment.Exit(42); } return x; }; #region TcpListener new { }.With( async delegate { //var l = new TcpListener(IPAddress.Any, port); var l = ctor(); var href = "http://127.0.0.1:" + port; Console.WriteLine( href ); while (true) { //Console.WriteLine("before AcceptTcpClientAsync "); var c = await l.AcceptTcpClientAsync(); // time to do firewall or security? //Console.WriteLine("before yield " + new { c }); yield(c); //Console.WriteLine("after yield " + new { c }); } } ); #endregion var onStartCommand_status = base.onStartCommand(value0, flags, startId); Console.WriteLine("exit onStartCommand " + new { onStartCommand_status }); // I/System.Console( 9005): 232d:0001 exit onStartCommand { onStartCommand_status = 1 } return onStartCommand_status; }
// "x:\util\android-sdk-windows\platform-tools\adb.exe" connect 192.168.1.126:5555 // x:\util\android-sdk-windows\platform-tools\adb.exe logcat -s "xNativeActivity" "System.Console" "DEBUG" // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150513 // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150531 // 01. lets have our service think of a port, and send it back to activity at start. or save into file as cpu does it? // http://developer.android.com/reference/android/os/MemoryFile.html // http://stackoverflow.com/questions/19778196/class-memoryfile-of-any-use // http://stackoverflow.com/questions/15123402/share-memory-between-two-processes-in-dalvik // http://www.slideshare.net/tetsu.koba/interprocess-communication-of-android // http://www.codota.com/android/scenarios/52fcbca7da0a12229fc989b1/android.os.MemoryFile?tag=dragonfly // https://groups.google.com/forum/#!topic/android-developers/r-oqeI7MlJg // http://stackoverflow.com/questions/19778196/class-memoryfile-of-any-use // https://vec.io/posts/andriod-ipc-shared-memory-with-ashmem-memoryfile-and-binder // http://notjustburritos.tumblr.com/post/21442138796/an-introduction-to-android-shared-memory // https://developer.android.com/training/articles/memory.html // http://www.slideshare.net/jserv/android-ipc-mechanism //Action AtActivityResult; //protected override void onActivityResult(int arg0, int arg1, Intent arg2) //{ // base.onActivityResult(arg0, arg1, arg2); // if (AtActivityResult != null) // AtActivityResult(); //} // I/ActivityManager( 475): Killing 7649:AndroidMultiProcTCPServerAsync.Activities/u0a49 (adj 9): remove task //I/ActivityManager( 475): Killing 7627:AndroidMultiProcTCPServerAsync.Activities:gateway7/u0a49 (adj 5): remove task //I/ActivityManager( 475): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.l //W/ActivityManager( 475): Scheduling restart of crashed service AndroidMultiProcTCPServerAsync.Activities/.GatewayService in 16000ms //protected override void onPause() //{ // Console.WriteLine("enter onPause, finishAndRemoveTask"); // // not called on back button? // // keep service running, remove activity // this.finishAndRemoveTask(); // base.onPause(); //} protected override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); var sv = new ScrollView(this); var ll = new LinearLayout(this); // fill the button ll.setOrientation(LinearLayout.VERTICAL); sv.addView(ll); this.setContentView(sv); var activity = this; new Button(activity).WithText("is the service already running?").AttachTo(ll); var m = (ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE); // why limit? var s = m.getRunningServices(0xffff); var a = Enumerable.FirstOrDefault( from i in Enumerable.Range(0, s.size()) let rsi = (android.app.ActivityManager.RunningServiceInfo)s.get(i) let cn = rsi.service.getClassName() where cn == typeof(GatewayService).FullName select new { i, rsi, cn } ); if (a == null) { new Button(activity).WithText("start service").AttachTo(ll).AtClick( delegate { // start the service unless already running? var intent = new Intent(this.getApplicationContext(), typeof(GatewayService).ToClass()); // if the user can swipe us away service is restarted? this.getApplicationContext().startService(intent); } ); } else { } // whats the port? new Button(activity).WithText("which port are we on? " + new { a }).AttachTo(ll).AtClick( delegate { var aa = default(AsyncReplyReceiver); aa = new AsyncReplyReceiver { AtReceive = (cc, ii) => { Console.WriteLine("ui now has the port..."); this.unregisterReceiver(aa); var host = ii.getStringExtra("host"); var port = ii.getIntExtra("port", 0); new Button(activity).WithText("open " + host + ":" + port).AttachTo(ll).AtClick( delegate { var href = "http://" + host + ":" + port; Console.WriteLine( href ); //this.runOnUiThread( // delegate // { var i = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(href) ); // http://vaibhavsarode.wordpress.com/2012/05/14/creating-our-own-activity-launcher-chooser-dialog-android-launcher-selection-dialog/ var ic = Intent.createChooser(i, href); this.startActivity(ic); // } //); } ); } }; var intentFilter = new IntentFilter(); intentFilter.addAction(GatewayService.ACTION + "reply"); this.registerReceiver(aa, intentFilter); var intent = new Intent(); intent.setAction(GatewayService.ACTION); intent.putExtra("whats my port", "?"); this.sendBroadcast(intent); } ); new Button(this).WithText("exit").AttachTo(ll).AtClick( delegate { // will it be logged? System.Environment.Exit(13); // application still visible in tasks? } ); new Button(this).WithText("finish").AttachTo(ll).AtClick( delegate { //this.finishAndRemoveTask(); this.finish(); // will it be logged? //System.Environment.Exit(13); // application still visible in tasks? } ); new Button(this).WithText("finishAndRemoveTask").AttachTo(ll).AtClick( delegate { this.finishAndRemoveTask(); //this.finish(); // will it be logged? //System.Environment.Exit(13); // application still visible in tasks? } ); // [javac] W:\src\AndroidMultiProcTCPServerAsync\Activities\ApplicationActivity.java:56: error: unreported exception IOException; must be caught or declared to be thrown //[javac] class22.m = new MemoryFile("foo0", 100); //// ipc memory referenced //var m = default(MemoryFile); //try //{ // m = new MemoryFile("foo0", 100); //} //catch { throw; } // MemoryFile not available yet. bypass to NDK? workaround to filesystem? // E/AndroidRuntime(28716): Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system) // http://developer.android.com/training/basics/data-storage/files.html // File.WriteAllText(this.getFilesDir().getAbsolutePath() + "/MemoryFile-foo0", "awaiting..."); // new Button(activity).WithText("Next " + // File.ReadAllText(this.getFilesDir().getAbsolutePath() + "/MemoryFile-foo0") // ).AttachTo(ll).AtClick( // button => // { // Intent intent = new Intent(activity, typeof(SecondaryActivity).ToClass()); // intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // // share scope // var myPid = android.os.Process.myPid(); // intent.putExtra("_item", "hello from " + new { myPid }); // //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); // //new Button(activity).WithText("read").AttachTo(ll).AtClick( // // button2 => // // { // // var m2 = default(MemoryFile); // // try // // { // // m2 = new MemoryFile("foo0", 100); // // } // // catch { throw; } // // var pos = 0; // // //var __out = new __NetworkStream { InternalOutputStream = m.getOutputStream() }; // // var __in = new __NetworkStream { InternalInputStream = m2.getInputStream() }; // // // block the ui? // // var ipcByte = 0; // // while (ipcByte == 0) // // { // // ipcByte = __in.ReadByte(); // // button2.WithText(new { ipcByte, pos }.ToString()); // // pos++; // // } // // } // // ); // AtActivityResult += // delegate // { // // if we read too early we get all zeros.. // //var pos = 0; // ////var __out = new __NetworkStream { InternalOutputStream = m.getOutputStream() }; // //var __in = new __NetworkStream { InternalInputStream = m.getInputStream() }; // //// block the ui? // //var ipcByte = 0; // //while (ipcByte == 0) // //{ // // ipcByte = __in.ReadByte(); // // button.WithText(new { ipcByte, pos }.ToString()); // // pos++; // //} // button.WithText( // File.ReadAllText(this.getFilesDir().getAbsolutePath() + "/MemoryFile-foo0") // ); // }; // // cached backgroun process? // // switching to another process.. easy... // //activity.startActivity(intent); // activity.startActivityForResult(intent, requestCode: 0x14); // } //); // //var s = new SemaphoreSlim(0); // ////java.lang.Object, rt // ////enter async { ManagedThreadId = 1 } // ////awaiting for SemaphoreSlim{ ManagedThreadId = 1 } // ////after delay{ ManagedThreadId = 8 } // ////http://127.0.0.1:8080 // ////{ fileName = http://127.0.0.1:8080 } // ////enter catch { mname = <0032> nop.try } ClauseCatchLocal: // ////{ Message = , StackTrace = java.lang.RuntimeException // //// at ScriptCoreLibJava.BCLImplementation.System.Net.Sockets.__TcpListener.AcceptTcpClientAsync(__TcpListener.java:131) // //new { }.With( // // async delegate // // { // // //System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // // //enter async { ManagedThreadId = 1 } // // //awaiting for SemaphoreSlim{ ManagedThreadId = 1 } // // //after delay{ ManagedThreadId = 4 } // // //http://127.0.0.1:8080 // // //awaiting for SemaphoreSlim. done.{ ManagedThreadId = 1 } // // //-- // // //accept { c = System.Net.Sockets.TcpClient, ManagedThreadId = 6 } // // //System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // // //accept { c = System.Net.Sockets.TcpClient, ManagedThreadId = 8 } // // //{ ManagedThreadId = 6, input = GET / HTTP/1.1 // // // jump back to main thread.. // // s.Release(); // // } // //); }
// test via // X:\jsc.svn\examples\javascript\chrome\apps\ChromeUDPSendAsync\ChromeUDPSendAsync\Application.cs // how do we know its running? // x:\util\android-sdk-windows\platform-tools\adb.exe logcat -s "DEBUG" "System.Console" // "x:\util\android-sdk-windows\platform-tools\adb.exe" connect 192.168.1.126:5555 // https://github.com/opersys/raidl // http://stackoverflow.com/questions/6274141/trigger-background-service-at-a-specific-time-in-android // http://stackoverflow.com/questions/7144908/how-is-an-intent-service-declared-in-the-android-manifest // http://developer.android.com/guide/topics/manifest/service-element.html //AtBootCompleted hack1; protected override void onCreate(global::android.os.Bundle savedInstanceState) { // http://developer.android.com/guide/topics/ui/notifiers/notifications.html base.onCreate(savedInstanceState); var sv = new ScrollView(this); var ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); sv.addView(ll); #region startservice var startservice = new Button(this); startservice.setText("Start Service"); startservice.AtClick( delegate { startservice.setEnabled(false); //this.ShowToast("startservice_onclick"); //var intent = new Intent(this, NotifyService.Class); var intent = new Intent(this, typeof(NotifyService).ToClass()); this.startService(intent); // http://developer.android.com/reference/android/app/Activity.html#recreate%28%29 //this.recreate(); this.finish(); } ); ll.addView(startservice); #endregion #region stopservice var stopservice = new Button(this); stopservice.setText("Stop Service"); stopservice.AtClick( delegate { this.ShowToast("stopservice_onclick"); var intent = new Intent(); intent.setAction(NotifyService.ACTION); intent.putExtra("RQS", NotifyService.RQS_STOP_SERVICE); this.sendBroadcast(intent); // seems stop takes a while //Task.Delay(100); Thread.Sleep(30); this.recreate(); } ); ll.addView(stopservice); #endregion stopservice.setEnabled(false); // http://stackoverflow.com/questions/12891903/android-check-if-my-service-is-running-in-the-background var m = (ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE); Console.WriteLine("getRunningServices"); var s = m.getRunningServices(1000); Console.WriteLine("getRunningServices " + s.size()); var se = Enumerable.Range(0, s.size()).Select(i => (android.app.ActivityManager.RunningServiceInfo)s.get(i)); foreach (var ss in se) { var cn = ss.service.getClassName(); Console.WriteLine(new { cn }); // I/System.Console(17713): { cn = AndroidServiceUDPNotification.Activities.NotifyService } if (cn == typeof(NotifyService).FullName) { startservice.setEnabled(false); stopservice.setEnabled(true); // its running // http://stackoverflow.com/questions/7170730/how-to-set-a-control-panel-for-my-service-in-android // http://www.techques.com/question/1-7170730/How-to-set-a-control-panel-for-my-Service-in-Android // http://alvinalexander.com/java/jwarehouse/android/core/java/android/app/ActivityManagerNative.java.shtml #if XCONTROLPANEL PendingIntent cp = m.getRunningServiceControlPanel(ss.service); Console.WriteLine(new { cp }); if (cp != null) { #region cpb var cpb = new Button(this); cpb.setText("ServiceControlPanel"); cpb.AtClick( delegate { //new Intent( //PendingIntent.getActivity( //startActivity(cp); // http://iserveandroid.blogspot.com/2011/03/how-to-launch-pending-intent.html Intent intent = new Intent(); try { cp.send(this, 0, intent); } catch { throw; } } ); ll.addView(cpb); } #endregion #endif } } this.setContentView(sv); this.ShowToast("http://jsc-solutions.net"); }