Skip to main content

Posts

Error: Retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23

My project is going on easily but suddenly what I found below bugs when developing an app. I know it's minor bug but it may be useful to anyone. Here is the error: Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. Solution: This happens because after updates your android studio uses API 23 by default. 1) First check that your compile SDK version must match the support library's major version. If you are using version 23 of the support library, you need to compile against version 23 of the Android SDK. Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.   2) Go to your project structure -> Properties -> and change Build tool version to...

How to show only one child of expandable list at a time?

If you have "ExpandableListView" and show only one child of expandable Listview at a time, then below is the code for it. expendListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { int previousGroup = -1; @Override public void onGroupExpand(int groupPosition) { if(groupPosition != previousGroup) expendListView.collapseGroup(previousGroup); previousGroup = groupPosition; } }); "groupPosition" will return the open group id. So when I expand the other group then open group will collapse. You can also expand specific item of "ExpandableListView" by applying following code: expendListView.expandGroup(i);

Put Multiple Marker on Map? It's So Damm Easy..

If you want to put multiple marker on google map, then just follow some snip of code below and enjoy it. // Initialize variables private GoogleMap mMap; private HashMap<Marker, Integer> mHashMap = new HashMap<Marker, Integer>(); private ArrayList<My_Custom_Model_Class> myList = new ArrayList<My_Custom_Model_Class>();  // Add Multiple marker on Map for (int i = 0; i < myList.size(); i++) { double latitude = myList.getLatitude(); double longitude = myList.getLongitude(); Marker marker = mMap.addMarker(new MarkerOptions().position(new LatLng(latitude,longitude))).title(myList.getTitle()) .icon(BitmapDescriptorFactory.fromResource(R.drawable.location_icon)); mHashMap.put(marker, i); } // If you want to get particular marker click @Override public boolean onMarkerClick(Marker marker) { int pos = mHashMap.get(marker); Log.i("Position of arraylist", pos+""); }

Youtube API: Service Intent must be explicit

Whe n I am using Youtube API and open the video in my application then it shows me below error in Android L Problem java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.youtube.api.service.START } Solution: *  The new android youtube SDK as been released! No more implicit intent problem: https://developers.google.com/youtube/android/player/downloads/

Be aware while Posting photo from a native ShareDialog in Facebook android SDK

Add the content provider to your manifest. <provider  android:name="com.facebook.NativeAppCallContentProvider" android:authorities="com.facebook.app.NativeAppCallContentProvider{Facebook-App-Id}" android:exported="true" /> Make sure exported=true (as above) Example: <provider android:name="com.facebook.NativeAppCallContentProvider" android:authorities="com.facebook.app.NativeAppCallContentProvider123456" android:exported="true" />

Fragment: App loads with white screen for 3 secs before showing proper UI

Issue: 1) When my application start then white/black screen appears, and then main UI is display.  2) Before my fragment load in activity black/white screen appears for 3/4 seconds and then fragment load. Solution: To fix this nasty problem, update the /res/values/styles.xml to include <item name="android:windowDisablePreview">true</item> or <item name="android:windowBackground">@android:color/black</item> for example : <!-- Application theme. -->  <style name="AppTheme" parent="AppBaseTheme">  <!-- All customizations that are NOT specific to a particular API-level can go here. -->  <item name="android:windowDisablePreview">true</item>  <!-- <item name="android:windowBackground">@android:color/black</item> -->  </style>

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...

Meta-Data tag updates with MAP API v2

Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> If you get this type of error while launch your application which is based on Google Map V2,then update your AndroidMenifest.xml file. Solution - Google Play Services have been updated to 4.0.30 very recently and so you seem to be using that version of google-play-services_lib. Assumption based on this line: <meta-data             android:name="com.google.android.gms.version"             android:value="@integer/google_play_services_version" /> Not all devices have received an update of GooglePlayServices.APK, which needs to be...

Android: Custom PreferenceScreen

