Mipmaps vs. drawable folders [duplicate]

The mipmap folders are for placing your app/launcher icons (which are shown on the homescreen) in only. Any other drawable assets you use should be placed in the relevant drawable folders as before. According to this Google blogpost: It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they … Read more

What is the difference between compileSdkVersion and targetSdkVersion?

compileSdkVersion The compileSdkVersion is the version of the API the app is compiled against. This means you can use Android API features included in that version of the API (as well as all previous versions, obviously). If you try and use API 16 features but set compileSdkVersion to 15, you will get a compilation error. … Read more

How to open the Google Play Store directly from my Android application?

You can do this using the market:// prefix. Java final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(“market://details?id=” + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(“https://play.google.com/store/apps/details?id=” + appPackageName))); } Kotlin try { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(“market://details?id=$packageName”))) } catch (e: ActivityNotFoundException) { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(“https://play.google.com/store/apps/details?id=$packageName”))) } We use a … Read more

How to install Google Play Services in a Genymotion VM (with no drag and drop support)?

As of Genymotion 2.10.0 and onwards, GApps can be installed from the emulator toolbar. Please refer to answer by @MichaelStoddart. Next follows former answer kept here for historic reason: Genymotion doesn’t provide Google Apps. To install Google Apps: Upgrade Genymotion and VirtualBox to the latest version. Download two zip files: – ARM Translation Installer v1.1 … Read more

Send Email Intent

UPDATE Official approach: public void composeEmail(String[] addresses, String subject) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse(“mailto:”)); // only email apps should handle this intent.putExtra(Intent.EXTRA_EMAIL, addresses); intent.putExtra(Intent.EXTRA_SUBJECT, subject); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } } Ref link OLD ANSWER The accepted answer doesn’t work on the 4.1.2. This should work on all platforms: Intent emailIntent … Read more

RecyclerView onClick

Here is a better and less tightly coupled way to implement an OnClickListener for a RecyclerView. Snippet of usage: RecyclerView recyclerView = findViewById(R.id.recycler); recyclerView.addOnItemTouchListener( new RecyclerItemClickListener(context, recyclerView ,new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { // do whatever } @Override public void onLongItemClick(View view, int position) { // do whatever } }) … Read more

How do I align views at the bottom of the screen?

The modern way to do this is to have a ConstraintLayout and constrain the bottom of the view to the bottom of the ConstraintLayout with app:layout_constraintBottom_toBottomOf=”parent” The example below creates a FloatingActionButton that will be aligned to the end and the bottom of the screen. <android.support.constraint.ConstraintLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_height=”match_parent” android:layout_width=”match_parent”> <android.support.design.widget.FloatingActionButton android:layout_height=”wrap_content” android:layout_width=”wrap_content” app:layout_constraintBottom_toBottomOf=”parent” … Read more

Fullscreen Activity in Android?

You can do it programatically: public class ActivityName extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // remove title requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); } } Or you can do it via your AndroidManifest.xml file: <activity android:name=”.ActivityName” android:label=”@string/app_name” android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”/> Edit: If you are using AppCompatActivity then you need to add new theme <style name=”Theme.AppCompat.Light.NoActionBar.FullScreen” … Read more

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