I'm writing a app in android studio 0.8.14(latest) and I am trying to add
<uses-permission android:name="android.permission.GET_TASKS"/>
After adding the permission I clean, rebuild and make the project but I still get error:
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.SecurityException: Permission Denial: getTasks() from pid=6608, uid=10061 requires android.permission.GET_TASKS
Another peculiar thing is if I remove any of my current permissions(like "android.permission.WR") the app still runs fine like I didn't change a thing
Another permission that isn't working is REORDER_TASKS, but I think it will be fixed once the manifest applies permissions.
This permission doesn't require any special permission as per: https://android.googlesource.com/platform/frameworks/base/+/master/core/res/AndroidManifest.xml
Below is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="*package*" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme2">
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.REORDER_TASKS"/>
<uses-permission android:name="android.permission.WR" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<activity
android:name=".Activity_main"
android:label="#string/app_name"
android:launchMode="singleInstance"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Thanks.
Put your uses-permission tag outside application tag
From Documentation:
CONTAINED IN:
<manifest>
Like this.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="*package*" >
<!-- put it here -->
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.REORDER_TASKS"/>
<uses-permission android:name="android.permission.WR" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme2">
<activity
android:name=".Activity_main"
android:label="#string/app_name"
android:launchMode="singleInstance"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Related
I have an application that may or may not work with NFC. I have added these lines to manifest:
<manifest ...>
<uses-feature android:name="android.hardware.nfc" android:required="false"/>
<uses-permission android:name="android.permission.NFC" />
</manifest>
When I search for the application in google play, the message continues: "Your device is not compatible with this version"
I have verified that the NFCAdapter is not null, I have requested the pertinent permissions directly in execution ... but that message continues to come out.
APORTACION:
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.app.app">
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-feature android:name="android.hardware.nfc" android:required="false"/>
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"
tools:ignore="ProtectedPermissions" />
<application
android:name=".App"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<service
android:name=".timer.UploadService"
android:enabled="true"
android:exported="true">
</service>
<service
android:name=".services.uploaddata.ui.UploadDataService"
android:enabled="true"
android:exported="true">
</service>
<activity android:name=".main.ui.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:launchMode="singleTask"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".p1.ui.class1"
android:label="#string/title_activity_class1"
android:screenOrientation="portrait"
android:launchMode="singleTask">
</activity>
<activity
android:name=".p2.ui.class2"
android:label="#string/title_activity_class2"
android:screenOrientation="portrait"
android:theme="#style/class2ActivityTheme"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity
android:name=".p3.ui.class3"
android:theme="#style/AppTheme.ActionBar"
android:label="#string/title_activity_class3"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".p4.ui.class4"
android:label="#string/title_activity_class4"
android:theme="#style/AppTheme.ActionBar"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".p5.ui.class5"
android:label="#string/title_activity_class5"
android:screenOrientation="portrait">
</activity>
</application>
</manifest>
my problem is not a bad code. I waited for one to two days and the problem was solved. It is possible that google servers did not resolve the request well and took a little longer to update. I really do not know what the reason was but my app is already working :)
I created a custom launcher and set it to default launcher for my tablet. but when I open an application and then press Back button I will go to the last launcher(Default launcher of Samsung) although I setup my launcher as default before!
This is my launcher manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="launcher.base.app.ehsan.com.minelauncher">
<!-- To access internet -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- To auto-complete the email text field in the login form with the JSON's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<application
android:name=".tools.G"
android:allowBackup="true"
android:icon="#mipmap/logo"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/AppTheme">
<activity android:name=".activity.MainActivity">
</activity>
<activity
android:name=".activity.LoginActivity"
android:label="#string/title_activity_login"
android:theme="#android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:stateNotNeeded="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".activity.ForgetActivity"
android:screenOrientation="sensorLandscape"
>
</activity>
<activity
android:name=".activity.RecoveryActivity"
android:screenOrientation="sensorLandscape"
>
</activity>
<service
android:name=".APIService.InternetService"
android:enabled="true"
android:exported="true"/>
</application>
</manifest>
Thank you for Your answers.
I changed the manifest of my app, and now the app cannot be launched. No icon. However, when I check installed under setting Application Manager, I see it there!
Whats going on??? I have used same permissions before. I just changed which app was MAIN and launcher. Now cannot see the app. Does not come up via Studio or show up in Apps device!!!!
Update: created new app with same permissions and launches ok, so it does not really seem to be permissions ...
Installing com.mycomp.myapp
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.mycomp.myapp"
pkg: /data/local/tmp/com.myapp.
Success
09-21 13:40:43.261 454-499/? W/PackageManager﹕ verifying app can be installed or not
09-21 13:40:49.171 454-499/? W/PackageManager﹕ Unknown permission android.permission.UPDATE_DEVICE_STATE in package com.mycomp.myapp
09-21 13:40:49.171 454-499/? W/PackageManager﹕ Not granting permission android.permission.PACKAGE_USAGE_STATS to package com.mycomp.myapp (protectionLevel=18 flags=0x18be46)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycomp.myapp.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="24" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
<application
android:allowBackup="true"
android:excludeFromRecents="true"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:largeHeap="true"
android:theme="#style/AppTheme" >
<activity
android:name="com.mycomp.myapp.test.SplashScreen"
android:label="#string/app_name" >
</activity>
<receiver android:name="com.mycomp.myapp.test.BootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service
android:name="com.mycomp.myapp.test.CheckValuesSercice"
android:exported="false" />
<service`enter code here`
android:name="com.mycomp.myapp.test.TestService"
android:exported="false" />
<service
android:name="com.mycomp.myapp.test.ValuesService"
android:exported="false" />
<activity
android:name="com.mycomp.myapp.test.Guest"
android:configChanges="orientation|keyboardHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.mycomp.myapp.test.SetUsageAccessToApp"
android:configChanges="orientation|keyboardHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.mycomp.myapp.test.MainActivity"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.mycomp.myapp.test.AddItems"
android:configChanges="orientation|keyboardHidden|screenSize" >
</activity>
<activity
android:name="com.mycomp.myapp.test.TestValues"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.mycomp.myapp.test.Login"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.mycomp.myapp.test.HomeScreen"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.mycomp.myapp.test.Listings"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.mycomp.myapp.test.Authorizing"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.mycomp.myapp.test.ThemeActivity"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.mycomp.myapp.test.EditHelpMessage"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.mycomp.myapp.test.Test"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.mycomp.myapp.test.ForOther"
android:configChanges="orientation|keyboardHidden" >
</activity>
</application>
</manifest>
Here is log
Uploading file
local path: C:\projects\MyProj\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.mycomp.myapp
Installing com.mycomp.myapp
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.mycomp.myapp"
pkg: /data/local/tmp/com.mycomp.myapp
Success
So now I can see it under Setting ->Application Manager. But not under Apps on the device.
All your activities seem to be in the test directory of your project. Please check in your IDE if it does not recognise this directory as a default directory for tests (would be highlighted in green on the Project view), as it would mean that the classes will NOT be compiled into the app.
Make sure that you delete app from device properly: go to Settings -> Applications. If you find your app here then choose it and make "delete for all users" in setting menu. After that try to inslall your app again.
I have added the permission for accessing phone_state but im still getting this exception " Caused by: java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10052 nor current process has android.permission.READ_PHONE_STATE."
<?xml version="1.0" encoding="utf-8"?>
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.goh2.pronoornotepad" >
<uses-permission android:name="android.permission.read_phone_state" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/pronoorpng"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light" >
<activity
android:name=".Login"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
android:name=".MainScreen"
android:label="#string/title_activity_main_screen" >
</activity>
</application>
You must declare the permission this way:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
instead of that
<uses-permission android:name="android.permission.read_phone_state" />
im using my own launcher i take this launcher app from github https://github.com/strider2023/Black-Launcher--Android- is install launcher in phone but i also wants to add my application in launcher so when launcher install my application also install inside launcher and automatically my app start after launcher start. this is launcher manifist file below my appplication class file is MainActivity.java how do i start my application after start launcher???
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.touchmentapps.black"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15"/>
<permission
android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="normal" />
<permission
android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="normal"/>
<permission
android:name="com.android.launcher.permission.READ_SETTINGS"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="normal"/>
<permission
android:name="com.android.launcher.permission.WRITE_SETTINGS"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="normal"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.BIND_APPWIDGET" />
<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:hardwareAccelerated="true"
android:largeHeap="true">
<activity
android:name=".BlackLauncherActivity"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true"
android:windowSoftInputMode="adjustPan"
android:theme="#style/Theme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY"/>
</intent-filter>
</activity>
<activity android:name=".Activity2"/>
</application>
</manifest>
As far as i understand your question, you want to see your app displayed in the launcher ?
This is related to intent-filters : http://developer.android.com/guide/components/intents-filters.html
Black launcher looks for applications that are flagged as being "LAUNCHER" applications. As you can see in their code here : https://github.com/strider2023/Black-Launcher--Android-/blob/master/Black%20Launcher/src/com/touchmentapps/black/functions/AppInfoHandlerFunctions.java
You have to add your activity tag in your Manifest file and include the LAUNCHER category.
<activity
android:name=".MyActivity"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true"
android:windowSoftInputMode="adjustPan"
android:theme="#style/Theme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>