I am trying to use Google Play services. To try the service I create an app with just one activity that have the sign in codes. I added the libraries and create my app on Google Play Console. get My Id and add it to my manifest.
But when I try to test my app I get this on logcat:
09-11 16:55:30.500 2387-5329/? E/DatabaseUtils﹕ Writing exception to parcel
java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13140)
at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
at android.os.Binder.execTransact(Binder.java:388)
at dalvik.system.NativeStart.run(Native Method)
Things I have done:
Manifest :
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id"/>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
internet permission:
<uses-permission android:name="android.permission.INTERNET"/>
grandle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.android.gms:play-services:4.4.52'
compile project(':libraries:BaseGameUtils')
}
Note: I used version 4.4.52 because the latest version is not updated on my device and it gives "this app won't work unless updating google play services" something like that. so I downgraded my lib in sdk.
Class:
public class MyActivity extends BaseGameActivity implements View.OnClickListener {
Button signOutBut;
View signInBut;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_my);
signOutBut = (Button) findViewById(R.id.sign_out_button);
setContentView(R.layout.activity_my);
signOutBut.setOnClickListener(this);
findViewById(R.id.sign_in_button).setOnClickListener(this);
checkIfOk();
}
private boolean checkIfOk() {
int checkGooglePlayServices = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (checkGooglePlayServices != ConnectionResult.SUCCESS) {
GooglePlayServicesUtil.getErrorDialog(checkGooglePlayServices, this, 1122).show();
return false;
} else {
return true;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onClick(View v) {
if(v.getId() == R.id.sign_in_button){
beginUserInitiatedSignIn();
}else {
signOut();
signOutBut.setVisibility(View.GONE);
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
}
}
@Override
public void onSignInFailed() {
Toast.makeText(getApplicationContext(), "ss", Toast.LENGTH_SHORT).show();
}
@Override
public void onSignInSucceeded() {
signOutBut.setVisibility(View.VISIBLE);
findViewById(R.id.sign_in_button).setVisibility(View.GONE);
}
}
What could be the reason for this error?