Skip to main content

Posts

Showing posts with the label android

Ionic2 Error Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper

Recently I upgraded to latest version of ionic and started getting following error when building app for android Error: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio To solve this issue you have to perform following steps Download Gradle from https://gradle.org/install/#manually Extract the downloaded zip file somewhere (e.g. D:\gradle) Add "D:\gradle\bin" to Path in your Environment variables After performing these steps everything started working fine for me. Hope you find this helpful :)

zipalign tool not found in SDK - Eclipse

While exporting Android signed application package through Eclipse you get this warning The zipalign tool was not found in the SDK. Please update to the latest SDK and re-export your application or run zipalign manually After getting this warning I started looking for zipalign tool. After searching in SDK folder I found zipalign.exe under copy_tools folder. This folder is used by Android SDK update to keep copy of old tools. What is zipalign tool ? From Android documentation zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. How to make Eclipse find this zipalign tool To make eclipse use this zipalign.exe you have to copy it in a proper SDK folder. You can find SDK folder in %android-sdk-path% / build_tools / {sdkfolder} After copying zipalign.exe to this folder when you run Eclipse to s...

Android pull down to refresh implementation

There are many apps that allow you to refresh content by simply pulling down the list. I had a similar requirement in one of my projects. I decided to write a blog post that how easily I implemented this feature. For simplicity I will remove code of setting Adapter to ListView etc.I will only show code to detect pull down on ListView First lets see the layout of my screen <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical" >       <!-- this linear layout will contain our content which we will show -->     <!-- to user while refreshing -->     <LinearLayout android:id="@+id/layoutRefresh"         android:orientation="vertical"         android:layout_height="wrap_content"...

Android - receiving result from another activity

Its a common operation in Android application to launch new activity all the time. There are times when you want to receive the result from new activity started. For example in one of my recent projects I have to launch settings activity ( SettingsActivity ) to set the mode of application and when this activity is closed it should return the selected mode to the caller activity ( MainActivity ). How child Activity returns result Activity class has a method setResult  which sets the result code to be returned to parent activity. Another overload of setResult  allows you to pass Intent also for any extra data to be sent. In my SettingsActivity I have code like this if (settingsSavedByUser()){     Intent i=new Intent();     i.putExtra("mode","selectedApplicationMode");     setResult(RESULT_OK,i); //RESULT_OK and Intent(i) will be returned to parent }else{     setResult(RESULT_CANCELLED); //RESULT_CANCELLED will be returned to p...

Java SDK not found under Android's SDK Locations settings in Xamarin

To work with Android under Xamarin you have to set up Android SDK and JDK path under Tools->Options->Projects->SDK Locations->Android I faced a problem after setting all SDK locations it says "SDK not found" for JDK despite giving the correct path for JDK installed on my system. After few hit and trials I figured out that the problem is 64-bit version of JDK installed . Xamarin works with 32 bit JDK. So I downloaded the 32-bit version of JDK from http://download.xamarin.com/Installer/MonoForAndroid/jdk-6u39-windows-i586.exe After installing this JDK I set up the options for SDK locations and now Xamarin works fine.

Intercepting Sent and Received SMS in Android

Android API provides a very easy to way to get applications notified for phone related events such as SMS received and SMS sent. In this blog post we will learn how our app can receive these two notifications. Getting notified for Received SMS BroadcastReceiver  class allows applications to get notified for any android defined filter they want. All you have to do is to extend your class with BroadcastReceiver class and overrides its onReceive method. This method is called when Intent broadcast is received by this BroadcastReceiver. It has two parametes, first is a Context in which the receiver is running , second is the Intent which is being received. Its prototype in BroadcastReceiver class is like this public abstract void onReceive(Context context,Intent intent); So lets write our simple class whose onReceive method will be called on broadcast for any filter we are interested (in our case it is  android.provider.Telephony.SMS_RECEIVED  ). public class MyR...