I have a requirement in which I have to figure out if my android app is running on one of the samsung edge devices or its a regular android phone. Accordingly my ui would update. All i could gather is that the device name has a substring edge in it. Can someone suggest me a a a better way to do this ?
For samsung device's, take a look at the Samsung programming guide for Edge, in page 10 :
initialize() initializes Look. You need to initialize the Look package
before you can use it. If the device does not support Look,
SsdkUnsupportedException exception is thrown.
If an SsdkUnsupportedException exception is thrown, check the
exception message type using SsdkUnsupportedException.getType(). The
following two types of exception messages are defined in the Slook
class:
VENDOR_NOT_SUPPORTED: The device is not a Samsung device.
DEVICE_NOT_SUPPORTED: The device does not support the Look package.
So you can do this:
Slook slook = new Slook();
try {
slook.initialize(this); // it is a edge
} catch(SsdkUnsupportedException e)
{
// it is not an edge
}
Related
I am trying to create a custom FollowMe mission by sending a vehicle's GPS data on Android studio. i can send the vehicle coordinates,but the updateFollowingTarget gives a timeout error.I'm using mavic 2 zoom and dji sdk v1.14 .Did someone manage to fix this issue.
Thanks in advance.
It's a bug. It always returns timeout.
Just dont care about the error and it will work.
But it speed limited to like 15km/h so dont expect to much from it.
Edited (Do you know another function that i can use to follow a vehicle's GPS signal):
Yes, it involves more programming though.
You have to use virtualstick to control the drone. This is the only way to control the drone programmatically.
I have done it here, follows a tracker app running on a phone on my head:
https://www.youtube.com/watch?v=i3axYfIOHTY
Im working on a python api for dji. In that framework the top level code looks like below. The virtualstick calls are inside move_towards():
while True:
tracker_location = api.tracker.get_location()
drone_target_location = copy.deepcopy(tracker_location).move_to(Changeable.radius.get_value(), Changeable.bearing.get_value())
drone_location = api.drone.get_location()
course_to_tracker = drone_location.get_course(tracker_location)
heading = api.drone.smooth_heading(course_to_tracker)
drone_target_distance, drone_speed, course = api.drone.move_towards(drone_target_location, height=current_altitude, heading=heading, lowest_altitude=Changeable.lowest_altitude.get_value(), deadzone=[Changeable.dead_zone0.get_value(), Changeable.dead_zone1.get_value()], k_distance=[float(Changeable.k_dist0.get_value()), float(Changeable.k_dist1.get_value())], speed_deadzone=Changeable.speed_deadzone.get_value())
Occasionally, the instrumentation tests (Espresso) are failing on Google's Firebase Test Lab due to a keyboard on-boarding popup (screenshot) that blocks the screen and prevents tap/type events.
This only happens on the Samsung Galaxy S9+
Here is the exception:
android.support.test.espresso.PerformException: Error performing 'type text(666666)' on view '(is descendant of a: (with id: XXX) and an instance of android.widget.EditText)'.
Caused by: android.support.test.espresso.InjectEventSecurityException: java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
at android.support.test.espresso.base.InputManagerEventInjectionStrategy.injectKeyEvent(InputManagerEventInjectionStrategy.java:113)
Any suggestions?
Maybe you can try to play around with "ime" command from ADB to enable another keyboard (you can log for example the return of ime list in order to get the IDs) before running your tests (e.g. #Before):
getInstrumentation().getUiAutomation().executeShellCommand("ime enable ID");
Thread.sleep(1000);
getInstrumentation().getUiAutomation().executeShellCommand("ime set ID");
Else you can workaround with uiautomator and implement a check before using the keyboard with this kind of piece of code :
...
onView(withId(R.id.inputField)).perform(click());
if (Build.VERSION.SDK_INT >= 23) {
UiDevice device = UiDevice.getInstance(getInstrumentation());
UiObject skipButton = device.findObject(new UiSelector().text("SKIP"));
if (skipButton.exists()) {
try {
skipButton.click();
Timber.e(e, "Dismissed popup on Keyboard");
} catch (UiObjectNotFoundException e) {
Timber.e(e, "There is no popup displayed on Keyboard");
}
}
}
onView(withId(R.id.inputField)).perform(typeText("some"), pressImeActionButton());
...
Hope this help !
I also faced this problem. It's on Firebase Test Lab side, and you shouldn't try to find a workaround. Sometimes there are problems with devices you are not responsible for. Instead you should report about it to Firebase team directly if you want it to be fixed as soon as possible.
The fastest way to do it is to go to #test-lab channel of the Firebase Slack community and report them about an issue like that. They will ask you to provide your matrix ID where you experienced something wrong.
As for layout popup, it was fixed the next day it was reported, so you shouldn't see it now.
How can I differentiate between a TV and a STB/game console on AndroidTV programatically? This method (https://developer.android.com/training/tv/start/hardware) won't work because an STB running AndroidTV is considered a television.
What's Your Goal?
The obvious reason for doing this would be to determine if a device is suitable for a game to be played on. If it's for any other reason, then the purpose needs to be elaborated on in order to receive applicable assistance.
With that said ...
Since it's not possible to query the device type directly -- personally, I'd look for something that only a game console would be likely to have.
In other words: a game controller/gamepad.
public ArrayList<Integer> getGameControllerIds() {
ArrayList<Integer> gameControllerDeviceIds = new ArrayList<Integer>();
int[] deviceIds = InputDevice.getDeviceIds();
for (int deviceId : deviceIds) {
InputDevice dev = InputDevice.getDevice(deviceId);
int sources = dev.getSources();
// Verify that the device has gamepad buttons, control sticks, or both.
if (((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|| ((sources & InputDevice.SOURCE_JOYSTICK)
== InputDevice.SOURCE_JOYSTICK)) {
// This device is a game controller. Store its device ID.
if (!gameControllerDeviceIds.contains(deviceId)) {
gameControllerDeviceIds.add(deviceId);
}
}
}
return gameControllerDeviceIds;
}
Of course, it's not fool-proof. Obviously, nothing would be returned if the gamepad(s) were unplugged at the time (not sure when that would happen). Not to mention, some TVs support gamepads (Samsung comes to mind first) -- but, if you're intention is to verify that there's an adequate input available for the application, this would be ideal.
If a gamepad isn't present, a message could be displayed stating, "Please connect a gamepad." -- while continuously checking in the background, and automatically proceeding once one is detected.
Is there an API to use to determine if the device an app is running on happens to be one of the Samsung "Edge" devices? That is, a device with a rounded edge as opposed to the one with the right-angled edges. (I believe Samsung is the only one manufacturing these at the moment.)
Additionally, some of the older "Edge" devices had only one rounded edge, while the newer ones have two. Is it possible to differentiate between these cases: no rounded edges, one rounded edge, two rounded edges?
I've encounter this problem too, after reading at the SDK docs, inspect the jar, and a few try and error; This is the method I use to check Samsung Edge devices (i.e Samsung Galaxy S8/S9.) without adding SDK libraries.
internal fun isEdgeDevice(): Boolean {
var hasCocktailPanel = false
try {
val sLookImplClass = Class.forName("com.samsung.android.sdk.look.SlookImpl")
if (sLookImplClass != null) {
val isFeatureEnabledMethod =
sLookImplClass.getDeclaredMethod("isFeatureEnabled", Int::class.java)
hasCocktailPanel = isFeatureEnabledMethod.invoke(null, 7) as Boolean
}
} catch (ignored: Exception) {
}
return hasCocktailPanel
}
Explanation:
This method try to find SlookImpl class.
If it found one, then we can query the COCKTAIL_PANEL availability.
Note: Before calling isEdgeDevice() method, I will check if the Build.MANUFACTURER and Build.BRAND is "samsung", then I will proceed to check whether its edge device or not.
I'm sending notification to a wearable from a handheld and then displaying background images on cards without text. I'd like to optimize the images for round and square wearables without creating a standalone app and wearable activities.
How would I send a message to the wearable asking what size it is and if it's round or square? I know how to send messages, I'm just looking for the api to look up if it's round or square.
From the following sample, you can see how you would detect this in an activity, but I'd like to detect this in a background service since I don't want to create a standalone wearable app.
https://github.com/mauimauer/AndroidWearable-Samples/blob/8287982332b82cada7bf68a6c5aa88df1bbbcbbe/GridViewPager/Wearable/src/main/java/com/example/android/wearable/gridviewpager/MainActivity.java
My other question shows how to detect if there is a wearable paired, but it only returns node name and node id, no other useful information about the actual wearable.
How to detect if android device is paired with android wear watch
The official way to determine round vs square is to use the WatchInsets class, and the isRound() method. https://developer.android.com/reference/android/view/WindowInsets.html#isRound()
There is a sample named GridViewPager included in the Android SDK Manager for API 20 that shows how to use the isRound() method.
For the rest of your question ... you will need to implement an app that runs on the watch, that would perform this query for you. You can then send a message to the watch, it performs the query, and then send a message back to the phone, for whatever else it is you want to do.
If you look at the DataLayer sample (also in the same place as GridViewPager) it shows how to detect the connection status of the wearable to the phone.
Unofficial way - but for me it was way way easier.
https://github.com/tajchert/ShapeWear
Just copy ShapeWear.java class, and subscribe to screen shape detection event setOnShapeChangeListener() or call method ShapeWear.isRound() (can throw error is shape is not yet determined) or ShapeWear. getShape() - which can result in ShapeWear.SHAPE_UNSURE in same situation.
override this method in ur Engine class that extends CanvasWatchFaceService.Engine
#Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
Log.d(TAG, "onApplyWindowInsets");
if (insets.isRound()) {
Log.d(TAG, "Round");
} else {
Log.d(TAG, "Square");
}
}