1) preferences_holder.xml <? xml version = "1.0" encoding = "utf-8" ?> <LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "fill_parent"   android:layout_height = "fill_parent" android:orientation = "vertical" > <LinearLayout   android:orientation = "horizontal"   android:background = "@color/bto_dark_green"   android:layout_width = "fill_parent" android:gravity = "center_vertical"   android:layout_height = "wrap_content" android:paddingTop = "4dip" >  <Button   android:id = "@+id/backPrefBurron"     android:layout_width = "wrap_content" android:layout_height = "wrap_content"     android:text = "Home" /> <TextView     android:id = ...

Android: To Display the system log inside your application

To display the system log inside your application, filtered for your own application-name, you could insert the following as an inner class: private static final String LogCatCommand = "logcat ActivityManager:I *:S" ; private static final String ClearLogCatCommand = "logcat -c" ; private class MonitorLogThread extends Thread{     public MonitorLogThread(){     }     BufferedReader br ;     @Override     public void run() {         try {             Process process;             process = Runtime.getRuntime().exec( ClearLogCatCommand );                 process = Runtime.getRuntime().exec( LogCatCommand );                 br = new BufferedReader ( new InputStreamReader (process.getInputStream()));     ...

Error : Plug-in com.android.ide.eclipse.adt was unable to load class com.android.ide.eclipse.adt.ToolsLocator.

Error: Plug-in com.android.ide.eclipse.adt was unable to load class com.android.ide.eclipse.adt.ToolsLocator. An error occurred while automatically activating bundle com.android.ide.eclipse.adt Solution If you have not added ADT then do the Following steps. Help -> Add New Software -> Add. In  Name  option write ADT And if you have installed ADT in your Computer then add its path in  Location  like jar:file:/D:/ADT-16.0.1.zip!/ And then ADT will install. And if there is a problem try to remove that adt and install again. remove the ADT repo (Window->Preferences->Install/Updates->Available Software Sites) add Indigo repo ("http://download.eclipse.org/releases/indigo") run updates add ADT repo again and install Restarting the application (Or) Restarting the computer. Some projects did not load.I think reinstalling ADT should do the trick. This problem is also caused by updating plugin. I have done this in the following way....

Android: Export aborted because fatal lint errors...WTF !!!....

Error * "app_name" is not translated in af, am, ar, be, bg, ca, cs, da, de, el, en-rGB, es, es-rUS, et, fa, fi, fr, hi, hr, hu, in, it, iw, ja, ko, lt, lv, ms, nb, nl, pl, pt, pt-rPT, ro, ru, sk, sl, sr, sv, sw, th, tl, tr, uk, vi, zh-rCN, zh-rTW, zu Issue: Checks for incomplete translations where not all strings are translated Id: MissingTranslation If an application has more than one locale, then all the strings declared in one language should also be translated in all other languages. If the string should not be translated, you can add the attribute translatable="false" on the element, or you can define all your non-translatable strings in a resource file called donottranslate.xml. Or, you can ignore the issue with a tools:ignore="MissingTranslation" attribute. By default this detector allows regions of a language to just provide a subset of the strings and fall back to the standard language strings. You can require all regions to prov...

Android: Google Map V2

1. Downloading Google Play Services Google made new Maps V2 API as a part of Google Play Services SDK. So before we start developing maps we need to download google play services from SDK manger. You can open SDK manager either from Eclipse or from android sdk folder. Open Eclipse ⇒ Windows ⇒ Android SDK Manager and check whether you have already downloaded Google Play Services or not under Extras section. If not select play services and install the package.  2. Importing Google Play Services into Eclipse After downloading play services we need to import it to Eclipse which will be used as a library for our maps project. 1 . In Eclipse goto File ⇒ Import ⇒ Android ⇒ Existing Android Code Into Workspace 2 . Click on Browse and select Google Play Services project from your android sdk folder. You can locate play services library project from android-sdk-windows\extras\google\google_play_services\libproject\google-play-services_lib 3 . Importantly while importin...