android


  • Powershell script to build and install an Android Flutter app

    Powershell script to build and install an Android Flutter app

    When developing an app you generally go through many cycles of testing your app on a physical device. That’s very easy with flutter. You just say one of these: possibly preceded by: to clear any cached build artifacts. Then you simply run: There’s usually no need to script this. But sometimes, you just want to…

    read more…

  • Uploading Debug Symbols

    Uploading Debug Symbols

    When uploading a new app bundle to Google Play Dev Console you can often get this warning: This App Bundle contains native code, and you’ve not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug. It can be a bit perplexing, but it’s…

    read more…

  • Add Firebase Crashlytics to Flutter

    Add Firebase Crashlytics to Flutter

    (This article is a work in progress. Keeping it here for now as reference) This was done using Flutter version 3.27. But will probably work fine with little adjustments in later versions. I’m focusing on Android, but many steps apply for iOS too. I will update the article in the future to cover more platforms.…

    read more…

  • (Android) Delay method call

    This is how you could delay a method call for a given amount of time. I’ve used this to have an alert dialog pop up a few second after starting an activity. This will fire myMethod() after 3000 miliseconds: [java] Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { myMethod(); }},…

    read more…

  • (Android) Check if Google Play Store is installed on device

    Here’s a quick way to check if Google Play Store is installed. I use this to keep activities that use in-app billing from crashing on devices that doesn’t have Google Play Store. Works fine in the emulator as well. If the method returns false, I’ll just give the user an alert telling them they need…

    read more…

  • (Android) Simple confirm dialog

    [java] private void confirmDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder .setMessage("Are you sure?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // Yes-code } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog,int id) { dialog.cancel(); } }) .show(); } [/java]

    read more…

  • (Android) Fast Android emulator

    This Android emulator is fantastic www.genymotion.com

    read more…

  • (Android) Tabbed activity with fragments tutorial

    Here is a really nice and clean tutorial for making an activity with tabs. http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/

    read more…

  • (Android) Find physical screen size programatically

    This method will find out if screen is a tablet size. You could of course make this even more corner case-compliant by getting the units dpi (dot per inch) and use the Pythagorean theorem to find the actual inch size of the diagonal. But this will probably suffice for most case. [java] private boolean isLargeScreen()…

    read more…

  • (Android) Custom view orientation change – restore state.

    Here’s one pretty simple way to get your custom view to restore its current state after an orientation change: You can of course put any values in there, for example if you need to restore fields. (quickly plotted code. Haven’t run it, but it should work) [java] @Override protected Parcelable onSaveInstanceState() { Bundle bundle =…

    read more…

  • (Android) Change background of a bitmap

    Create a new bitmap, with the size and config of the bitmap you wish to change. Create a Canvas and prepare it to paint to the new bitmap. Paint the new bitmap with your color using the canvas object. Draw the old bitmap to the new bitmap through the canvas object. Do what you want…

    read more…

  • (Android) Convert Density-independent Pixels to Pixels (dp 2 px)

      A simple function to convert dp into pixels. Use when you have to pass pixels to a method and want to keep everything to scale. [java] private int dp2px(int dp) { float scale = getResources().getDisplayMetrics().density; int pixels = (int) (dp * scale + 0.5f); return pixels; } [/java] From Android Developer Center : pxPixels –…

    read more…