How to Take a Screenshot [System App Granted] - android

Application in the manifest:
android:sharedUserId="android.uid.system"
<uses-permission android:name="android.permission.INJECT_EVENTS" />
Need to get screen and analyse colors and text. How can this be done?

Related

Android TV forces app in portrait mode

I have an Android mobile app and now I'm trying to run it on Android TV emulator, but it doesn't respond to screen orientation, it is always in portrait mode even though I handled it in code (it0s working both on mobile and tablet).. This is my AndroidManifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="------">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />
<permission android:name="android.permission.REBOOT" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<application
android:name="-----"
android:allowBackup="true"
android:icon="#drawable/ic_launcher_2"
android:label="#string/app_nameMain"
android:launchMode="singleTask"
android:theme="#style/AppTheme"
tools:replace="android:label">
<activity
android:name=".activities.LauncherActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:theme="#style/App.Theme.Translucent"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.LogInActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".activities.BrowserManagerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/MyHomeCustomTheme"
android:windowSoftInputMode="adjustPan" />
</application>
I also tried adding this line of code but it's not helping:
<uses-feature
android:name="android.hardware.screen.portrait"
android:required="false" />
Did you have similar experience or do you have any ideas what's the problem here?
I think it is not about your application orientation configurations. Many Android-tv producers force the orientation as landscape. If you have access, you may check system properties and find about x.forceorientation:landscape and change it.
Some producers have also put a settings menu option such as System Settings > Display > Rotate.
Another way, this application can work on some devices
I had the same problem but with a real TV device - the system ignored rotation at all (everything worked fine on tablets and phones).
I found solution for my case but it can be inappropriate for you.
So, the short answer is "impossible" the long answer goes here:
Firmware for TV devices often tweaked by their manufacturers, in my case it was /system/framework/services.jar
that contained services\com\android\server\wm\WindowManagerService.java
in which the following code handled the rotation case:
if ("box".equals(SystemProperties.get("ro.target.product", "tablet"))) {
rotation = 0;
}
of course the /system/build.prop has setting ro.target.product=box, when I tried to patch this file (I had root and possibility to reflash firmware) the system went into the kind of boot loop. The parameter ro.target.product was used several times inside system applications so I think that final firmware in my case lacks some additional code to handle other target modes. Because of this I was forced to patch classes.dex directly in order to turn this checking off.
Another set of options that controls rotation are persist.demo.hdmirotates and persist.demo.hdmirotation, by default they were turned off. When I added them via the command line:
setprop persist.demo.hdmirotates true
setprop persist.demo.hdmirotation landscape
I got desired behavior: my application chooses necessary orientation and it works! In my case the rotation of TV depends upon cabling requirements, i.e. the relative position of TV and its corresponding socket outlet on the wall.
So, no free lunch :-( each device should be handled separately.

Android user-permissions in Manifest

I declared <user-permission android:name="android.permission.INTERNET" /> in my AndroidManifest since I thought it was the goto way of getting user-permissions.
But I got this warning : "Element user-permission not allowed here"
Via a quick google search I could not figure out what the problem or what the best practice is here.
I am using SDK 21 and up.
Change this.
<user-permission android:name="android.permission.INTERNET" /> //Not Valid
To this.
<uses-permission android:name="android.permission.INTERNET" /> //Correct One

Here Maps screen on Nokia X device shows a white screen with logo only

I have followed all steps mentioned in the porting guide for V1.
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<meta-data
android:name="com.here.android.maps.appid"
android:value="id here" />
<meta-data
android:name="com.here.android.maps.apptoken"
android:value="token here" />
<uses-library
android:name="com.google.android.maps"
android:required="false" />
<uses-library
android:name="com.here.android"
android:required="false" />
<activity
android:name=".ui.maps.HereLocationsActivity"
android:launchMode="singleTop"
android:hardwareAccelerated="true"
android:theme="#android:style/Theme.Holo"
android:screenOrientation="portrait" >
</activity>
I have added hardwareAcceleration to application tag as well.
It shows location markers properly without map tiles.
What could be the issuw. I am testing on a Nokia X device without SD card.
Any help would be appreciated.
the minSdkVersion should be also changed to be 11, you do need to set the Id & token to values reserved for you
As well as do add following permissions as well:
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.ACCESS_WIFI_STATE
Also do try zooming out, could indeed be that you are located in a area which is shown in white and having full zoom there..
Basically it should be black if the initialization fails, and it should be blue if there is no tiles (or you are at sea), white background thus would indeed be inddicating something else going wrong.
Do also make sure you have enabled location, and have working mobile internet. Would also suggest opening HERE maps app, and downlaoding the maps tiles for the same location used in the app, thus you could see that how it is supposed to look like.

Phonegap 3.1 video capture error data is null

Just upgraded from android 2.9 to 3.1 and now my video capture is not working. I am working on android right now.
I have the following plugins:
camera
file
filetranfer
geolocation
mediacapture
networkinformation
My manifest permissions looks like this:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
From what I have been testing here is what happens:
The capture video opens the video recorder, even with the timelimit I
have set.
I record the video.
It gives me the okay or close, I choose okay.
It saves the video in my gallery (oddly as mp4 instead of 3gpp
which I thought was how it saved videos).
Then instead of going to the success with the mediafile it goes to
error and tells me data is null.
Here is my code to take the video --
var options = {duration: 15};
navigator.device.capture.captureVideo(checkLogin, mediaError, options);
The error message from LogCat--
Cordova Activity Request code = 2
Web Console An error occurred: Error: data is null
Any ideas would be great and if you need more info please ask,
Thank you
My reputation is not high enough yet to simply add a comment, so I'll post this as an answer. If you're still having trouble with this you may want to look at the answer to this question - Phonegap video capture crashes
Looks like modifying the java code for Capture fixed the problem for many people.

Android Development: How to request permissions?

I was just wondering how to request permissions when creating an android application. I am a beginner, so please explain in simple terms :D.
So I want to make it so that my app can vibrate the phone at certain times, and the permission is called "android.permission.VIBRATE." But how do I request this? I do it in the Android Manifest file right?
Thanks for all help!
You're definately right. You need to put it in the AndroidManifest.XML
If you're using eclipse you can do it quite easily and without XML by opening up AndroidManifext.xml and use the Permissions tab at the bottom and press the "Add" button and selecting "Uses Permission" Then just select vibrate from the dropdown list.
If you want to do it in XML code you can add it before the application tag, like so:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:name="Application" >
(the rest of your manifest continues from here)
Also, please accept answers if you found them useful. With a 0% acceptance rate, people won't want to answer your questions.

Categories

Resources