How to manage Xamarin forms app resuming from background on Android? - java

I have a Xamarin forms app that starts some processes to run a Bluetooth communication in the background.
The app works normally when it is sent to the background.
When I get it back in the foreground it kind of opens again and I don't know how to manage this situation.
When I press back for a split second I can see the previous instance of the app before it shuts down.
Any clue would be very much appreciated.
Thanks in advance!

Shiny is a robust new nuget package that makes managing backgrounding easy. Its a pretty complicated thing to do otherwise if you want to do it properly. The Nuget package also supports Bluetooth
The developer of Shiny also an MVP, Allan Ritchie presented Shiny at the Toronto. Net mobile developers meetup event, here's a video of it.
There's also a lot of examples for Bluetooth usage here. As you can imagine, Bluetooth & Backgrounding are two separate behemoths by themselves, so this helps unify and simplify them.
That said, he needs help with documentation, so please feel free to update us with how you used it!

Related

How do I go about implementing a monitoring app

I am trying to build a monitoring app using LUA in corona labs. I was wondering how I would go about doing that.
Background: the app should notify the user when there is another app or outside third party accessing the camera/microphone.
I'm thinking trying to get access to the devices resource manager and it notify the app when the camera and microphone is being used.
I haven't come across anything like this before. Am I on the right path? Or am I way off? How would you go about doing this?
I'm not expecting a definite answer, just a nudge in the right direction :)
In general this kind of behavior is not what Corona is designed for. You would likely have to use native tools, or Corona native if you want to use corona for your UI, to access this kind of data.
There is an interesting discussion about how it can be done in Android here How to check whether microphone is used by any background app, hope it helps!

Android development: Access to the activities of other apps

Is it allowed in Android that developers can access the activities of other apps? For example, can my app get triggered when some other app is put from foreground to background or the other way around?
I checked some websites, they mostly talked about how to manage the activity of your own app....I've read someone's article saying there was an API allowing developers to monitor other apps but it was banned after Android5.0.
So please help! I really have no idea if it is possible...Thank you!
Not without access to the framework can you do this. Android was meant to have isolated processes so that this can be avoided. The only thing you can do is launch someone's else's activities should they follow certain criteria. But once it is launched, its under the process of the app you launched, not yours. You should NEVER be able to take control of someone else's process unless they allow you to via some hooks.
One hacky and error-prone ways is to monitor logs and check which activities are launching.. but this is horribly inefficient.
Have a look at my answer here # https://stackoverflow.com/a/35594313/529691

Ideas for my app that runs in the background

I'm developing an app that runs in the background that essentially snaps a front facing photo every time the phone is successfully/unsuccessfully unlocked. This isn't an original idea, but I'm developing it as a final project for my college android programming course, with no intent to sell this app. I have a general idea how I am going to go about this via some research but I keep running across a problem.
I know that it is hard and bad practice to run an app continuously in the background, so the idea is you put the app to sleep and set an alarm. My problem is that if the would be phone-snooper were to get really lucky, they could access the phone in between the alarms, and the owner of the phone would never know. I talked with my professor, and he proposed a couple ideas, but we could not come up with a definite solution, so I'm asking opinions here. Any idea how to subvert this dilemma? Thanks a ton.
Your approach is probably not appropriate for the problem. You can't "time" unpredictable events (like someone attempting to unlock a phone). Or else it's not clear how you are setting the alarm.
You should change the approach to an event-based approach.
Either provide a service for a lock-screen app so that it can use your code to capture a pic by sending login attempt events to it. You write that and provide an SDK/API.
Or else create your own lock screen app with your feature:
https://stackoverflow.com/questions/10864300/create-a-lock-screen-of-my-own

Java ME on Siemens CX70

