UserManager getUserCount() (Jelly Bean) - android

I am working on this class : UserManager
public int getUserCount ()
Return the number of users currently created on the device.
My code is:
UserManager um = (UserManager) getSystemService(USER_SERVICE);
int count = um.getUserCount();
Log.i("count",""+count);
It produce error like this:
Caused by: java.lang.SecurityException: You need MANAGE_USERS permission to: query users
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.os.IUserManager$Stub$Proxy.getUsers(IUserManager.java:321)
at android.os.UserManager.getUsers(UserManager.java:198)
at android.os.UserManager.getUserCount(UserManager.java:186)
at com.example.multiusertest.MainActivity.onCreate(MainActivity.java:52)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
I already added this permission manually in Manifest file. Does anyone know why it is produce.
Manifest File:
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.MANAGE_USERS"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.multiusertest.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

The MANAGE_USERS has a protectionlevel of signature|system, which means that the application has to be signed with the platform key. See this thread on XDA

Related

My app is working fine on my real device but it is not working on the emulator and other devices

My app is working fine on my real device but she is not working on the emulator and other devices except my device and I don't know why.
As I write the app working only on my phone and everything is good but when I try to check the app on another phone or in the emulator it doesn't work.
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.matan_gesta.gestamain">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".GestaMainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".GPS_Service"
android:enabled="true"
android:exported="true"/>
<activity
android:name=".Google_Gesta"
android:label="#string/title_activity_google__gesta"
android:theme="#style/AppTheme.NoActionBar" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="Gesta" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity
android:name=".Facebook_login"
android:label="#string/title_activity_facebook_login"
android:theme="#style/AppTheme.NoActionBar" />
</application>
the errors from the logcat:
01-19 14:02:10.777 5387-6114/? E/Gmail.LabelManager: Unable to get label ^sq_ig_i_personal for account account:21453719 01-19 14:02:10.777 5387-6114/? E/Gmail: Couldn't find label: ^sq_ig_i_personal 01-19 14:02:10.824 2003-2003/? E/BluetoothAdapter: Bluetooth binder is null 01-19 14:02:11.134 2485-6127/? E/AccountsChangedIntentOp: exception while subscribe: java.util.concurrent.TimeoutException: Waited 6000 milliseconds for awgr#2e3c018[status=PENDING] 01-19 14:02:11.420 2003-2003/? E/BluetoothAdapter: Bluetooth binder is null 01-19 14:02:11.428 1616-1628/? E/SyncManager: Job params not found for 109473 01-19 14:02:11.820 2003-2324/? E/ctxmgr: [NetworkUtil]No active synchronizable contexts. 01-19 14:02:12.557 2003-2324/? E/Auth: [GoogleAccountDataServiceImpl] getToken() -> BAD_AUTHENTICATION. Account: , App: com.google.android.gms, Service: oauth2:https://www.googleapis.com/auth/contextcontroller fbl: Long live credential not available. at fbm.b(:com.google.android.gms#11951470:10) at fbm.a(:com.google.android.gms#11951470:50) at ezw.a(:com.google.android.gms#11951470:37) at gnu.a(:com.google.android.gms#11951470:7) at gnu.a(:com.google.android.gms#11951470:155) at gmu.a(:com.google.android.gms#11951470:2) at gms.a(:com.google.android.gms#11951470:17) at gms.a(:com.google.android.gms#11951470:6) at cob.a(:com.google.android.gms#11951470:25) at cob.a(:com.google.android.gms#11951470:80) at ewz.a(:com.google.android.gms#11951470:6) at ewy.a(:com.google.android.gms#11951470:2) at ewy.e(:com.google.android.gms#11951470:6) at ewy.d(:com.google.android.gms#11951470:1) at eww.b(:com.google.android.gms#11951470:1) at mqa.a(:com.google.android.gms#11951470:1) at mon.a(:com.google.android.gms#11951470:3) at dfo.a(:com.google.android.gms#11951470:54) at dax.run(:com.google.android.gms#11951470:2) at dav.handleMessage(:com.google.android.gms#11951470:3) at muq.run(:com.google.android.gms#11951470:6) at mvc.run(:com.google.android.gms#11951470:26) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at nak.run(:com.google.android.gms#11951470) at java.lang.Thread.run(Thread.java:761) 01-19 14:02:13.117 2485-2748/? E/ProcessCheckinRequest: CheckinNowTaskTag : Checkin Succeeded: https://android.clients.google.com/checkin (request #1): 01-19 14:02:13.531 2003-2324/? E/ctxmgr: [BaseServerTask]Server task (WriteInterestRecordTask) got error statusCode=-1. com.android.volley.VolleyError: Unable to obtain auth token - is the device online? at dfo.a(:com.google.android.gms#11951470:62) at dax.run(:com.google.android.gms#11951470:2) at dav.handleMessage(:com.google.android.gms#11951470:3) at muq.run(:com.google.android.gms#11951470:6) at mvc.run(:com.google.android.gms#11951470:26) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at nak.run(:com.google.android.gms#11951470) at java.lang.Thread.run(Thread.java:761) 01-19
It will be better if you could post few more details like emulators API version and also about your real device. These kind of things can happen because of different way to provide permissions in different API versions.
You are using location reference that doesn't work on emulators.

