This is the code I'm using to try to start Bluetooth discovery. However, I always end up with the "Unable to start discovery" message (see below the code).
Device: Pixel 3 running Android 10 API 29
from grade file:
minSdkVersion 16
targetSdkVersion 30
from manifest file:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-feature android:name="android.hardware.bluetooth" />
from java:
if (bluetoothAdapter==null)
Log.i("BT", "First must enable BT");
else
{
if(bluetoothAdapter.getState()==bluetoothAdapter.STATE_ON)
{
Log.i("BT", "BT State on");
if (bluetoothAdapter.isDiscovering()) {
Log.i("BT", "was already discovering");
bluetoothAdapter.cancelDiscovery();
}
if(bluetoothAdapter.startDiscovery())
Log.i("BT", "starting discovery");
else
Log.i("BT", "Unable to start discovery");
}
else
Log.i("BT", "BT State NOT on");
}
Thanks!
So despite all permissions from the manifest, the app was declined Location servces by the system and my app wasn't even listed when I was going to the Location settings in the phone menu. I had to go to the drop down menu and enable "Show system" and then a bunch of other apps with weird names appeared, among them my app. I enabled "alwasys allow" and now BT is discovering nearby devices.
How can I request this permission at runtime then so I make sure I have permission without having to go to the Settings Menu?
Related
Creating a ToastNotification using electron-windows-notifications using the following code.
let notification = new ToastNotification({
appId: app.name,
title: "title",
template: `<toast>
<visual>
<binding template="ToastText02">
<text id="1">Incoming: %s</text>
</binding>
</visual>
<actions>
<action content="Accept" activationType="protocol" arguments="Foo://accept" />
<action content="Decline" activationType="protocol" arguments="Foo://decline" />
</actions>
</toast>`,
strings: [callerid]
})
notification.on('activated', (toast, arguments) =>
{
win.show()
win.webContents.send('call-notification-response', sip, arguments)
})
notification.show()
When the ToastNotification pops up, clicking the notifcation successfully brings the app to the foreground, but clicking either accept or decline causes the you'll need a new app to open this Foo link Windows dialog to appear but the app still processes the response successfully, which suggests that Windows is having no issue finding the app
I have attempted to use both activationType="foreground" as we as activationType="background" hoping that it would stop windows believing I am opening another app but both of these just cause the actions to not appear. I attempted to remove the app name from arguments e.g. arguments="accept" this stops the error/dialog box but also stops the app from receiving the accept command. Looked through the very minimal documentation for electron-windows-notifications as well as looking into the WinRT Documentation for ToastNotifications but still can't find anything that explains this behaviour
the app i'm working on uses a File as a target for photo capturing. this is executed externally by user selecting a camera-app using Intent(ACTION_IMAGE_CAPTURE). since upgrading build and target-sdk to 29, there have been a series of issues starting with the restriction on freely accessing files on external storage. the first change was to use one of either the application's private-cache directory, eg:
File.createTempFile("tempImage", ".jpg", context.cacheDir)
or the applications private external-storage directory:
File.createTempFile("tempImage", ".jpg", context.getExternalFilesDir(Environment.DIRECTORY_PICTURES))
in combination with FileProvider access in file_paths.xml, eg:
<paths>
<external-path name="images" path="Pictures/" /><!-- prior to SDK-29, use public external storage -->
<external-files-path name="externalImages" path="Pictures/" />
<files-path name="internalImages" path="internalImages/"/>
<cache-path name="cache" path="/" />
</paths>
these work well now after being properly configured, however implementing "Save to Gallery" functionality, eg: notifying other apps of new images is no longer working on devices running Android-10
// use FileProvider to make this new photo publicly accessible
val shareableUri = FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY, newImage)
context.sendBroadcast(
Intent(ACTION_MEDIA_SCANNER_SCAN_FILE).apply { data = uris.externalUri }
)
this approach should work but doesn't, regardless of where the original image is saved (private-app-dir, cache-dir, external-private)
MediaScannerConnection.scanFile(context, arrayOf(newImage.absolutePath), arrayOf("image/jpeg")) { path: String, uri: Uri? ->
if (uri == null) {
throw IllegalStateException("media scan failed...")
} else {
// successful
}
}
Are there are new restrictions in Android's SDK-29 which necessitate a change in MediaScanning, specifically related to the way in which a (potentially) private image file is scanned? I noticed that MediaScanner methods mostly expect a String path instead of a URI, so this leads me to think that the new restrictions won't apply to it since its a system component.
Apps targeting Android 10 (API level 29) and higher are given scoped access into an external storage device, or scoped storage, by default.
so you need to make it compatible with scopedStorage but you can use this temporary approach for now mentioned in Google Android Developers guide.
Before your app is fully compatible with scoped storage, you can temporarily opt out based on your app's target SDK level or the requestLegacyExternalStorage manifest attribute:
<manifest ... >
<!-- This attribute is "false" by default on apps targeting
Android 10 or higher. -->
<application android:requestLegacyExternalStorage="true" ... >
...
</application>
</manifest>
visit this link for more info:
https://developer.android.com/training/data-storage/files/external-scoped
I am getting an error once I load my app in Android Things on Rasperry PI, it shows a message about "Bluetooth has stopped".
This happens just after registering the GPS Driver. it does not affect the functionality and it is only at the first time.
It has already some permissions in the xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.google.android.things.permission.MANAGE_GNSS_DRIVERS" />
<uses-permission android:name="com.google.android.things.permission.USE_PERIPHERAL_IO" />
Looks like it requires to switch the port to GPS or unregister Bluetooth first... By the way I am not using bluetooth feature in the app. any idea?
thanks
if (context.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
Log.e(TAG, "No permission");
return;
}
try {
// Register the GPS driver
mGpsDriver = new NmeaGpsDriver(context, "UART0", UART_BAUD, ACCURACY);
mGpsDriver.register();
This is a known limitation of the Raspberry Pi, as per the pinout documentation:
The Raspberry Pi has pins that are multiplexed between various board functions. Some board functions cannot be used simultaneously (for example, enabling Bluetooth and using the UART0 port for peripheral I/O).
So there may be a process running in the background which is still using Bluetooth and causing the driver to crash.
I've installed an IIS server on windows 8 and plublished my first site, this is the error I get. Any help would be appreciated.
Detailed Error Information:
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x80070021
Config Error
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Config File
\?\C:\inetpub\wwwroot\ContractorScoping\web.config
Requested URL
http://localhost:80/ContractorScoping
Physical Path
C:\inetpub\wwwroot\ContractorScoping
Logon Method
Not yet determined
Logon User
Not yet determined
Config Source:
68: <validation validateIntegratedModeConfiguration="false" />
69: <modules>
70: <remove name="ApplicationInsightsWebTracking" />
Line 69 is the one highlighted in red
Schoolboy error, forgot to install asp.net on the server
This error comes due to missing IIS Packages. I solved the error with doing these steps:
Click "Start button"
in the search box, enter "Turn windows features on or off"
in the features window, Click: "Internet Information Services"
Click: "World Wide Web Services"
Click: "Application Development Features"
Check (enable) the features. I checked all but CGI.
My permissions are:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
but according to Google Play developer console, when I upload my apk, the following permissions are required by my app...
android.permission.ACCESS_NETWORK_STATE
android.permission.INTERNET
android.permission.READ_EXTERNAL_STORAGE
android.permission.WAKE_LOCK
android.permission.WRITE_EXTERNAL_STORAGE
com.android.vending.BILLING
com.google.android.c2dm.permission.RECEIVE
com.myapp.appname.permission.C2D_MESSAGE
Why are wake lock, and messaging added to my app by default? Is it because I've added facebook activity/support for sharing/liking?
This did not happen when I first used Eclipse, but now that I moved it to Android Stuido it occurs.
It doesn't appear to be documented but when you add firebase to an app, these permissions are automatically added to your app:
see https://www.reddit.com/r/androiddev/comments/4kobvm/admob_firebase_and_extra_permissions/