Browsed by
Month: May 2018

Android how to remove new line and spaces and all html tags from String

Android how to remove new line and spaces and all html tags from String

Step 1:  compile ‘org.jsoup:jsoup:1.11.3’ add jsonup gradle and sync. Step 2 : create a method public static String html2text(String html) { return Jsoup.parse(html).text(); } Step 3 : implement this String descriptionRawText = “raw text”; String descriptionFinalText = descriptionRawText.replace(“\n”, “”).replaceAll(“\\<[^>]*>”,””).replace(“\r”, “”); String htmlConvertedText = html2text(descriptionFinalText); productDesc.setText(Html.fromHtml(String.valueOf(Html.fromHtml(htmlConvertedText)))); Done 🙂

Android Google map clustering – how to show actual marker in cluster

Android Google map clustering – how to show actual marker in cluster

1 . Create Custom Cluster renderer package com.findbitcoinatm.android.utils; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.OvalShape; import android.util.SparseArray; import android.view.ViewGroup; import com.findbitcoinatm.android.models.cluster.ATMClusterItems; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.BitmapDescriptor; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.MarkerOptions; import com.google.maps.android.clustering.Cluster; import com.google.maps.android.clustering.ClusterManager; import com.google.maps.android.clustering.view.DefaultClusterRenderer; import com.google.maps.android.ui.IconGenerator; import com.google.maps.android.ui.SquareTextView; public class MyClusterItemRenderer extends DefaultClusterRenderer<ATMClusterItems> { private final IconGenerator mIconGenerator; private final ShapeDrawable mColoredCircleBackground; private final float mDensity; private SparseArray<BitmapDescriptor> mIcons = new SparseArray(); public MyClusterItemRenderer(Context context, GoogleMap map, ClusterManager<ATMClusterItems> clusterManager) { super(context, map, clusterManager); mIconGenerator…

Read More Read More

Error:Execution failed for task ‘:app:preDebugAndroidTestBuild’. > Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

Error:Execution failed for task ‘:app:preDebugAndroidTestBuild’. > Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

Solution : compile ‘com.android.support:support-annotations:27.1.1’ to gradle(app) and sync . Solved 🙂 Example : apply plugin: ‘com.android.application’ android { compileSdkVersion 26 defaultConfig { applicationId “com.arifhasnat.islamicbooks” minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName “1.0” testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner” } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’ } } } dependencies { implementation fileTree(dir: ‘libs’, include: [‘*.jar’]) implementation ‘com.android.support:appcompat-v7:26.1.0’ implementation ‘com.android.support.constraint:constraint-layout:1.1.0’ implementation ‘com.android.support:design:26.1.0’ testImplementation ‘junit:junit:4.12’ androidTestImplementation ‘com.android.support.test:runner:1.0.2’ androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2’ compile ‘com.android.support:support-annotations:27.1.1’ compile ‘com.github.barteksc:android-pdf-viewer:2.8.2’ }

Android how to add collapsing toolbar with layout body touch collapse and expand

Android how to add collapsing toolbar with layout body touch collapse and expand

1 . <?xml version=”1.0″ encoding=”utf-8″?> <android.support.design.widget.CoordinatorLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” tools:context=”com.adn.activities.root.HomeActivity”> <android.support.design.widget.AppBarLayout android:id=”@+id/appbar_layout” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:theme=”@style/AppTheme.AppBarOverlay” > <android.support.design.widget.CollapsingToolbarLayout android:id=”@+id/collapsing_toolbar” android:layout_width=”match_parent” android:layout_height=”match_parent” app:layout_scrollFlags=”scroll|exitUntilCollapsed” app:contentScrim=”?attr/colorPrimary” app:expandedTitleMarginStart=”48dp” app:expandedTitleMarginEnd=”64dp” android:fitsSystemWindows=”true” > <LinearLayout android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”wrap_content”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”?actionBarSize” android:background=”?attr/colorPrimary” app:popupTheme=”@style/AppTheme.PopupOverlay” > <!–<ImageView–> <!–android:src=”@drawable/logo”–> <!–android:layout_width=”@dimen/count_60dp”–> <!–android:layout_height=”wrap_content” />–> </android.support.v7.widget.Toolbar> </LinearLayout> </android.support.design.widget.CollapsingToolbarLayout> <EditText android:id=”@+id/search_bar” android:background=”@drawable/corner_radious” android:layout_width=”match_parent” android:editable=”false” android:layout_height=”@dimen/count_40dp” android:paddingLeft=”@dimen/count_10dp” android:drawableLeft=”@drawable/search_gray_24″ android:hint=”Search for Products, Brands and More ” android:textSize=”@dimen/count_12dp” android:drawablePadding=”@dimen/count_10dp” android:textColorHint=”@color/dark_gray” android:textColor=”@color/dark_gray” android:layout_marginLeft=”@dimen/count_10dp” android:layout_marginRight=”@dimen/count_10dp” android:layout_marginBottom=”@dimen/count_5dp” /> </android.support.design.widget.AppBarLayout> <include layout=”@layout/content_home2″ /> </android.support.design.widget.CoordinatorLayout> 2. In content layout add…

Read More Read More

Android show collapsing toolbar layout title only when collapsed

Android show collapsing toolbar layout title only when collapsed

final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbarLayout); AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout); appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { boolean isShow = true; int scrollRange = -1; @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { if (scrollRange == -1) { scrollRange = appBarLayout.getTotalScrollRange(); } if (scrollRange + verticalOffset == 0) { collapsingToolbarLayout.setTitle(“Title”); isShow = true; } else if(isShow) { collapsingToolbarLayout.setTitle(” “); //carefull there should a space between double quote otherwise it wont work isShow = false; } } }); Source : stackoverflow

itunesconnect supported screenshoot sizes

itunesconnect supported screenshoot sizes

The following resolutions are acceptable to iTunes connect: iPhone 3+4 (3.5 Inch) 640 x 960 iPhone 5 (4 Inch) 640 x 1136 iPhone 6 (4.7 Inch) 750 x 1334 iPhone 6 Plus (5.5 Inch) 1242 x 2208 You need the screenshot in this resolution, the phone scales them down to 1080 x 1920 iPhone X 1125 x 2436 iPad (Air and Mini Retina) 1536 x 2048 iPad Pro (12.9 Inch) 2048 x 2732 Apple Watch 312 x 390 pixels (only…

Read More Read More

Android navigation/ toolbar back

Android navigation/ toolbar back

Step one : put these in oncreate method getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true);     @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_details); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } Step two : Give action to go specific page or actions @Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(fromActivity.this, toActivity.class); startActivity(intent); return super.onOptionsItemSelected(item); } @Override public void onBackPressed() { super.onBackPressed(); Intent intent = new Intent(fromActivity.this, toActivity.class); startActivity(intent); }

ERROR ITMS-90717: “Invalid App Store Icon. The App Store Icon in the asset catalog in ‘CoinAtmFinder.app’ can’t be transparent nor contain an alpha channel.”

ERROR ITMS-90717: “Invalid App Store Icon. The App Store Icon in the asset catalog in ‘CoinAtmFinder.app’ can’t be transparent nor contain an alpha channel.”

It may be causes for 2 reasons – If image is transparent or if alpha channel  .   Solution for transparent :  Simply remove transparent or convert .png image to .jpg/.jpeg format . Solution for alpha channel :   Copy and Paste the App Store icon to the desktop. Open the image. Click File Menu->Duplicate. Save it by unticking the Alpha channel. Replace the current App Store icon with this one. Validate and upload. Source : https://stackoverflow.com/questions/46585809/error-itms-90717-invalid-app-store-icon