ACRA not sending to eMail

I am trying to send crash reports to email but when my app crashes nothing happens. I tried messing around with configurations but i just kept getting errors (unknown member mostly, wth that is). Here's my code for the class.
#ReportsCrashes(
mailTo = "me#gmail.com")
public class MyApplication extends Application
{
#Override
public void onCreate() {
super.onCreate();
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
}
My manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ghostdevelopment.ueni2"
android:versionCode="1"
android:versionName="1.0"
android:debuggable="true">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="25" />
<application
android:name="MyApplication"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:label="#string/app_name"
android:name="com.ghostdevelopment.ueni2.MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="Ship Database"
android:name=".ShipInfo" />
</application>
</manifest>
According to your logcat it appears that your app has not included the ACRA library. You need to configure your build so that ACRA is included in your APK.

AdMob still not working

I got a problem regarding Google AdMob:
I try to display a Interstitial, for this I have added the AdActivity, permissions and meta-tags to manifest.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lunation.warface"
android:versionCode="10"
android:versionName="1.4" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:largeHeap="true"
android:theme="#style/AppTheme"
android:windowSoftInputMode="adjustPan|adjustResize" >
<!--This meta-data tag is required to use Google Play Services.-->
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!--Include the AdActivity configChanges and theme. -->
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="sensorPortrait"
android:windowSoftInputMode="adjustPan|adjustResize" >
<intent-filter>
</intent-filter>
</activity>
<activity
android:name=".SplashScreen"
android:noHistory="true"
android:screenOrientation="sensorPortrait"
android:theme="#style/Theme.Transparent" >
<intent-filter>
<action android:name="android.intent.action.MAIN" >
</action>
<category android:name="android.intent.category.LAUNCHER" >
</category>
</intent-filter>
</activity>
<activity android:name="gallery.FullScreenViewActivity"></activity>
</application>
</manifest>
In MainActivity:
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("xxx/xxx");
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest);
if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
Logcat:
04-04 15:15:19.397: W/Ads(19752): There was a problem getting an ad response. ErrorCode: 0
04-04 15:15:19.407: I/dalvikvm(19752): Could not find method android.webkit.WebSettings.setMixedContentMode, referenced from method com.google.android.gms.ads.internal.s.g.<init>
04-04 15:15:19.407: W/dalvikvm(19752): VFY: unable to resolve virtual method 3153: Landroid/webkit/WebSettings;.setMixedContentMode (I)V
04-04 15:15:19.407: D/dalvikvm(19752): VFY: replacing opcode 0x6e at 0x004a
04-04 15:15:19.502: W/Ads(19752): Failed to load ad: 0
Besides there is also a compilation error:
Conversion of dalvik format failed with error code 1
I tried about 20 answers, still not working.
I also dont know whether the problem is the unit id, I can change
mInterstitialAd.setAdUnitId("xxx/xxx");
to:
mInterstitialAd.setAdUnitId("xxx");
and I got the same errors.
I use the following external libraries:
android support v4&v7, picasso, ftpclient(commons, httpmime),FAB
Does somebody have a advice?
Greetings
Solution found!
Seems like some features in CyanogenMod blocks AdMob.
Flashed a new version WITHOUT Adaware and blocking Tools.
WORKING NOW :D

