Skip to main content

Posts

How to Create Image Gallery by View Pager In Android

 In some application we have requirement of Image Gallery in which all respective images will show on single UI like Image Gallery App. In this blog we will learn about how to create Image gallery app using View Pager. before going further here is brief about View Pager: Layout manager that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter to generate the pages that the view shows. ViewPager is most often used in conjunction with android. app. So let's start making our App Step by Step. Step 1: Create activity_main.xml and   before this make 2 icons prev and next under mipmap folder. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientati...

Android Implicit Intent Examples

In Android development we often use intents to use Activity Communications and other Intent Services. As per Documentation "An Intent is a messaging object you can use to request an action from another app component ".  Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc. It is generally used with startActivity() method to invoke activity, broadcast receivers etc. The dictionary meaning of intent is intention or purpose. So, it can be described as the intention to do action. Android intents are mainly used to: Start the service Launch an activity Display a web page Display a list of contacts Broadcast a message Dial a phone call etc. There are two types of intents in android: 1) Implicit Intent: Implicit Intent doesn't specifiy the component. In such case, intent provides information of available components provided by the system that is to be invoked. For example, you may write the follo...

How to use UPI Deep Linking in Android

 In this Article we will discuss about the UPI Deep linking. By this Deep linking we can perform UPI Payments through intent .Basically it open the All UPI supported Application in our mobile then user choose their preference and initiate the Payment and through this we get the payment credentials like payment id ,transaction id ,etc. without any payment gateway. So lets start with what is UPI? Unified Payments Interface(UPI) is an instant real-time payment system developed by National Payments Corporation of India facilitating inter-bank transactions. The interface is regulated by the Reserve Bank of India and works by instantly transferring funds between two bank accounts on a mobile platform. (from Wikipedia) Coding part: package com.example.droidmedium; import android.content.Intent; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget....

How to Change Hamburger Icon in Android

 This is post for changing the Hamburger Icon in Android Programmatic ways .So lets Start with brief Introduction of Hamburger Icon in Android. Hamburger icon :  The hamburger button is a button in a graphical user interface carrying an icon consisting of three parallel horizontal lines (displayed as ☰). It is often placed in the top left or top right of a user interface and is so called for its resemblance to a hamburger icon. it will look like this in Android Apps: Lets start with Changing the Hamburger Icon Programmatic Ways.There are some steps to follow: Step 1: Setup the drawer toggle mDrawerToggle = ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close); Step 2: Set the DrawerIndicatorEnabled to false mDrawerToggle.setDrawerIndicatorEnabled(false); Step 3: Set the listener to the drawer Toggle because by above setup your hamburger button click  mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() { ...

How to use Obfuscation in Android

 Security is main concern nowadays for our app .we want to secure our apps from hackers and also want it to be more complex to understand by anyone.To achieve this we use Obfuscation in Android .So lets start with brief information about Obfuscation. What is Obfuscation: According to the Oxford dictionary, obfuscation denotes that the action of making something obscure, unclear, or unintelligible. In software, the obfuscation of code is the process of modifying an executable so that it is no longer useful to unauthorized parties such as hackers but remains fully functional. Or in other ways we can say that  To protect trade secrets, processes, unauthorized access, vulnerability discovery and bypassing licensing or other controls can be done by using obfuscation. Advantages of Using Obfuscation: 1. Optimized Code    is one of the most important feature of using Obfuscation the code become more optimized after applying Obfuscation. 2. Security   is also a feature ...

How to use Google Play Referral to get the Source

In Many Android Application you can see their is refer Scheme Play Store url of app with some value and on other device we will get referral code or we can can what is the source of url coming from .So to achieve this we have some steps to follow : for example the url is :  https://play.google.com/store/apps/details?id=com.droidmedium&referrer=DroidMedium1234 by clicking this url user redirect to Play Store and after installation we have to get the referral value    "DroidMedium1234" Step 1: Create a class Name RefererDataReceiver.java package com.droidmedium; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; public class RefererDataReciever extends BroadcastReceiver { public static f...

Solution of Image not Loaded or Auto Suggestions not working in Android Studio

Sometimes we face issue when some images are not loaded or showing in Android Studio . It shows that image not loaded try to open it externally to fix format problem .It cause when some gradle files are corrupted. also if you try auto suggestions not working in xml layout files like  you can try Invalidate Caches and Restart in Android Studio's File Menu option but you will get no result . So here are some steps to follow to remove this type of problem: Step 1: Close your Android Studio Completely. Go to your User Folder - on Windows 7/8 this would be: [SYSDRIVE]:\Users[your username] (ex. C:\Users\DroidMedium\) there you find a folder with name .AndroidStudio3.5  *( i am using Android Studio 3.5.1 version your version may be different according to your Android Studio version) open this folder now you will find two folders Go to System folder  C:\Users\DroidMedium\.AndroidStudio3.5\System\ Step 2: Now under System Folder you will find Caches folder Delete the Folder Com...

Solution of More than one file was found with OS independent path AndroidManifest.xml

After adding some jar or third party libraries sometime we face this type of problem during gradle build or at runtime .it might be because of in the mergeDebugJavaResource gradle task and on error message about multiple Android Manifests . We can assume that the problem is that there are several manifests(for example one for debug and one for production) and there are no proper manifest merging rules. sometimes it will resolve by Invalid Caches and Restart the Android Studio or by cleaning and rebuild project. But if this technique does not work than there are some solutions for this: Solution 1: downgrading your gradle plugin version from high version to low version like converting   classpath 'com.android.tools.build:gradle:3.5.1 ' to  classpath 'com.android.tools.build:gradle:3.4.0' if this solution not work here is another solution. Solution 2: in your app level gradle add these line of code  android { .... packagingOptions { exclude 'AndroidManifest.xml' ...

How to add Vibrate or Shake effect to any View

Sometimes we have to apply Shake or Vibrate effect to a view like text view or any other view for indicating user that something went wrong or wrong input.To achieve this we have some steps to follow:- For Vibrate   Step 1: Create the object for the Vibrator class private Vibrator vibrateObject; Step 2 : Block of code for vibrate the device for 300 millisecond vibrateObject = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 300 milliseconds vibrateObject.vibrate(300); Step 3: Add permission in Manifest.xml <uses-permission android : name = "android.permission.VIBRATE" /> Shake The View Or Text Step 1: Create shake_effect.xml in anim folder  <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="300" android:fromXDelta="0" android:interpolator="@anim/cycle_inter2" ...

How to Hide or Show Toolbar While Scrolling

Sometimes we have requirement for hiding the toolbar when some list is scroll .In this post we will learn how to hide when scroll down the list and show when scroll upside in Android Application.For this we have to follow some steps :- Step 1: Create a ToolBar separately for use it in an entire application with name toolbar.xml <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:titleTextColor="#FFFFFF" app:layout_scrollFlags="scroll|enterAlways" /> set this flag to toolBar app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags a...