Skip to main content

Posts

Android: Check whether activity is in stack or not.

Solution There's possibility to check current tasks and their stack using ActivityManager . So, to determine if an activity is the last one: request android.permission.GET_TASKS permissions in the manifest. Use the following code: ActivityManager mngr = (ActivityManager) getSystemService( ACTIVITY_SERVICE );  List<ActivityManager.RunningTaskInfo> taskList = mngr.getRunningTasks(10); if(taskList.get(0).numActivities == 1 && taskList.get(0).topActivity.getClassName().equals(this.getClass().getName())) {             Log.i(TAG, "This is last activity in the stack");  }

Android-Studio : Error: Could not create the Java Virtual Machine

Solution: Changed below file to modify vm heap option. C:\Program Files\Android\android-studio\bin\studio.exe.vmoptions & increased -Xms128m to -Xms512m and restarted Android Studio. You should create a new environment variable named _JAVA_OPTIONS, set it to -Xms256m -Xmx1024m and it should work. Follow this steps: Run regedit Go to HKEY_CURRENT_USER Select Environment Add a new String Value and enter _JAVA_OPTIONS for Value name Enter -Xms256m -Xmx512m for Value data Reboot computer

Android Studio: Failed to complete Gradle execution

Problem: Failed to complete Gradle execution Cause:  A fatal exception has occurred. Program will exit Solution Go to File -> Settings -> Gradle Input the following in the "Gradle VM options:" box: -XX:MaxHeapSize=256m -Xmx256m Hit apply and Android Studio should build your project successfully.

Android: Place Search using Google Places API

The Google Places API allows you to query for place information on a variety of categories, such as: establishments, prominent points of interest, geographic locations, and much more. You can search for places either by proximity or a text string. A Place Search returns a list of Places along with summary information about each Place; If you want to view additional information it is extracted using Place Details query. An HTTP URL is used for search query specifying the type of Place you are searching, latitude and longitude of your location and radius.The HTTP URL should look like: https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=YourAPIKey Mandatory parameters key — Your application's API key. This key identifies your application for purposes of quota management and so that Places added from your application are made immediately available to your app. Vis...

Android: Adt doesn't create default hello world

Problem While creating project SRC and LAYOUT folder is empty. Solutions Check your Android Developer Tool build version. If it shows v22.3.0m then update your ADT version. This problem was because of New version of SDK and ADT so to update ADT please add this address: https://dl-ssl.google.com/android/eclipse/ ** Be aware it doesn't work with exciting address begin with http so go to Install New software in ADT and do these steps: Then Select this and press Next and Next and accept licence and press finish to download and install: Now after restart ADT if you create a project it will work another problem i saw was the AVD doesn't work correctly you can not add new device to solve this problem run this command from SDK path: ~/Program/android/adt/sdk/tools $ ./android avd After add your device go to ADT and open AVD from eclipse and press Refresh. It should work now.

Android: Custom Calendar Control

Caldroid   Caldroid is a fragment that display calendar with dates in a month. Caldroid can be used as embedded fragment, or as dialog fragment. User can also swipe left/right to navigate to different months. Caldroid can be used with Android 2.2 and above. For more details refer github.     Here is the output of custom calendar control. You can also set custom background with different argument. This Calendar control is also open in dialog box just add code.on button click and access the calendar in dialog box. Enjoy.

Android: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

Solution Try the following any one solution and problem will go away: 1)  Apply following steps: Close the project and reopen it. Clean the project (It will rebuild the buildpath hence reconfiguring with the JDK libraries) OR Delete and Re-import the project and if necessary do the above steps again. 2)  Apply following steps: Go to properties of project with the build error (right click > Properties) View the "Libraries" tab in the "Build Path" section Find the "JRE System Library" in the list (if this is missing then this error message is not an eclipse bug but a mis-configured project) Remove the "JRE System Library" Hit "Add Library ...", Select "JRE System Library" and add the appropriate JRE for the project (eg. 'Workspace default JRE') Hit "Finish" in the library selection and "OK" in the project properties and then wait for the re-build of the project Hopefully th...