Permission Denied

My app is crashing when I call insert on the contentProvider class and I get a permission denied error. How do I set the permission??
01-13 23:41:15.071 467-467/system_process W/ActivityManager﹕ Permission denied: checkComponentPermission() owningUid=10065
01-13 23:41:15.071 467-467/system_process W/ActivityManager﹕ Permission Denial: opening provider net.kritico.todolist.ToDoContentProvider from ProcessRecord{a784a9c0 1669:net.kritico.kriticoads/u0a10069} (pid=1669, uid=10069) that is not exported from uid 10065
My manifest is as below
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
<!-- Used to request banner and interstitial ads. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Used to avoid sending an ad request if there is no connectivity. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="net.kritico.kriticoads.MainActivity"
android:label="#string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Activity required to show ad overlays. -->
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|
screenSize|s mallestScreenSize" />
<activity
android:name="net.kritico.kriticoads.ToDoItemActivity"
android:label="#string/title_activity_to_do_item" >
</activity>
</application>
</manifest>
You need to declare the ContentProvider to your manifest inside of your application tag. Declaring Content Provider
Also see Declaring Content Provider

java.lang.NoClassDefFoundError in android

I updated the Sherlock action bar library to new version in my project. After compiling and running logcat shows NoClassDefFoundError.
I have checked the jar versions. I have added the jars in project libs folder. I also checked order and export tab in build path. I also tried clean and build. Still i am getting NoClassDefFoundError.
My LogCat is shown below
E/AndroidRuntime(9699): java.lang.NoClassDefFoundError: com.mobiotics.tvbuddydemo.TVBuddyMainActivity
E/AndroidRuntime(9699): at com.mobiotics.tvbuddydemo.SplashScreen.onCreate(SplashScreen.java:54)
E/AndroidRuntime(9699): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(9699): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
E/AndroidRuntime(9699): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
E/AndroidRuntime(9699): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
E/AndroidRuntime(9699): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
E/AndroidRuntime(9699): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(9699): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(9699): at android.app.ActivityThread.main(ActivityThread.java:3839)
E/AndroidRuntime(9699): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(9699): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(9699): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
E/AndroidRuntime(9699): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/AndroidRuntime(9699): at dalvik.system.NativeStart.main(Native Method)
THE error line in splash screen
TVBuddyMainActivity.setSuccess(false);
i cant figure out the cause earlier working fine
My MAINFEST
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mobiotics.tvbuddydemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="15"
/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyTheme"
android:screenOrientation="portrait"
>
<activity
android:name=".SplashScreen"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TVBuddyMain"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".CustomSearch"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".PackageBuilderActivity"
android:screenOrientation="portrait"
>
</activity>
<service
android:name="com.mobiotics.tvbuddy.data.service.Droid_service"
android:exported="false" />
</application>
<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
If you are using jar file. Do not add by "java Build path". Jar file should be in libs folder. if there is not libs folder create it and please put your jar file in libs folder. Then Right click on jar file and do build path and add to build path.
thank u
com.mobiotics.tvbuddydemo.TVBuddyMainActivity is not declared in android manifest file.
you have declared android:name=".TVBuddyMain" whic is not needed.
furthermore accessing static method inside an activity is not good idea.
TVBuddyMainActivity.setSuccess(false)
pass that false value through intent.

Categories

Resources