I have very old Siemens CX70 in working state and just don't want to throw it out. My idea is to use its math power and peripherals (GSM module, USB, Camera and screen) to build some simple applications for home use (multichannel termometer, timer and cheap security system - for examples).
I know I should use Java ME and IDE (I love Netbeans, for example). Can you tell me what I need more to start developing? I know Java well, I just need to make an environment to developing, debug and deploy. Mobile library documentation will be very helpful too.
Thanks.
There are so many online tutorials about this topic that the only right thing to do is to refer you to google.com
Search after "getting started with j2me".
However, there's something else you should know upfront before getting too excited.
The security model in JavaME will prevent you from doing much useful stuff, in relation to some of the things you mention.
Every time you try to access certain things in the phone, like e.g. the camera, or send SMS, or read/write a file on SD card, etc etc - the phone will show a popup "This app is trying to access camera. Allow this?". And the app will only continue after a manual click on Yes.
As you can imagine, this of course renders a lot of ideas useless.
In order to prevent these popups, you can sign your app with a certificate you buy from Thawte or Verisign. But as that'll cost you $300 a year, it's not the way most sparetime hobby developers chooses.
Personally, I found another way, but it requires you to use a phone from Sony Ericsson.
Because the old Sony Ericsson phones can be patched in order to remove the Java security. After doing this on one of my old phones, I've been having fun making apps like the ones you mention. For example, an app that keeps an eye on my home when we're out, by taking a picture every second. If it detects a difference in the picture, it sends me an MMS with the picture. :-)
I have searched a long time for patching options for other brands, but I just can't find anything useful. Nokia should supposedly also be patchable, but I just can't find anything useful about it.
So in short: If you'd like to make some sparetime hobby apps on a phone like that, you should either find a Sony Ericsson phone and patch it - or go dig up an old used Android device.
Good luck.

Video training program

I am looking to create a video training program which records videos - via webcam, user screen capture and captures sound. Now the main problem is that I need a cross-platform (mac and windows) solutions.
I know its possible to use flash to record webcam + audio. But its not possible to record the user's screen via flash.
So am wonder if I should use Java (which i believe will work on mac & windows). I do not want to develop to separate versions because of the cost involved in developing two versions.
Please guide me as I am new to this.
Thank you.
UPDATE
Hello again,
I had a look at the following site: www.screencast-o-matic.com or www.screentoaster.com. I see that they have developed a java applet which helps interact with Windows/Mac to record the screen.
I am wondering how to go about developing something like that and integrating it with Flash (for webcam and audio recording).
Is this a better idea?
This is not an answer to your question, but I strongly recommend against using video for educational programmes. Our company delivers university courses on-line, and we long ago learned that video feeds are only effective under particular scenarios. In general, a talking head is a waste of bandwidth. You're much better off to put together a well designed powerpoint presentation, record a voice-over (and edit it!) and then assemble the whole thing as a flash presentation. This is a non-trivial amount of work, but it provides a much more interesting product for the student.
When to use video:
1) When you are demonstrating something dynamic - Mechanics or Chemistry for example.
2) When you are acting out a scenario or case as an illustration -- For example, threat de-escalation techniques for high school teachers.
When you solve the screen recording problem, seriously consider whether you need full motion or if you can get away with stills. Often the motion is distracting, and a still with good voice over can be more effective. (Hint: Replace mouse pointers with something HUGE before recording -- Like Fox did with hockey pucks)
Try CamStudio. I don't know, if it works on Mac, but on windows, it's the best solution I know. It's open source, so you can use it's source code, if you want to :)
If you're looking to build an application that does all of the recording and screen capture itself, then you might consider using Adobe AIR (essentially, Flash running on the desktop) in combination with Merapi. Merapi is essentially a bridge between Adobe AIR and Java. So for example, for your project, you might use Java to handle the lower-level (but still cross-platform) stuff you can't do natively in AIR, and use Merapi to wire the Java application to your AIR UI.
This is by no means a simple project. Lets get that said and out the way. There are open source (and cross-platform) options for each element, but nothing (I know of) that will do everything for you.
I think the "cleanest" option would be to use Flash for webcam and audio, as you said, and run a VNC server to send the screen video... The only closed-platform code will be the VNC launching code. That should be pretty simple to maintain!
That raises a problem because most people are behind NAT firewalls these days. Setting up port forwarding is a pain in the behind. I've used an app called Gitso before which allows people to connect to me and send their desktop to my screen (for tech support). Its VNC-based and all it really does is add another layer on top of the VNC connection so rather than me connecting to them, they connect to me. That makes the whole business of port forwarding a non-issue.
And once you've recorded everything, there's the final issue of syncing it all back together... Might not be so hard.
Well, Camtasia provides the solution to get your problem done. It can record the onscreen activity and also the webcam video and put them in the same player template. Another screen recorder DemoCreator can publish the screen recording as Flash movie, but can not record the webcam.

Categories