Skip to main content

Posts

Showing posts from May, 2014

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.