I want to make a simple login and register app, so the user can create an account. (name, username, password) I use WAMP and a MYSQL database where I store the accounts.
This was a bug in Android that was fixed in later versions of Marshmallow
I believe that this is Marshmallow specific. Are you using a Marshmallow device?
I've noticed this error is printed out every time I switch between applications (doesn't matter which) or exit out of them, and when activities are destroyed.
I've tried running the same apps on two Nexus 5s - one running Lollipop and the other Marshmallow, and these log prints only appeared on the Marshmallow version - with every app, not just the one I'm building.
Not sure why this happens, but I opened a report here.
It's quite strange but in my case i got this error when tried loading contacts without adding
<uses-permission android:name="android.permission.READ_CONTACTS" />
into manifest. And it disappeared just I've done it.
So my guess it's might be something with new permissions in Marshmallow.
Tested on my Nexus 5 with Android 6.0 and with targetSdkVersion 23 in build.gradle
I don't have specific problem's solution. But I had similar problem. Anyone who has problem like this please make sure you have below code.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.<YOUR_XML_FILE_NAME>);
by using intelligence you might have choose below code:
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.<YOUR_XML_FILE_NAME>);
}
This worked for me
For more info on PersistentState
Happy coding :)
Since that android changed permissions request (some permissions like android.permission.READ_PHONE_STATE or android.permission.READ_CONTACTS), when you ask for these permissions at runtime and dont add the permission tag (<uses-permission android:name="..." />) in manifest, you will get the error.
So just use tag permissions like old versions and add request permission at runtime in newer versions.
Update your android OS to 6.0.1.
This was an open issue found here. The issue is fixed in Android 6.0.1 which was publicly released recently.
I think you are finishing the context before backgrounTask finish, and Context you pass no longer exist.
You can try:
Use appContext : new BackgroundTask(Register.this.getApplicationContext());
Or, Wait for BackgroundTask finish : remove finish() after .execute(...) and add finish() onPostExecute