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
Related
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.
I am new to CQ 5 Mobile Application Development what I want to achieve is,
When a mobile device send the request to the page it captures the attributes of mobile like mobile browser, mobile browser version, mobile OS and mobile OS version.
I want to LOG this information and in later stage use this to categorize them in different Device Group and render different components in different device groups.
Note I have already went through some of these links
CQ5 Mobile Development Docs
http://www.cognifide.com/blogs/cq/adobe-cq-5-5-mobile-improvements/
http://wurfl.sourceforge.net/help_doc.php
I have tried this code which throws Null Pointer Exception, since device has null value.
Correct me if I am doing wrong somewhere
SlingHttpServletRequest slingRequest = this.request.getSlingRequest();
Device device = slingRequest.adaptTo(Device.class);
Map<String, String> deviceAttributes = device.getAttributes();
LOG.info("Request is sent from Device with OS"+deviceAttributes.get("device_os"));
Here is the way I am testing this code, whenever a request is sent to the page which has this component which logs the attributes of the mobile device from one of the emulator, I check my LOG Files that
Please help me out if I am going wrong in the code or method to get the mobile device's attributes. Please let me know if you need more details on this.
Regards,
Yash
Hi Here is the Stack Trace for this :
Caused by: org.apache.sling.api.SlingException: An exception occurred processing JSP page /apps/companyname/components/content/mobilebreadcrum/mobilebreadcrum.jsp at line 5
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspExceptionInternal(JspServletWrapper.java:571)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:496)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:448)
at org.apache.sling.scripting.jsp.JspServletWrapperAdapter.service(JspServletWrapperAdapter.java:59)
at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:173)
at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:84)
at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:388)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:358)
... 147 more Caused by: javax.el.ELException: Error reading 'modelName' on type com.companyname.www.components.content.mobilebreadcrumb.MobileBreadCrum
at javax.el.BeanELResolver.getValue(BeanELResolver.java:66)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.sling.scripting.jsp.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
at org.apache.jsp.apps.companyname.components.content.mobilebreadcrum.mobilebreadcrum_jsp._jspService(mobilebreadcrum_jsp.java:160)
at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
... 152 more Caused by: java.lang.NullPointerException
at com.companyname.www.components.content.mobilebreadcrumb.MobileBreadCrum.getModelName(MobileBreadCrum.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
... 160 more
The JSP Code is :
<%#include file="/apps/companyname/components/global.jsp"%><ct:component
className="com.companyname.www.components.content.mobilebreadcrumb.MobileBreadCrum"
name="mobilebreadcrum" />${mobilebreadcrum.modelName}
The Java Code is:
public String getModelName() {
SlingHttpServletRequest slingRequest = this.request.getSlingRequest();
String resourceType = slingRequest.getResource().getResourceType();
String resourceSuperType = slingRequest.getResource().getResourceSuperType();
LOG.info("RESOURCE TYPE:"+resourceType);
LOG.info("RESOURCE SUPER TYPE:"+resourceSuperType);
Device device = request.getCurrentPage().adaptTo(Device.class);
device.getAttributes();
return modelName;
}
Please let me know if you want anything else
Regards,
Yash
Could you please go to /system/console/adapters and make sure that there is appropriate adapter SlingHttpServletRequest → Device?
I'd start diagnosis from there. In my case corresponding row looks like this:
Adaptable Class: org.apache.sling.api.SlingHttpServletRequest
Adapter Class: com.day.cq.wcm.mobile.api.device.DeviceGroup, com.day.cq.wcm.mobile.api.device.DeviceGroupList, com.day.cq.wcm.mobile.api.device.Device
Providing bundle: com.day.cq.wcm.cq-wcm-mobile-core (190)
Thanks,
Max.
To do this u should use real device, not an emulator. To detect a device CQ looks at user-agent data in the request, so when u open a page on desktop browser u send request with not-a-mobile device user-agent data. To test this feature u can use something like user agent switcher (eg for chrome), but in that case CQ will not use and draw an emulator wrapper cause it will assume that u use a mobile device.
Now I think how to combine right user-agent and drawing an emulator on desktop. Will post by results.
thinking a step above, if you are able to fix this issue how you gonna serve requests? will you always serve requests from publish Aem server or you want to utilize Dispatcher caching?
As your code is identifying device on server side, i doubt you would be able to leverage dispatcher caching. can you think of identifying device on apache level and add selectors in request.
eg. if request if coming from iphone5, then write a rewrite rule on apache to check User agent header and add a selector
http://somesite.com/my/page/url.html to http://somesite.com/my/page/url.iphone.html
if request coming from ipad then add other selector
http://somesite.com/my/page/url.ipad.html
Dispatcher will create different cache for different selectors and will start serving pages from cache.
In your component, you can implement different views for different selector.
Its just a thought, please rethink ...
I am trying to get the Connections or user's friends info from LinkedIn using LinkedIn jar for android and example given in google code, but i wont get Connections using linkedInApiClient.getConnectionsForCurrentUser() this method call it returns null, but i can access user current profile info using linkedInApiClient.getProfileForCurrentUser()
can any body suggest me how to get User connections information in linkedIn in android. Or guide me the the wright way.
I got the solution for the above ask question, what I was doing wrong, was that we have to pass an argument of the ProfileField information we want, like this:
final Set<ProfileField> connectionFields = EnumSet.of(ProfileField.ID, ProfileField.MAIN_ADDRESS,
ProfileField.PHONE_NUMBERS, ProfileField.LOCATION,
ProfileField.LOCATION_COUNTRY, ProfileField.LOCATION_NAME,
ProfileField.FIRST_NAME, ProfileField.LAST_NAME, ProfileField.HEADLINE,
ProfileField.INDUSTRY, ProfileField.CURRENT_STATUS,
ProfileField.CURRENT_STATUS_TIMESTAMP, ProfileField.API_STANDARD_PROFILE_REQUEST,
ProfileField.EDUCATIONS, ProfileField.PUBLIC_PROFILE_URL, ProfileField.POSITIONS,
ProfileField.LOCATION, ProfileField.PICTURE_URL);
Connections connections = client.getConnectionsForCurrentUser(connectionFields);
I am developing an Android app which takes the current location of the user and displays a list of restaurants close to his/her location. The restaurants' data is available to me (i.e I do have the lat/long of each restaurant I want to display in the search results). I can't use Google Places API, because I need to show only those restaurants that are available in our database(in our website). My question is how do I access my database(or even an URL),which is on a computer, to extract the restaurants' data and display as search results in my android app?
I am actually making a Seamless ( http://bit.ly/Jp7pUN ) type application for my company.
I am a complete newbie to android app development. So, pardon me if this is really a very broad or a stupid question. Please just tell me what topics I need to study to implement this. I would study and do it myself.
Thanks.
You will need:
a Sqlite database to store the restaurants and their longitude/latitude
a MapView to display the map (Don't forget to register your Google Maps API key)
a map overlay to show the markers on the map
GPS access to get the user's location (needs the appropriate Android permission)
a simple search algorithm that retrieves a result set of restaurants within x distance of the user's location
EDIT
If your database is stored on a server, you will need a way to query the server, preferably using an HTTP-based protocol such as REST. It is useful (but not required) to cache the restaurant locations on the Android device (using Sqlite), in case the user is offline (The good news: Since you can use Java both on Android and the server, 90% of your data access layer you will only need to write once).
For the data transfer from server to the Android client, JSON is a popular format.
To acces database on your computer (not SQLite on Android) you should use url for your database server changing localhost to: 10.0.2.2. But in case your database will be on the Internet - you should create maybe some REST API to get the data you need. Then use HttpClient to fetch the data from server.
Everything that you need is in Developer Guide: MapView
And for retrieving current location I advice using MyLocationOverlay
For example (url to server):
//public static final String SERVER_ADDRESS = "http://10.0.2.2:3000"; // for localhost server
public static final String SERVER_ADDRESS = "http://railsserver.herokuapp.com"; //for remote server
Accessing data on your server - this depends on that how you implement (and using what thechnology) your server (REST API?, WebService?, Plain HTML?) and what will be the format of the response from server (JSON? XML?, etc.)
I suggest using JSON because it is easy to parse using included classes in Android SDK:
String json = execute(new HttpGet(Constants.SERVER_URL + "/fetchData"));
JSONObject responseJSON = new JSONObject(json);
if(responseJSON.has("auth_error")) {
throw new IOException("fetchData_error");
}
I'm writing a program that speaks with an external accessory over rfcomm.
My problem is that I don't know what the correct way of identifying my device is.
the way I do it now is like this:
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter
.getBondedDevices();
for (BluetoothDevice device : pairedDevices) {
if (device.getName().equals(MY_DEVICE_NAME)) {
this.myDevice = device;
break;
}
}
This method however relies on the name of the device which to me seems dirty and bad :)
is there a better way to do this?
I tried looking at all the methods of BluetoothDevice but none seemed to help - is the name really the best way to do it?
I saw that in some places people say that I should use UUIDs but that is used to open the socket to the device once I have it:
_socket = myDevice.createRfcommSocketToServiceRecord(MY_UUID);
is there a better way to do it?
Devices of the same kind/functionality and/or brand will usually have a similar name. For example, all RN-41 devices from Roving Networks have the following name:
FireFly-XXXX
where XXXX is the last 4 digits of the device's address. That means you can use the following to connect to any of them:
if (device.getName().startsWith("FireFly-")) {
this.myDevice = device;
break;
}
This is exactly what I do in my app and haven't found any more reliable/consistent way to do it. As a generalization, you should be able to use a regular pattern if the name in the devices you are interested in is any more complex than the example above.
You can use myDevice.getAddress() to get the bluetooth device address and compare, it will always be unique (unlike name)
You can also use BluetoothDevice.getBluetoothClass() for at narrowing down which devices might be relevant.
BluetoothClass.getMajorDeviceClass() will tell you roughly what kind of device it is - a phone, a computer, an audio or video device, or whatever.
BluetoothClass.hasService() further specifies some capabilities of the device.
Within each of the major classes, some minor classes are defined - what kind of computer / audio-video device / phone / health equipment etc. it is.
Also, on recent versions of the Android platform (API level 15+), you can query for the service records of a device, without having to connect to it. See BluetoothDevice.fetchUuidsWithSdp() and BluetoothDevice.getUuids().