I wrote a Cordova application with a TTS provided by translation google REST services, that are no more available (from today I suppose) because they require a captcha to work. I have some questions about this:
- is possible to pay for the service? (Google translate API V2 don't seem the answer ...)?
- does Android text-to-speech work without internet?
- is there a Cordova plugin to connect this service?
- is it available something like this for iOS?
I will talk about the last question you asked. Yes there is offline TTS service for iOS. It's AVSpeechSynthesizer.
NSString *ttsString = #"Hello Bangladesh";
NSString *language = #"en-US";
AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance
speechUtteranceWithString:ttsString];
utterance.rate = 0.5f;
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:language];
[synth speakUtterance:utterance];
You can see the list of language codes.
for(AVSpeechSynthesisVoice *voice in [AVSpeechSynthesisVoice speechVoices])
{
NSLog(#"%#", voice.language);
}
I wanted to make a comment but my reputation is not enough. You can use SpeechRecognizer. It supports offline TTS utility for couple of languages including English, but not for all.
Actually it is both online and offline. If device is connected to a network then it uses online recognition communicating with Google servers. If device is offline then it uses offline package which is installed on the device.
Related
I'm trying to provision a device with QR code method according to these documentations.
I'm using this Google collab quickstart guide to do so.
Right now, I'm stuck here:
enrollment_token = androidmanagement.enterprises().enrollmentTokens().create(
parent=enterprise_name,
body={
"policyName": policy_name,
"qrCode": "{'android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME': 'com.tmp.app.admin/.AdminReceiver','android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM': 'MUQ6NEQ6MDQ6NTY6M0E6ODA6Mzg6NEY6NUM6ODI6Qzk6NUY6MkM6QjA6RTk6RDc6QTM6RjI6NDg6NTA6QTQ6RjY6QTA6RjM6MTA6NUM6MzI6NkY6QkU6NUI6M0E6Qzk%3D','android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION':'https://myurl-stuff.com/link_part/my_app.apk','android.app.extra.PROVISIONING_SKIP_ENCRYPTION': false,'android.app.extra.PROVISIONING_WIFI_SSID': 'MY_WIFI_SSID','android.app.extra.PROVISIONING_WIFI_PASSWORD': 'my_wifi_password','android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE': 'WPA'}"
}
).execute()
json.dumps(enrollment_token, indent=2)
Whenever I run this code, the output is the following.
{\n "name": "enterprises/LC00y54m79/enrollmentTokens/UV4yLfxoyWSln7CArwtp7OJQiHH_Gvc76JttPa4-r48",\n "value": "ZBNWPOWHBQUPNLMBTNRU",\n "expirationTimestamp": "2023-02-06T12:43:34.634467Z",\n "policyName": "enterprises/LC00y54m79/policies/policy1",\n "qrCode": "{\\"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME\\":\\"com.google.android.apps.work.clouddpc/.receivers.CloudDeviceAdminReceiver\\",\\"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM\\":\\"I5YvS0O5hXY46mb01BlRjq4oJJGs2kuUcHvVkAPEXlg\\",\\"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION\\":\\"https://play.google.com/managed/downloadManagingApp?identifier=setup\\",\\"android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE\\":{\\"com.google.android.apps.work.clouddpc.EXTRA_ENROLLMENT_TOKEN\\":\\"ZBNWPOWHBQUPNLMBTNRU\\"}}"\n}
It is the default Google example and it does not contains my application, instead, it contains Google's official example app.
What am I doing here wrong?
EDIT:
I have syntax error with double quotes.
EDIT 2:
Also tried with starting and ending single quotes like:
'{"android.app.extra (...)
Also tried with starting and ending with triple quotes like in Google's previous example like here:
But still no luck.
The api either returns a syntax error or simple doesn't returns with my app/parameters in the qrCode, instead it replaces to their own example project.
EDIT 3:
Tried like this:
But with no success:
There are two ways to manage devices :
Provision a device with your own DPC : Your DPC is installed (referenced by an URL in the QR code). It fetches policies from your servers and applies them as a profile / device owner, without using any Google API (Android only).
Manage devices using Google Play EMM API. It is basically Google's layer on top of the Android API (but often called Android Management API, which is a bit confusing) : Your EMM console send policies to Google's servers. They are applied on the devices by Google's own DPC.
You are trying to mix the two approaches. It is no longer possible :
Android Enterprise is no longer accepting new registrations for custom device policy controllers (DPC) using the Google Play EMM API.
All new EMM solutions should now use Android Management API, which comes with its own DPC provided by Google.
The Google DPC is the com.google.android.apps.work.clouddpc you are seeing in the generated QR code.
If you want to use you own DPC, you need to use the json containing the android.app.extra.PROVISIONING* keys directly, without wrapping it in a Google token.
The content looks fine except the SSID has to be quoted, and the signature hash should not be percent encoded :
{
"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "com.tmp.app.admin/.AdminReceiver",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "https://myurl-stuff.com/link_part/my_app.apk",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM": "MUQ6NEQ6MDQ6NTY6M0E6ODA6Mzg6NEY6NUM6ODI6Qzk6NUY6MkM6QjA6RTk6RDc6QTM6RjI6NDg6NTA6QTQ6RjY6QTA6RjM6MTA6NUM6MzI6NkY6QkU6NUI6M0E6Qzk=",
"android.app.extra.PROVISIONING_SKIP_ENCRYPTION": false,
"android.app.extra.PROVISIONING_WIFI_PASSWORD": "my_wifi_password",
"android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE": "WPA",
"android.app.extra.PROVISIONING_WIFI_SSID": "\"MY_WIFI_SSID\""
}
You just have to generate a QR code containing this content (with any generator), and scan it with the device.
Unfortunately the provisioning process is not forgiving. If something is wrong, the device shows a "Provisionning failed" error message without any clue. You have to triple check everything.
I have a Vision API Barcode scanner logic which is based on play-services-vision:17.0.2 to scan barcodes and QR codes. This is working on most phones apart for the users in the China region where play services and stores are disabled.
So, I need to find a way if Vision API is allowed or not and make a switch to either use full-fledged Vision API or fallback to the minimal feature of ZXing library.
For this, I tried googleApiAvailability.isGooglePlayServicesAvailable(activity)
and included com.google.android.gms:play-services-base:17.1.0.
However, after installing the app I am receiving a message that "to open the app Play services and Play store apps are required". How can I address this?
Is there any other way to find out and make the proper switch of features or maybe better ways to handle this?
Thank you...
I found this code snippet in another question and it helped me.
try {
packageManager.getPackageInfo("com.google.android.gms", 0);
// - >Installed
} catch (PackageManager.NameNotFoundException e) {
// -> Not installed
}
I'm making a pair of website-based apps for both Android and iOS interfaces, and I'm struggling with a part of it. Perhaps you guys could help me out!
I'm using Android Studio and Xcode, and launching the website through WebKit and WK WebView respectively. It's super simple, just an app which calls a website into it directly. No external navigation, nothing but a full-page website. And this part is working great!
But I do have one problem! I don't want my users to get consistently logged out if they close the app, or after a few hours of not using it. I'd like it to stay logged in for them, or to automatically log-in when they use it.
The maker of the website has given me a way to do this through the URL.
Basically, my URL currently is set up like "https://URL.com/x/y/z" and it goes to the website, and that is great, but I need to set it up to be "https://url.com/x/y/z/[insert user's IMEI or UDID here]". That unique ID from their Android device will keep them logged in. I've tested it using my own device with my own IMEI and it works great, but obviously using one specific identifier for everyone will not work. I just need it to call the specific user's IMEI or UDID into the URL, to complete it.
How should I go about this?
I am assuming that you are talking about an Android app that visualizes a website in an activity. On Android, you can retrieve the device's IMEI OR MEID string by calling:
android.telephony.TelephonyManager.getDeviceId().
But be warned, this requires that you add a permission to your manifest:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
You should inform your users why you are requesting this permission.
For iOS/Xcode, you can get the device UUID via UIDevice:
// Swift 4
let uuid = UIDevice.current.identifierForVendor!.uuidString
If you are targeting iOS 11 or newer, Apple introduced Device Check to get a device specific token. I personally haven't used it, but it sounds like it's use case is similar to what you're looking for.
Update:
From your comment, here is how'd you include it in the url string.
let urlString = "url.com/x/y/z/" + uuid
I currently have code that gets the device identifier (advertising ID) on Google Play enabled and Kindle devices. Now I'm looking for documentation targeting developers that would explain how to get it on other Android forks (similar to Amazon's instructions), esp. on Xiaomi and Alibaba phones made for the local Chinese market.
One resource I could find is by AppsFlyer which is obviously bogus since it states "IMEI and Android ID - Both are necessary for accurate attribution" while the former is disabled since Android 6 (unless you want to prompt the user for a runtime permission) besides other problems with it and the latter is not device unique since Oreo.
Yes, IMEI, Mac address and Android ID are using for the Android market in China. Unity, Vungle and Admob are actually pursuing the Android market. We also heard that other ad networks create a custom Android SDK just for the Chinese market.
Last time I talked to a Chinese developer on the Android market in China was a while back so my info may be outdated. I'll double check tonight.
This isn't the answer I was hoping for, but after further research, the "first and largest independent mobile advertising platform of China", Youmi, does have an open source DeviceInfoUtils class and they do everything AppsFlyer recommended, that is, everything Google is against.
To be specific, with every request, they send: telephonyManager.getDeviceId(); (IMEI on GSM phones), telephonyManager.getSubscriberId() (IMSI on GSM phones), the MAC address, and the ANDROID_ID. Again, the first two of these require prompting the user for allowing the app to "make and manage phone calls" which is super creepy (resulting in bad app ratings and/or denied permissions). The latter two of these used to work but as of Oreo, they are not device unique any more as I mentioned in my question statement.
Update: I have now downloaded Xiaomi's Mimo SDK (ads SDK). Decompiling reveals a class called AdvertisingIdHelper which has only two methods, one to check if the device has Google Play store installed, and the other looks like this:
private static d z(Context paramContext)
{
if (!y(paramContext)) {
return null;
}
try {
d localD = new d();
Intent localIntent = new Intent("com.google.android.gms.ads.identifier.service.START");
localIntent.setPackage("com.google.android.gms");
if (paramContext.bindService(localIntent, localD, 1))
return localD;
} catch (SecurityException localSecurityException) {
com.miui.zeus.a.a.b("stacktrace_tag", "stackerror:", localSecurityException);
return null;
}
return null;
}
What its role is in the overall SDK is unclear but it definitely seems like a way of querying Google's ads ID rather than Xiaomi's alternative ID. If this is for all cases, or only for devices sold outside of China (which does have Google Play services) is again unclear.
My mobile web apps use a map link which automatically starts the mapping features of Android or iPhone by simply linking to "maps.google.com/maps?q=[something]". iOs 6 comes out, the links stop working, because Apple wants us to use "maps.APPLE.com". So now I have to specially detect iOs 6 and swap out links.
Is there a clean way to open the device/native mapping app from a mobile web app that works on Android, iOs 6, and iOs pre-6, since iOs 6 nerfed it?
Turns out ANYTHING you send to "maps.apple.com" gets forwarded to "maps.google.com"!
Both these links go to the same place
http://maps.google.com/maps?q=New+York
http://maps.apple.com/maps?q=New+York
Recently updated documentation on Apple dev site...
http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html#//apple_ref/doc/uid/TP40007894-SW1
I tried this on my iPhone and maps.apple.com does launch the new Apple Maps app (however I only typed it into the address bar). When I followed the same link on my iMac using Chrome I was redirected to maps.google.com. I believe this is intentional on Apple's part. If you are targeting iPhones with iOS 6 then you'll want to switch from google.com to apple.com. It should be seamless.
[CONFIRMED - this works on my iPhone with iOS 6.0 - I no longer have a iOS 5.x device to confirm that this redirects on a previous version of iOS. It does do the redirect in Safari, but it is broken in the iPhone Simulator]
// javascript snippet to detect ipad/iphone OS version - these are notoriously fragile, use at your own risk :)
function getOsVersion() {
var osVersion = window.navigator.userAgent.match(/(ipad|iphone);\s+cpu\s.*os\s+([_0-9]+)/i);
if (osVersion && osVersion.length === 3) {
return Number(osVersion[2].replace('_', '.'));
}
return 0;
}
In Android you can use these Intent URIs:
geo:latitude,longitude
geo:latitude,longitude?z=zoom
geo:0,0?q=my+street+address
geo:0,0?q=business+near+city
For example:
String uri = "geo:37.167629,-121.222478";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri) );
startActivity(intent);