So, I'm being able to disable the device using the AMAPI(Android Management API), but I want to let the user know why his device is being disabled, so I started looking for a way to show why the device was disabled and I found the "disabledReason" property, but it's not working, or I don't know where is displaying the reason that I set.
If you know where is displaying or how to display the disabledReason I will be very thankful.
device.setState("DISABLED");
UserFacingMessage reason = new UserFacingMessage();
reason.setDefaultMessage("Reason why your device was disabled...");
device.setDisabledReason(reason);
androidManagementClient
.enterprises()
.devices()
.patch(device.getName(), device).execute();
There is an issue when using the disabledReason field in AMAPI. There is no message displayed on the device indicating why the device is disabled, and this issue has not yet been resolved, but you can see it on your JSON response if you set a customized disabledReason.defaultMessage.
Related
I want to disable camera functionality in my app, if the device does not have a camera. However, I seem to have stumbled into a bug when doing so.
According to the official Android Developer docs, I can use hasSystemFeature() to detect device features at runtime, as shown below:
boolean hasAnyCamera = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
Log.i(LOG_TAG, "hasAnyCamera = " + hasAnyCamera);
boolean hasBackCamera = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
Log.i(LOG_TAG, "hasBackCamera = " + hasBackCamera);
However, I tried to create an emulator without a front-facing or back-facing camera, and it still returns true for both checks. Is there some other way that I can detect the camera in Android?
Relevant documentation:
Take Photos > Request the camera feature
PackageManager.hasSystemFeature()
PackageManager.FEATURE_CAMERA_ANY
PackageManager.FEATURE_CAMERA
After some research, it appears that this is a known bug, which has been unresolved for 10+ years now.
See: Emulator does not honour Camera support flag
It seems that the only know work-around is to detect the number of cameras using the Camera.getNumberOfCameras() method, which has been deprecated since Android 5.0.
boolean hasCamera = Camera.getNumberOfCameras() > 0;
Log.i(LOG_TAG, "hasCamera = " + hasCamera);
The above method seems to work on my emulator, despite the warning that it is deprecated.
Now according to the docs for Camera.getNumberOfCameras():
"The return value of [getNumberOfCameras()] might change dynamically if the device supports external cameras and an external camera is connected or disconnected."
So perhaps hasSystemFeature() always returns true, because the device might later have an external camera attached?
An emulator started by using a hardware configuration which enables or disables some features in runtime. It would be possible to add / change some configuration for your emulator.
I think, It is not removing camera hardware, just disables them. I created an emulator as you mentionned and there was no camera. When I changed the configuration I was able to use the camera. However, hasSystemFeature returned true for both situtation.
When you create an emulator, the settings you choose is written in hardware-qemu.ini for that AVD. You can find it in ~/.android/avd/YOUR_EMULATOR.avd/hardware-qemu.ini. You can get exact path in show on disk on Device Manager.
How can I print from android phone or tablet without showing the document ?
This is what i tried :
List<PrinterId> ids=new ArrayList<PrinterId>();
PrinterId id=printService.generatePrinterId(info.getNickname());
ids.add(id);
Chetan, Android would not allow to print like this. First you should find the ip in the network using, Network Service Discovery.
Please refer more from here
I'm using facebook sdk to share details to facebook and it works fine. Now my question, is there a way to set description to "What's on your mind?" text field.
Feed Dialogs (deprecated) used to have a message parameter earlier, but facebook removed. Also, there's no way to pre-populate the message in the Share Dialog.
They have removed this purposely in the UI Dialogs. If you are posting a feed using the API (not dialog), then only you can populate the message with message parameter.
The abcd text is the description of the link that you (or the link admin) have provided; but the message is related to user and in case of dialogs, facebook expects that the user himself should give any message if he wants to, it should not be app-written.
Greetings,
I am creating a Java based server to create push notifications for Apple's iOS APNs service. I have found Javapns on google code which seems to provide a simple basic framework to communicate with APNs, and which seems to be fairly wide used.
http://code.google.com/p/javapns/
However, reading Apple's docs, there is an "enhanced format" for notifications which supports "expiry" i.e. setting a time (well, in seconds) for a notification to expire if it hasn't yet been delivered. I do not see any way to set this using Javapns, and I am unsure how the APNs service handles expiry of notifications if you do not explicitly set it. So,
Does anyone know how to support the enhanced notification format of APNs specifically how to set the expiry?
Does anyone know how Apple handles notification expiry if it isn't explicitly set?
Does anyone have any suggestions that don't require me to start from scratch, as the server is currently functional as is?
Thanks in advance.
Andrew
I have recently made substantial contributions to the JavaPNS project, which lead to the release of JavaPNS 2.0 a few days ago. That version provides full support for the enhanced notification format, including the ability to set your own expiry.
Sylvain
Nice that you found the java library... to bad you didn't read the docs there.
I'll post some of the highlights below:
The existing code uses the 'Simple notification format' which does not return an error EVER.
See docs at:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html
I've tried updating to the 'Enhanced notification format' which is supposed to return an error, but I'm unable to get any errors back from the APNS. (also in the link above)
With the Enhanced format, the connection isn't being dropped immediately after sending data, but I'm not getting anything back from my socket.getInputSocket.read() call.
This issue will have to be tabled until I have more time to troubleshoot.
(Someone else commented)
Thanks a lot for looking into it.
I got the same result as yours. Maybe it has something to do with Apple Gateway.
So... you could:
1) Build your own
2) Help improve the existing library
3) Try another library like: https://github.com/notnoop/java-apns
4) Do nothing
Enhanced ios push here.
To send a notification, you can do it in three steps:
Setup the connection
ApnsService service =
APNS.newService()
.withCert("/path/to/certificate.p12", "MyCertPassword")
.withSandboxDestination()
.build();
Create and send the message
String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
String token = "fedfbcfb....";
service.push(token, payload);
To query the feedback service for inactive devices:
Map<String, Date> inactiveDevices = service.getInactiveDevices();
for (String deviceToken : inactiveDevices.keySet()) {
Date inactiveAsOf = inactiveDevices.get(deviceToken);
...
}
When I get the notifications from google at the callback URL I am unable to correlate the messages to the correct order in the database. Can I pass some identifier that would be sent back to me as a part of the callback notification? How is this done in general?
I am using the latest google-checkout-java SDK.
You should be able to use your merchant-private-data-section for this
<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">
<shopping-cart>
<merchant-private-data>
<your-ref>019b1723a2754981ed5bc24e6ac9f501</your-ref>
</merchant-private-data>
[...]
</shopping-cart>
</checkout-shopping-cart>
When you get the notification, you can read this data.
See also this question and especially this answer. I'd only note additionally that you don't have to use merchant-note (or your-ref), but can define any tags of your own as merchant-private-data is defined as a sequence of xs:any.
Hope that helps...