I am working on an Android application that uses Bluetooth to communicate with a nearby PC.
The app works greatly on my own device (Samsung Galaxy Note 3 - CM 12.1) but on of my beta-testers it does not.
Simply put the app allows people to write and receive SMS from their
PC (with my C# WPF app) via Bluetooth & their phone.
My beta-tester is using a Samsung Galaxy Note 4 stock ROM (Lollipop).
At first I thought when his screens turned off, Android would kill the MainActivity which holds on a few threads including the one maintaining the connection alive (with a inpustream.read() blocking method). Such behavior does not occur on my own device : I could keep the connection alive for a whole night without plugging my phone.
I was warned, though, that using services would avoid such problem because Android does not behave the same way from one device to another. So I updated my app and made my MainActivity use my MainService to spawn the relative threads. But it did not change a thing.
As my title suggests, the problem lies with his antivirus and more precisely : AVG.
I have no knowledge on how such antivirus work on Android and I don't even use one. By freezing AVG with Titanium Backup on his rooted Galaxy Note 4, my app stopepd crashing and is now working perfectly well as intended.
So I wonder, how come AVG deciced to kill my app when the device screen turned off?
How should my app behave so that this won't happen with any other users using AVG or any other antivirus ? What should I do so that my app does not look as a suspect ?
I don't know exactly what the AVG did to your app.But I think that AVG may don't let your app force to turn on the bluetooth or use the Bluetooth when Android device is sleep or send/receive SMS.The AVG is one kind of antivirus apps that most of them have lots of permission request limited or power saving strategy,especially on rooted Android devices or the first part app already in the Android ROMs.
Try to make clear that what's the real point AVG did to your app.And then try to solve your problems with gentle and smart.
For example:
1.If the AVG doesn't let you use BluetoothAdapter.enable() to force to turn on the Bluetooth, try to use Activity.startActivityForResult() to let users to choose whether turn on Bleutooth or not.
2.If the AVG doesn't let you use Bluetooth when the Android device is sleep.You can try to use WakeLock.acquire() to hold the Android device.
3.If the AVG doesn't let you use SMS sending or receiving.You can changed another communication protocol, SPP or BLE or something else.
Maybe you have heard Xiaomi.If you are an Android Developer in China,because Xiaomi is very popular in China,you must deal with the adaption with Xiaomi,and then you will find that Xiaomi is really fucking for Android Developers in China.
Xiaomi doesn't some really amazing things to the original Android.For example:
1.
AlertDialog..getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
you can't alert the TYPE_SYSTEM_ALERT dialog on some xiaomi ROMs that they tell you nothing.
2.Xiaomi has modified lots of original themes.
3.Xiaomi has changed the Android alarm timing mechanism while the device is sleep which is called Wake-Up-Alignment.This is really terrible for the apps that with the function of timing.
The above problems are that I met in Android development, some problems I can resolve it, some you don't have any chances to change it.
Remember that:The adaption with Android devices is that you must make your users know you app works on most of the popular Android Devices,the developers try to make the app run on most Android devices,but it maybe not work on some Android devivces with customized ROMs or with some special third part apps.That's it ,that's true, that's Android.
If the problem can't be solved,it's not a problem!
Related
I've developed a couple of Enterprise iOS apps for our users in the field. Some have expressed a preference for Android devices over Apple, and I fully understand. I do not have an Android phone, nor do I want to get one and have a second account to maintain. I'm wondering if I can use an inexpensive Android tablet to reliably test an application that will ultimately be running on an Android phone? The app will need to communicate via internet to a server via cell connection or wifi.
Also, any advice for an Android newbie developer would be appreciated.
Yes you could test on a Android tablet but it would be hard to see how it render on a phone.
You could also use the Android Emulator to test different size and android configuration.
Yes. I developed my first major Android app using only a couple of cheap tablet devices. It's fine; the only thing you can't really test is "what happens to my app when a phone call comes in." Plus if you can get the emulator working under HAXM, or some other similar setup where it doesn't work like a tortoise trapped in amber, you can test on a variety of simulated devices perfectly well.
Other things to consider:
You'll probably want to test your app on a variety of different hardware and Android versions, in particular I'd recommend testing on older devices. This means that you friends' old Android phones are a great source of cheap test devices. I regularly gather phones from friends that would otherwise just end up lingering in the back of a drawer as a "spare" that will never actually get used. Bear in mind that you can use all the features of a phone apart from the actual phone bit without a SIM, including a WiFi-based data connection.
You may find that you can find good, contract-free "pay as you go" phone SIMs. I use a provider whose "credits" don't expire, so I have a phone connection for my test devices where there's no ongoing cost, apart from the actual calls I make when testing.
Every now and then, the radio of my android phone silently dies because of some network related issues.
On the Nexus 4, it shows the empty triangle as if there where no service available in this area. On other phones it does not even do that. It looks like signal is fine.
Anyway, after the radio died silently no phone call / text message / data is going through in any direction.
The only hint I get from the System is the android.net.conn.CONNECTIVITY_CHANGE broadcast fired when the signal dies and wifi is not connected.
The only thing, that fixes the problem is restarting the phone.
Finally my question:
Does anybody know how to restart the radio completely by code?
I mean, it is a separate image running on a separate CPU. There must be a way to reboot it without rebooting the phone.
Maybe there is something, I can path into the Android ROM. I'm running CM here and be happy to patch it (again).
I tried fixing it by launching a system app by pressing *#*#4636#*#* on the dailer and stopping the radio and starting it again. But it did not help at all.
I recently made an app that checks the radio every time the connection changes. It shows a simple notification that tells me, I should reboot my phone. [1]
Issues reproduced on:
LG Nexus 4
Samsung ACE 2
multiple Apple iPhone 4*
Issues not reproduced on:
Apple iPhone 5
All phones running in the Dialog.lk network.
[1] https://github.com/felixb/network-checker
On a rooted device, one can issue the pkill command for all processes running as the user radio. I tested this on a Oneplus 3. The system seems to immediately restart the service:
pkill -u radio
Yes it is possible, but it will be difficult to perform on device without a deep understanding of the modem communications code of which multiple versions exist and even that will be dependent on if the system will permit you to even perform the communications on device.
The only one I am aware of that you can fully manipulate on device at this time is Qualcomm's (Qualcomm is standard in the majority of devices, but Samsung has used VIA in some cases which is a whole different monster, and even still another chipset or two exist), but to even be able to perform what your asking with Qualcomm's chipset, the following must be true:
The device must be rooted.
The application must have root access.
The system ROM must have the ability to place the cellular radio into modem diagnostics mode.
The device must have the appropriate permissions to permit the access.
At this point most people would connect their computer to their device and manipulate the cellular radio using QPST, CDMAWare, or QXDM. Options available to those users include everything from manipulating cellular subscriber data to restarting the cellular modem.
But, this is where things get tricky, you need to be be able to access this from the device side, which depending on the device, the operating system, and the configuration of it...may very well not be possible.
Also your application must be able to communicate with the cellular radio using the special protocol that the applications above use to do their communications which will require you becoming intimately familiar with that specification. The whitepaper for the Qualcomm diagnostics protocol is floating around on the web if you look hard enough for it.
Also on the not so cool side, if your application has access to the radio...so does any other rooted application (or even non-rooted, if you don't set the device permissions correctly) thus enabling rouge applications the ability to change your radio's configuration data potentially even bricking your device (which I have seen people do using the applications named above).
So my answer is Yes, you can do it, although:
Depending on your device you may not be able to, you should be well prepared to study and develop the needed tools to perform what you are wanting to do
No quick-start guide exist to be followed
Remember that you do so in the knowledge that your device could potentially be bricked either by a mistake in your coding or by a rouge application.
Rebooting the radio, as you have done in the device menus, may not help your problem, you may still require a device reboot
My advice is to use a much easier method and include a timer with automatic reboot in your current application, it is much safer, won't brick your device, and you won't have to become a cellular engineer to figure out how to accomplish it.
Your timer could begin counting down when the radio dies, and provide you an option to stop the reboot if your doing something important, otherwise it would restart your device and all would be ready when you reached for it to make a call or check your email.
Hopefully I was able to help, even though I know this is not the answer that you wanted.
Side note, if you could hijack Android's system configuration menus from an outside application you could potentially manipulate the radio state using the same methods used in Android...but you already discovered that restarting the radio in this method does not help your situation. Plus Android is designed to prevent such manipulation to prevent malicious applications from overtaking the UI of other apps and the system.
Instead of shelling out ~$600+ for an unlocked Android development phone device can you use a used phone that is not connected to any wireless carrier?
I see Android phones for sale on Craigslist all the time that people want to get rid of whenever they get an upgrade. They are usually a year old at least but as long as it is in working order that's okay with me.
Are there any downsides to this? Can you use these phones as legit development devices? Are they crippled or anything if they are disconnected from a carrier? They can't make calls or send/receive text messages obviously. But as long as you can use them with a WiFi connection it seems like you'd be able to test quite a bit.
Precisely what you said. You can't make calls/receive texts, but for development it's good enough. Don't know actually if Market will work, but you will find out soon enough.
The only thing that comes to mind is that locations are often provided by carrier networks. You will then need to be connected with WiFi or use GPS to find your locations.
The emulator works pretty well and then you wont need an actual phone. Unless of course you want access to the sensors. Even then you could use the monkey tool to simulate sensor input.
You can use any android phone for your development. So far all the phones I have ever seen has a development menu under preferences. As long you enable debugging and installing unknown apps it should be fine. For full system access you would need rooted phones, it does not matter if the phones is locked to a carrier or not.
Although you can develop on the emulator, you might fail because of the mobile network speed, device io and touch sensitivity. It is best to at least test on a device before publishing. Meanwhile most modern phones run faster than the emulator so if you are ok on emulator you should more than ok on the real device.
I work with several no-contract/no-sim phones with no problem. My first dev phone was a used T-Mobile myTouch 3g (that I bought on Craigslist). The great thing about T-mobile is that you can pop in a pre-paid SIM and get 3g data when you need it for $1.49 per day.
We want to place a device in a store that operates as sort of a kiosk device. As in customers walk up to it and start interacting with our custom app. The app could be developed for Android or the iPad, so I'm trying to decide which one to use and would like comments on the following ideas:
Is it possible for Android or iOS to access services over the USB port? This would enable us to disable the network.
Is one particularly better for 24 hour always on?
I like the iPad as I think its supply will be more constant as we move forward and need to replace devices due to ones gone bad. Also, our app will probably work on future generations of the iPad. With Android, I'm not sure there will be that sort of consistency from the tablet vendors.
Kiosk mode? I think with the iPad by putting it in a kiosk case that removes access to the home button and turning on the restrictions we'll get what we want. What about Android? I'd rather not have to get into rooting devices and replacing their firmware.
Remote control? Any way to remotely control iOS or Android in a standard means? Our app will be a client to a master server which will obviously be able to control the app somewhat (when used purely as a display device to a customer, controlled from behind the counter).
My feeling is that neither Android tablets or the iPad is best suited for this. Are there other options?
I will try to answer your points, but know that I am probably biased towards Android, because that is where my experience lies.
With Android 3.1+, at least with the Xoom, you have full USB host capabilities. Things like USB flash/hard drives, keyboards, mice, even digital cameras, all work. If you need custom interop with a USB device, you could go as far as to write a driver for it.
24 hour always on is not good for any device with a battery, but neither is better in this situation.
While android apps are forward-compatible, bad programming practices and/or deviations from "vanilla" Android software and hardware CAN break forward compatibility. That being said, if you grab a Google Experience device like the Xoom, you won't meet as many surprises.
In Android 3.0, the navigation bar is built-in at a low level, and it is not possible for apps to remove it. Therefore, it is trivial for anyone to break a "software nanny."
I know that it is possible to control android devices remotely, but without knowing your specific needs, I can't really offer more information than that.
Good luck!
iPad NOOO believe me I am a convert to Apple for my home and business but when we went to launch kiosk the iPad FAILED Big Time.. Here are a couple of little (Big) issues we ran into.
If the device reboots you cannot auto launch you iPad app since Apple does not allow that.
There is a serious memory leak in the iPads browser. We were running javascript / CSS3 and it cratered intermittently. I literally spent 2 hours "today" on the phone with Apple getting the MAJOR run around. I finally said let me speak to an Enterprise Sales Manager as my project could mean thousands of iPads and I got NO WHERE. One Apple employee even told me they don't have enterprise sales managers.
If those weren't enough even though we are just in the proof of concept phase, we are already getting request for other options. These other options are going to require access to the OS which Apple yea right. We are moving to Android immediately.
Sorry Apple I love you but you loose here.
If your using an Ipad you should consider if it can support the power for the USB thing. Watch this Using Powered USB Port
Your idea about putting the tablet behind another piece of glass/plastic is neat. To then deal with remote controlling, you might consider doing some Bluetooth programming.
My mobile development has been primarily with iOS, so I am biased toward that SDK. I will mention that the data/sync/charge port for iOS has (I believe) never changed. Your Gen 1 iPhone sync cord works on your iPhone 4... and your iPad or iPad 2. So, in terms of third party hardware, you may see more consistency with Apple.
I haven't found a good answer regarding whether it is easier to do Bluetooth programming for iOS or Android, but I think to stay cost-effective, you might see which one is more open to third-party devices. Here is an SO post/answer about iOS and third-party Bluetooth devices; I've not found anything on Android regarding third-party Bluetooth remotes, but considering a lot of hardware running Android is third-party, your chances from a naive perspective seem pretty good. Here's the Android Bluetooth API.
Buying an iOS or Android handheld to remote control an iOS or Android tablet does seem a bit steep, but then again, maybe not. Cost also depends on your ratio of remotes to tablets. 1:1? 1:N? N:1? N:M?
The lowest end iPod goes for $229 as of May 20, 2011. Android does have more variety in terms of hardware. You may be able to get a cheap Android phone with no service plan to act as a Bluetooth remote for an Android tab.
I have provided a solution for the kiosk mode using iPad here Lock-down iPhone/iPod/iPad so it can only run one app
I am afraid that I don't really know for Android if the same thing is possible.
To address the issue of crashing applications you can use an exception trampoline (see discussion here https://blog.compeople.eu/apps/?p=275) to catch the crash and reboot your app.
If the entire device is restarted however then other apps that are on the device can be started and will subsequently be locked in.
To answer your other points:
You can use a configuration profile to control network access. Force it to use a VPN or Proxy that only allows your custom app with embedded credentials to use. That way other network access can be prevented.
Your concern over future compatibility is spot on. The Android marketplace is so fragmented then maintaining a fleet is difficult.
If you have an app that is behaving as a server and is locked in then remote control is possible.
We manufacture tablet kiosks that support both android and iPad devices. In fact we are the only iPad kiosk that has achieved apple approval.
Generally speaking i think you will have an easier time with an iPad as the software and hardware will remain more consistent over time. Which is important if you have to change out a fault unit or deploy more kiosks 6 months or year from now when the original device is no longer manufactured.
I started developing android applications. And am testing with the android emulator. Do I really need android phone before releasing it for public usage?
Short answer No. You can test and build a android application package with the SDK and an emulator. But I would say there are usually many things which it would be wise to test on a device.
Personally I have noticed that the emulator does not give a good indication of response times for UI controls. It is usually necessary to move functionality which has long processing times into background threads to maintain user interactivity without the 'force close' pop-up. Testing the effectiveness of your UI responsiveness must be done on a phone to be meaningful.
Network connectivity is another aspect which can be vastly different on a phone, 3G or wifi.
Device sizes and Android platform versions can be tested effectively on the emulator.
Some phone allow hot-swapping of the SD card (replacing the SDcard without turning off the phone). I am not sure how to replicate this on the emulator.
There may be many more things which may only become apparent when using your application on a real device. I would strongly suggest to always test under real conditions when feasible for any commercial project.
From a technical perspective there's no reason why you can't develop purely on the emulator. You're not going to be able to test on every available device, so there's always going to be possibility of device specific bugs that you've missed.
However, I'd strongly recommend getting an actual phone to test your application on.
For me the biggest difference between an actual device and the emulator is the difference between using the interface with your fingers and using a mouse. Interactions which make sense in the emulator sometimes don't work as well when you start using touch on the screen. So if you develop purely on an emulator you'll won't lots of little improvements to your UI that would obvious when you used your app on a phone.
You can't feel a real app in your hands until you have a real phone. (I'm telling you as an Android developer)
So, developing w/o real phone is possible, but real phone gives you a lot more experience, fun & usefulness.
It depends on what type of application you're developing, for serious ones you need at least one device to test it on. For complex applications you would need a range of devices, for example with or without hardware keyboard, different navigational button etc. For basic, simple applications you'll probably do fine with just the emulator.
I would imagine with games you would definitely need to test on real devices.
Thanks to you all. I am going to get HTC Legend and test it, so that I can hope that my apps can be used by others :)
You guys suggest me HTC Desire or HTC Legend?