Browsed by
Category: Tutorials

Android Fragment basic code structure

Android Fragment basic code structure

public class BasicFragment extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.basic_fragment_layout, container, false); return view; } }

Android custom date picker

Android custom date picker

Step -1 : Create a custom fragment import android.annotation.SuppressLint; import android.app.DatePickerDialog; import android.app.Dialog; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.view.View; import android.widget.DatePicker; import android.widget.EditText; import java.text.SimpleDateFormat; import java.util.Calendar; @SuppressLint(“ValidFragment”) public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { public static final String DATE_FORMAT = “dd-MM-yyyy”; EditText mView; private DatePickerDialog datepic; public DatePickerFragment(View v) { mView = (EditText) v; } Calendar c; public DatePickerFragment() { } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the…

Read More Read More

IOS Swift 3/4 show alert for specific time duration

IOS Swift 3/4 show alert for specific time duration

   let alert = UIAlertController(title: “”, message: “alert disappears after 30 seconds”, preferredStyle: .alert)             self.present(alert, animated: true, completion: nil)             // change to desired number of seconds (in this case3 0 seconds)             let when = DispatchTime.now() + 30             DispatchQueue.main.asyncAfter(deadline: when){                 // your code with delay          …

Read More Read More

Android Beautiful Spinner view without Custom adapter

Android Beautiful Spinner view without Custom adapter

To make this just bind spinner with cardview . and make it like the code bellow . now it will looks beautiful .   <android.support.v7.widget.CardView android:layout_width=”match_parent” android:layout_height=”@dimen/count_40dp” android:layout_marginLeft=”@dimen/count_5dp” android:layout_marginRight=”@dimen/count_5dp” android:layout_marginTop=”@dimen/count_10dp”> <Spinner android:id=”@+id/gender” android:layout_width=”match_parent” android:layout_height=”match_parent” /> </android.support.v7.widget.CardView>

Android Custom spinner .

Android Custom spinner .

Step -1 : Create new Adapter . public class CustomSpinnerAdapter extends BaseAdapter implements SpinnerAdapter { private final Context context; private ArrayList<String> asr; public CustomSpinnerAdapter(Context context1, ArrayList<String> asr) { this.context = context1; this.asr=asr; } public int getCount() { return asr.size(); } public Object getItem(int i) { return asr.get(i); } public long getItemId(int i) { return (long)i; } @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { TextView txt = new TextView(context); txt.setPadding(16, 16, 16, 16); txt.setTextSize(18); txt.setGravity(Gravity.CENTER_VERTICAL); txt.setText(asr.get(position)); txt.setTextColor(Color.parseColor(“#000000”)); return…

Read More Read More

Firebase: A config file was found, but it indicates a project ID “priokotha-92c0e” that you dont appear to have access to. Request access or delete the file in order to proceed with the connection process.

Firebase: A config file was found, but it indicates a project ID “priokotha-92c0e” that you dont appear to have access to. Request access or delete the file in order to proceed with the connection process.

This error will occur if you are signed in to Android Studio and the Firebase Console with different accounts. In Android Studio, click on the small profile icon in the upper right corner to see your sign-in account. Do the same for the Firebase Console tab of your browser. If they are different, sign out and sign in to make them the same.    

ERROR:’keytool’ is not recognized as an internal or external command, operable program or batch file

ERROR:’keytool’ is not recognized as an internal or external command, operable program or batch file

Step 1 : Download JDK : http://www.oracle.com/technetwork/java/javase/downloads/index.html and install it . Step 2 : Set the path on environment path . To do this My Computer – > Properties -> System variable -> Edit Path , click new and past jre bin path location . Check that the directory the keytool executable is in is on your path. (For example, on my Windows 7 machine, it’s in C:\Program Files (x86)\Java\jre6\bin.)   keytool path may be different . find the keytool…

Read More Read More

Android firebase Phone verification authentication – OTP

Android firebase Phone verification authentication – OTP

Step 1 : Go to firebase console . Go SIGN-IN METHOD and enable phone authentication option .   Step 2 : Open your build.gradle (app) and paste this firebase ui gradle and sync . Check firebase version code . It may vary . compile ‘com.firebaseui:firebase-ui-auth:3.1.0’ compile ‘com.google.android.gms:play-services-auth:11.4.2’ Step 3 : private static final int RC_SIGN_IN = 123; Step 4 : Paste this on OnCreate method . FirebaseAuth auth = FirebaseAuth.getInstance(); if (auth.getCurrentUser() != null) { AuthUI.EXTRA_DEFAULT_NATIONAL_NUMBER.toString(); // SavedData.user = auth.getCurrentUser().toString();…

Read More Read More

Error:Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Error:Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

It may causes for several reasons – I have found 2 reason and solution .  Problem 1 : If you use firebase service and it’s gradle version are older version . Or google play service , gms service are not updated version that can create this problem . Solution : Update all gradle version updated and same version for firebase . Problem 2 :  If multidex not enabled Solution :  Android Multi-dex Enable  

unable to boot device due to insufficient system resources. xcode

unable to boot device due to insufficient system resources. xcode

Problem : unable to boot device due to insufficient system resources. xcode Please see Simulator Help for information on adjusting system settings to allow more simulated devices to boot at once. maxUserProcs: 709, runningUserProcs: 614, enforcedProcBuffer: 144 Solution : Open Terminal and run the command sudo launchctl limit maxproc 2000 2500  Explanation : xCode restricts to run more device but it has 2000 max device run capability. sudo launchctl limit maxproc [limit for one user] [total limit]

Firebase for android – Insert value as a list data

Firebase for android – Insert value as a list data

Part : one – Go to firebase console and click database . If you want to insert database without authentication then go to database->rules tab and { “rules”: { “.read”: “auth == null”, “.write”: “auth == null” } } Part 2 : Create Model . I used Notes Model /** * Created by ADN Digital on 12/24/2017. */ public class Notes { public String id; public String title; public String description; public String date; public String day; public String currentDate; public…

Read More Read More

Binary Search Algorithm – Deep thinking with Java

Binary Search Algorithm – Deep thinking with Java

import java.util.Scanner;   class BinarySearch { public static void main(String args[]) { int c, first, last, middle, n, search, array[];   Scanner in = new Scanner(System.in); System.out.println(“Enter number of elements”); n = in.nextInt(); array = new int[n];   System.out.println(“Enter ” + n + ” integers”);     for (c = 0; c < n; c++) array = in.nextInt();   System.out.println(“Enter value to find”); search = in.nextInt();   first = 0; last = n – 1; middle = (first + last)/2;…

Read More Read More

Android beautiful dialog and alert libraries

Android beautiful dialog and alert libraries

1 . Lovely dialog is a nice dialog third party android library . There has some good functionality that makes it awesome .   2 . Sweet alert   is also a nice dialog and alert library . It’s also have animation that makes it beautiful .   3 .android material dialog  is now default dialog for android . It’s also simple and nice .    4.  Pretty dilog    is good for it’s nice close button . 5. No Internet Dialog   is very good for…

Read More Read More

IOS – Main Thread Checker: UI API called on a background thread: -[UIApplication delegate] PID: 902, TID: 13120, Thread name: (none), Queue name: NSOperationQueue 0x604000037a20 (QOS: UNSPECIFIED), QoS: 0 Backtrace:

IOS – Main Thread Checker: UI API called on a background thread: -[UIApplication delegate] PID: 902, TID: 13120, Thread name: (none), Queue name: NSOperationQueue 0x604000037a20 (QOS: UNSPECIFIED), QoS: 0 Backtrace:

Solution : use DispatchQueue.main.async { // Correct }     Updating UI from a Completion Handler Long-running tasks such as networking are often executed in the background, and provide a completion handler to signal completion. Attempting to read or update the UI from a completion handler may cause problems. let task = URLSession.shared.dataTask(with: url) { (data, response, error) in if let data = data { self.label.text = “\(data.count) bytes downloaded” // Error: label updated on background thread } } task.resume()…

Read More Read More

Firebase for android : Read list of data from database and show on recyclerview

Firebase for android : Read list of data from database and show on recyclerview

Part -1 : Take that we have some data field on child node named “user” . We will first retrieve all data and then we will show it on recyclerview. , public class UserListActivity extends AppCompatActivity { private DatabaseReference mDatabase; ArrayList<User> userArrayList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_list); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mDatabase = FirebaseDatabase.getInstance().getReference(); mDatabase.child(“user”).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { Toast.makeText(UserListActivity.this, snapshot.toString(), Toast.LENGTH_SHORT).show(); @Override public void onCancelled(DatabaseError databaseError) { System.out.print(databaseError.toString()); } });…

Read More Read More

Firebase for android : Part One – Project setup

Firebase for android : Part One – Project setup

First of all you can get total setup manual from here . https://firebase.google.com/docs/android/setup I am describing here step by step : Part 1 : First create an android project . If already have then no need . We need project package name . Part 2 :  Go to firebase console to create a project . You need a gmail account . https://console.firebase.google.com/ . Add new project . Give project name and enter create project . I named test-project .   Part…

Read More Read More

PhoneGap or Cordova iOS build and import to Xcode

PhoneGap or Cordova iOS build and import to Xcode

Open Terminal and go to project folder like cd: Desktop/newProject run the command on terminal cordova platform add ios  and run the command cordova build  It will create  a platform folder in the project directory and inside project directory you will find iOS . import iOS on xCode and build as same as other xCode project .    

!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master-1`. You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.

!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master-1`. You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.

Open Terminal and run this command that will add the source on master branch on cocoapod repos .   $ cd ~/.cocoapods/repos $ git clone https://github.com/CocoaPods/Specs.git master     if again issuing already has master branch and it’s not empty and completely remove cocoapod and install from new . How to uninstall cocoapod completely and install new

How to uninstall cocoapod completely and install new

How to uninstall cocoapod completely and install new

1. Uninstall CocoaPods (choose to uninstall all versions): 1 sudo gem uninstall cocoapods 2. Remove old master repo: 1 sudo rm -fr ~/.cocoapods/repos/master 3. Install CocoaPods with sudo: 1 sudo gem install cocoapods 4. Setup CocoaPods and Master repo: 1 pod setup Source i collected 

Android Encryption and Decryption String with AES/DES .

Android Encryption and Decryption String with AES/DES .

Base Class :  import android.util.Base64; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.GeneralSecurityException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; /** * Created by ADN Digital on 1/17/2018. */ public class EncryptionDecryption { public static String encrypt(String value, String key) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { byte[] value_bytes = value.getBytes(“UTF-8”); byte[] key_bytes = getKeyBytes(key); return Base64.encodeToString(encrypt(value_bytes, key_bytes, key_bytes), 0); } public static byte[] encrypt(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, byte[]…

Read More Read More

Android notify users when app version is updated on play store .

Android notify users when app version is updated on play store .

1 . First get current play store version. int currentVersion,updateVersion; VersionChecker versionChecker = new VersionChecker(); try { String latestVersion = versionChecker.execute().get(); updateVersion = Integer.parseInt(latestVersion.substring(latestVersion.length()-1)); Toast.makeText(HomeActivity.this, latestVersion.toString(), Toast.LENGTH_SHORT).show(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } PackageManager manager = this.getPackageManager(); PackageInfo info = null; try { info = manager.getPackageInfo(this.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } 2. Get current app version with PackageManager . PackageManager manager = this.getPackageManager(); PackageInfo info = null; try { info…

Read More Read More

Swift 3 / 4 get current location with location manager .

Swift 3 / 4 get current location with location manager .

Step – 1 :  First define LocationManager . And Current location of CLLocaion .   var manager = CLLocationManager() var currentLocation: CLLocation! Step 2 : In ViewDidController get Current location with location manager . That’s it .   manager.requestWhenInUseAuthorization()                  if (CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedWhenInUse ||             CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedAlways){             currentLocation = manager.location             print(“location is “, currentLocation.coordinate.latitude)…

Read More Read More

Swift 3 /4 take photo from camera or gallery and show it .

Swift 3 /4 take photo from camera or gallery and show it .

Step One : First create a project and take imageView and a button to capture image . Connect it to ViewController . Step Two : Copy this code and run . hope it will be done . 😀    class ImageCapture: UIViewController , UIImagePickerControllerDelegate,UIPopoverControllerDelegate,UINavigationControllerDelegate{      @IBOutlet var imageViewWeight: UIImageView!      var imagePicker:UIImagePickerController?=UIImagePickerController() override func viewDidLoad() {         super.viewDidLoad()          imagePicker?.delegate=self     }      @IBAction func takeImage(_ sender: Any) {       var alert…

Read More Read More

Laravel 5.5 : include css , js and image for boostrap theme .

Laravel 5.5 : include css , js and image for boostrap theme .

Put your assets in the public folder public/css public/images public/fonts public/js And then called it using Laravel   {{ URL::asset(‘js/scrollTo.js’); }} // Generates the path to public directory public/js/scrollTo.js {{ URL::asset(‘css/css.css’); }} // Generates the path to public directory public/css/css.css {{ URL::asset(‘image/one.png’); }} //Generates the path to public directory public/image/one.png or {{ HTML::script(‘js/scrollTo.js’); }} // Generates the path to public directory public/js/scrollTo.js {{ HTML::style(‘css/css.css’); }} // Generates the path to public directory public/css/css.css  {{ HTML::style(‘image/one.png’); }} //Generates the path to…

Read More Read More

Laravel – Please provide a valid cache path

Laravel – Please provide a valid cache path

In laravel sometime cache not valid problem shows . What’s the reason ? Reason is there had no cache path in the storage directory . To solve this problem , try this : create these folders under storage/framework: sessions views cache Now its worked! More         

Script php artisan clear-compiled handling the pre-update-cmd event returned with error code 255

Script php artisan clear-compiled handling the pre-update-cmd event returned with error code 255

In laravel there may be shown the following error when working with bellow laravel 5.3 projects . Cause composer structure has been changed .   So how to solve it : Its easy way to just replace the code in composer.php (Only bold sections) :   { “name”: “laravel/laravel”, “description”: “The Laravel Framework.”, “keywords”: [“framework”, “laravel”], “license”: “MIT”, “type”: “project”, “require”: { “php”: “>=5.6.4”, “laravel/framework”: “5.4.*”, “laravel/tinker”: “~1.0” }, “require-dev”: { “fzaninotto/faker”: “~1.4”, “mockery/mockery”: “0.9.*”, “phpunit/phpunit”: “~5.7” }, “autoload”: {…

Read More Read More

How to install and fix all errors after clone laravel project from github ?

How to install and fix all errors after clone laravel project from github ?

Installation Follow the instructions below to install the project Clone the repository using git clone composer install npm install Create .env by copying the env.example file php artisan key:generate php artisan migrate Set administrator info in UserTableSeeder.php // Optional php artisan db:seed run gulp or gulp watch (Install gulp (sudo npm install -g gulp) if needed) // optional

Print page and specific section with JavaScript

Print page and specific section with JavaScript

Whole Page :   If we want to print complete to print . we can do it with JavaScript Print() mehtod.   <!DOCTYPE html> <html> <body> <p>Click the button to print the current page.</p> <button onclick=”myFunction()”>Print this page</button> <script> function myFunction() { window.print(); } </script> </body> </html>     Print Specific portion : If we want to print specific portion then we need to implement some more works . Here’s are that .   <html xmlns=”http://www.w3.org/1999/xhtml”> <head>     <title></title>     <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”></script>     <script type=”text/javascript”>         $(“#btnPrint”).live(“click”, function ()…

Read More Read More

Laravel : Specified key was too long error

Laravel : Specified key was too long error

Laravel 5.4 or later  made a change to the default database character set, and it’s now utf8mb4 which includes support for storing emojis. This only affects new applications and as long as you are running MySQL v5.7.7 and higher you do not need to do anything. For those running MariaDB or older versions of MySQL you may hit this error when trying to run migrations: [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is…

Read More Read More

Recyclerview OnTouchListener Easy way

Recyclerview OnTouchListener Easy way

blogCategoryRecycler.addOnItemTouchListener(new RecyclerTouchListener(this, blogCategoryRecycler, new RecyclerTouchListener.ClickListener() { @Override public void onClick(View view, int position) { } @Override public void onLongClick(View view, int position) { } }));

IOS 10 : TableView tutorial with Swift 3 – most easy way

IOS 10 : TableView tutorial with Swift 3 – most easy way

import UIKit class ViewController: UIViewController , UITableViewDelegate , UITableViewDataSource{ var names = [“arif”,”hasnat”,”ios”,”developer”] @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self tableView.dataSource = self } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return names.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = UITableViewCell() cell.textLabel?.text = names[indexPath.row] return cell } }

Android Multi-dex Enable

Android Multi-dex Enable

aSometimes it needed to enable multidex in out add and its can throw error also . But memory limit 64 k problem may be a painful problem to solve for who faces this problem newly . But we can easily solve this problem . Just three steps – Step : 1 Add dependency at first and sync compile ‘com.android.support:multidex:+’ Step 2 : and add multidex enable inside defaultConfig multiDexEnabled true so whole build.gradle will looks like as   apply plugin:…

Read More Read More

iOS 10 tutorial : Working with collection view

iOS 10 tutorial : Working with collection view

Collection view is very good component of IOS . Its similar with table but have some basic difference . Here I will discuss with ios Collection view with easy way 🙂 So let start , Part 1 : Create a project Named Like CollectionViewDemo . Go to Main.Storyboard and add a Navigation controller – for that go to Editor menu of toolbar and select EmbededIn and click Navigation Controller . It will add a Navigation bar of the top of…

Read More Read More

Working With ionic and cordova : Part-1 Installation

Working With ionic and cordova : Part-1 Installation

Ionic is a good platform for hybrid mobile apps development , both for android and ios . There has some good stuffs and good functionality . We can make app only with HTML , CSS , And java Script framework like angular . So lets start – Step : 1 Fist of all we have to install node js of our machine . Go the node js website and download and install it . https://nodejs.org/en/ Step : 2 From this…

Read More Read More

Insertion Sort Algorithm

Insertion Sort Algorithm

Insertion Sort: Insertion sort is a simple sorting algorithm that is relatively efficient for small lists and mostly sorted lists, and is often used as part of more sophisticated algorithms. It works by taking elements from the list one by one and inserting them in their correct position into a new sorted list.[17] In arrays, the new list and the remaining elements can share the array’s space, but insertion is expensive, requiring shifting all following elements over by one. Shell…

Read More Read More

Process in Android

Process in Android

What is Process :  A process is an instance of a program running in a computer. It is close in meaning to task , a term used in some operating systems. In UNIX and some other operating systems, a process is started when a program is initiated (either by a user entering a shell command or by another program). Like a task, a process is a running program with which a particular set of data is associated so that the…

Read More Read More

Android Schedule Notifications at specific time

Android Schedule Notifications at specific time

A notification is a message you can display to the user outside of your application’s normal UI. When you tell the system to issue a notification, it first appears as an icon in the notification area. To see the details of the notification, the user opens the notification drawer. Both the notification area and the notification drawer are system-controlled areas that the user can view at any time.   I will discuss here about android schedule notification with big Image…

Read More Read More

Android Push Notification Using Firebase

Android Push Notification Using Firebase

Firebase is a very nice services of Google specially for mobile   platform . Apps developer can do many things simply . Firebase has several features including real-time database , hosting, messaging , notifications ,analytics , app-linking ,admob and so on . I will discuss here push notification using firebase including big image notification. Firebase Account and Project Creation :  Go to firebase console and login with gmail account and  press button ‘Create New Project’ Give your project Name and select country and…

Read More Read More