I'm trying to hide another application by using the following code:
PackageManager pm = this.getPackageManager();
pm.setComponentEnabledSetting(new ComponentName("com.sas.remotesample",".Player"),
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.DONT_KILL_APP);
and with the following permission:
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
but it throws
java.lang.SecurityException: Permission Denial: attempt to change component state
CHANGE_COMPONENT_ENABLED_STATE has a protectionLevel of signature|privileged. This means that either:
You have to build your own custom ROM, then sign your app with the same signing key that you used to sign your custom ROM. Then, devices with your custom ROM installed will allow your app to control component states of other apps.
Your app has to be pushed to the system partition on rooted devices by their users.
Otherwise, you cannot hold this permission. Or, as the documentation for the permission states, "Not for use by third-party applications".
Related
Well, I have built an app to store values on a remote database. It works!! I didn't use an emulator for testing instead I used my own phone. Now the problem is that on my phone, it works perfectly...no issues but when I installed it on another phone, the app doesn't connect to the internet.
I have included internet permission in android manifest.xml.
I have tried these but didn't work:
Building apk and installing in the new phone.
Compiling directly to the new phone.
Sending the apk from old phone to new phone via shareit.
Creating a signed apk and installing.
Checked via wifi and mobile data (NOTE: BOTH WIFI AND MOBILE DATA WORKS IN OLD PHONE).
Checked android compatibility: supports up to android 10.
*I added error messages for try...catch blocks in form of toasts for the user to know what's the issue. and the catch exception for no internet returns connection problem. I'm getting that error message.
As I researched, I got to know that internet permission is categorized as normal permission which is not prompted to the user upon installation.
I built a second dummy app: Same issue with it... compiled directly to new phone but didn't work...it works in old phone...
Old phone: Samsung J7 Prime with Android 8.1
New Phone: Samsung J7 Pro with Android 9
Any idea or suggestion will be gladly helpful... Thank you!
in android 9 and above you have to set network Security Config
first of all in res package create xml package and in xml package create new xml resource file with network_security_config name
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
then in manifest in
android:networkSecurityConfig="#xml/network_security_config"
<uses-permission android:name="android.permission.INTERNET" />
Use debug APK instead of signed APK
please add permission on Manifest to give a permission of permission.INTERNET
Android 10 changes the permissions For device identifiers so that all device identifiers are now protected by the READ_PRIVILEGED_PHONE_STATE permission. and I cannot find a way to Use READ_PHONE_STATE permission to get all those identifiers (e.g IMEI, IMSI and Build serial) using TelephonyManager.
I tried getImei() and getDeviceId() but I am still getting Null when I Call them all. I Know there should be a way to whitelist my app or permission but I don't know how!!!
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
telephonyManager.getImei(0);
telephonyManager.getDeviceId();
That permissions is not available for 3rd party apps installed via the Play store. Only OEM apps which are bundled with the platform can have that permission. This is outlined in the Android 10 notes:
https://developer.android.com/about/versions/10/privacy/changes
Does anyone know of a way to retrieve the Device ID found under Settings -> About tablet -> System updates -> Software update settings under the Device information header in Android versions 4.x or 5.x?
Agreed with #G.hakim , but additional to that, this API requires android.permission.READ_PHONE_STATE permission.So you need to declare the permission in AndroidManifest.xml if you want to use this api:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
If i'm not wrong you are looking for your mobile phone's device id which you can get using these line of code
TelephonyManager tm = (TelephonyManager)context.GetSystemService(Context.TelephonyService);
deviceId = tm.DeviceId;
Also requires the following permission:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Also after Android Marshmallow Or API 23 you need to ask for permissions on the fly the code reference for that can be found here:
https://blog.xamarin.com/requesting-runtime-permissions-in-android-marshmallow/
Just faced this exception under my application PID in the Android Monitor, while not doing anything special. First time I'm seeing such thing, any explanation/docs? Thanks
java.lang.SecurityException: Permission Denial:
broadcast from android asks to run as user -1 but is calling from user 0;
this requires android.permission.INTERACT_ACROSS_USERS_FULL or
android.permission.INTERACT_ACROSS_USERS
One of the possible solutions is to disable auto-fill, but it works only on Android Oreo. Check this link Disabling Android O auto-fill service for an application
Iam getting this error on my log
07-06 06:22:07.419: ERROR/AndroidRuntime(2618): java.lang.SecurityException: SECURE PERMISSION: Neither user 10070 nor current process has android.permission.WRITE_SECURE_SETTINGS.
I used like this
in activity file
private static final String SECURE_SETTINGS = android.Manifest.permission.WRITE_SECURE_SETTINGS;
mContext.enforceCallingOrSelfPermission(SECURE_SETTINGS,
"BLUETOOTH_ADMIN permission");
in manifest file
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
Why does it give error?
The WRITE_SECURE_SETTINGS permission is not available to apps which aren't part of the firmware because secure settings are designed to be secured against modification by third party apps.
You can only read this settings if your phone doesn't have root access. To enable bluetooth you can use this references http://developer.android.com/guide/topics/wireless/bluetooth.html.
However, this is above sdk5... I'm not really sure if it is a good idea to use bluetooth with sdk3. I also wanted to do an app which uses bluetooth and I had to switch my target level to above 2.0.1 because bluetooth below this sdk is not supported very well.