What is ‘Context’ on Android?

Putting it simply: As the name suggests, it’s the context of the current state of the application/object. It lets newly-created objects understand what has been going on. Typically you call it to get information regarding another part of your program (activity and package/application). You can get the context by invoking getApplicationContext(), getContext(), getBaseContext() or this (when in a class that extends … Read more

You need to use a Theme.AppCompat theme (or descendant) with this activity

The reason you are having this problem is because the activity you are trying to apply the dialog theme to is extending ActionBarActivity which requires the AppCompat theme to be applied. Update: Extending AppCompatActivity would also have this problem In this case, change the Java inheritance from ActionBarActivity to Activity and leave the dialog theme in the manifest as it is, a non Theme.AppCompat value The general … Read more

You need to use a Theme.AppCompat theme (or descendant) with this activity

The reason you are having this problem is because the activity you are trying to apply the dialog theme to is extending ActionBarActivity which requires the AppCompat theme to be applied. Update: Extending AppCompatActivity would also have this problem In this case, change the Java inheritance from ActionBarActivity to Activity and leave the dialog theme in the manifest as it is, a non Theme.AppCompat value The general … Read more

Find all Bluetooth devices (headsets, phones etc) nearby, without forcing the devices in discoverable mode

So, here’s all I found after reading blogs, threads, documentations, SO answers etc. regarding Android’s bluetooth discovery. Thought this might be useful to post my findings here. So before someone starts reading, I want to clarify that, I could not find any way to detect a bluetooth device nearby which is turned on but not discoverable. … Read more

Simple Android RecyclerView example

The following is a minimal example that will look like the following image. Start with an empty activity. You will perform the following tasks to add the RecyclerView. All you need to do is copy and paste the code in each section. Later you can customize it to fit your needs. Add dependencies to gradle … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)