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.
Related
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
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?
what i am doing::
I have disabled the datapackets so i don't have a internet connection
at the moment in emulator
Now i am checking whether the internet connection is available if not
availabe i am using this code below to launch the screen so that i
can enable the datapackets
code::startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
This code takes me to page::
When i click on button it shows turning wifion.... but it is not switching on no matter how long i wait
But when i close the app and go to settings manually. I can turn it on
The permissions i have used are below::
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
What is that i am doing wrong here ? how can i correct myself !
try this code.it might helps you
Intent gpsOptionsIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
startActivityForResult(gpsOptionsIntent,0);
if you are using wifiManager than you will need this permission.
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
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.
I am trying to integrate Leadbolt icon ads into an Android app. I followed the How-to guide: http://www.leadbolt.com/docs/Leadbolt_android_app_guide_v304.pdf . Here's the relevant code:
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- LeadBolt -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
The onCreate for the launcher Activity:
String leadboltIconId = Application.getInstance().getLeadboltIconId();
Log.d(TAG, "leadboltIconId: >" + leadboltIconId + "<");
AdController adController = new AdController(this, leadboltIconId, this);
adController.loadIcon();
"leadboltIconId" is filled correctly. Here is a ss of the config screen:
and the details screen:
I am using an emulator with 2.3.3 on it. It also doesn't work on my HTC Incredible with CM7 ( 2.3.3 ). There are no errors in the log. The activity implements AdListener and none of the methods are ever called.
Please change this line:
AdController adController = new AdController(this, leadboltIconId, this);
to
AdController adController = new AdController(
getApplicationContext(), leadboltIconId);
Also, please note the 3 variable is not needed when running App Icons as App icons will not trigger any event listeners. You need to use the Application Context rather than Activity for App Icons and Notifications. Activity is needed for App Ads.
I've got the same problem with the Ad Icon. I also noticed someone else posting this problem on the Leadbolt Q&A forum recently. There might be a problem with Leadbolt's side, however they fail to communicate this to us...