Langsung ke konten utama

Postingan

Download file using Okio in Android

Okio is a library that complements java.io and java.nio to make it much easier to access, store, and process your data. Simply Okio is a modern I/O API for Java.  In this post, we will see how to download image or any file using Okio. Okio is component for OkHttp Coding Part Create a new project in Android Studio. Add following dependencies to your  app-level  build.gradle  file. compile 'com.squareup.okhttp3:okhttp:3.6.0' Don't forget to add the following permission in your AndroidManifest.xml <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> Implementation Paste the following code in your Activity and Here, I have kept as MainActivity.java public void downloadImg(View view) { try { Request request = new Request.Builder() .url(imageLink) .build(); new OkHttpClient().newCall(request).enqueue(new Callback() { @Override public void onFail
Postingan terbaru

Youtube Video link to mp3 file - Library

Library to Download youtube video as mp3 files Created By How to Download Gradle: compile 'com.ajts.androidmads.youtubemp3:youtubemp3:1.0.0' Maven: <dependency> <groupId>com.ajts.androidmads.youtubemp3</groupId> <artifactId>youtubemp3</artifactId> <version>1.0.0</version> <type>pom</type> </dependency> How to use this Library: This Library is used to download mp3 file from youtube video link. new YTubeMp3Service.Builder(MainActivity.this) .setDownloadUrl("https://youtu.be/nZDGC-tXCo0") .setFolderPath(new File(Environment.getExternalStorageDirectory(), "/YTMp3/Downloads").getPath()) .setOnDownloadListener(new YTubeMp3Service.Builder.DownloadListener() { @Override public void onSuccess(String savedPath) { Log.v("exce", savedPath); progressDialog.dismiss(); } @Override public void onDownloadStarted() {

SQLite Importer Exporter - Library

A light weight library for exporting and importing sqlite database in android Created By How to Download Gradle: compile 'com.ajts.androidmads.sqliteimpex:library:1.0.0' Maven: <dependency> <groupId>com.ajts.androidmads.sqliteimpex</groupId> <artifactId>library</artifactId> <version>1.0.0</version> <type>pom</type> </dependency> How to use this Library: This Library is used to import SQLite Database from Assets or External path and Export/Backup SQLite Database to external path. SQLiteImporterExporter sqLiteImporterExporter = new SQLiteImporterExporter(getApplicationContext(), db); // Listeners for Import and Export DB sqLiteImporterExporter.setOnImportListener(new SQLiteImporterExporter.ImportListener() { @Override public void onSuccess(String message) { Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); } @Override public void onFailure(Exception exception

Room Android Architecture

In Google I/O 2017, Google announced about Room Architecture for Android. This Architecture is used to maintain the State of Android Application when the orientation changes. As well as google announced about Room Architecture. Room We have more boiler plates while creating SQLite Database in Android even it is small. Room as a library used to remove the boiler plates like Cursors & Handlers and database can be handled with annotations and model classes. If we remember about Sugar ORM or Active Android , the same approach is dealt with Room.  We don't want to go for any third party libraries, when the official Android libraries give you an equal, or better solution. Life Cycle Activity We have faced the problem mostly as that  to maintain the State of Android Application when the orientation changes. The Life Cycle Activity used to handle the state easily. Coding Part Create a new project in Android Studio. First, Add Google’s maven repository to your project-level build.gradle

RecyclerView & ListView in Kotlin

In this tutorial, we will learn how to build ListView and RecyclerView with Custom Adapter in Kotlin. Everybody knows what is Listview and Recyclerview. So, without any introduction about them we will jump into the coding part of the Tutorial. Coding Part Kotlin ListView Example We should follow the same steps to create Activity with associated layout file for example MainActivity.kt with activity_main.xml Create ListView Adapter Create new class and named as MoviesListViewAdapter and paste the following. class MoviesListViewAdapter(private val activity: Activity, moviesList: List ) : BaseAdapter() { private var moviesList = ArrayList () init { this.moviesList = moviesList as ArrayList } override fun getCount(): Int { return moviesList.size } override fun getItem(i: Int): Any { return i } override fun getItemId(i: Int): Long { return i.toLong() } @SuppressLint("InflateParams", "ViewHolder")

Kotlin Android Extensions

Kotlin Android Extensions is an important Kotlin plugin that is similar to Butterknife. It will allow to recover views in android. Implementation Add the following plugins in your app level build.gradle file apply plugin:'com.android.application' apply plugin:'kotlin-android' apply plugin:'kotlin-android-extensions' Coding Part Create a new layout file in res folder, name it as activity_main.xml and paste the following codes <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:gravity="center" android:orientation="vertical" tools:context="com.androidmads.kotlinsample_helloworld.MainActivity"&g

Firebase Phone Authentication - Example

Hi Friends. In this tutorial, we will learn how to implement firebase phone authentication with it's origin. Digits is an Simple User Phone Authentication Service to create easy login experience. Now Digits is acquired by Google's Firebase and it provides free service for limited amount of authentication per month. However, if you need to sign in a very high volume of users with phone authentication, you might need to upgrade your pricing plan. See the pricing  page.  You can use Firebase Authentication to sign in a user by sending an SMS message to the user's phone. The user signs in using a one-time code contained in the SMS message. Setup Firebase To setup firebase in your project, read previous post . After setting up, open Authentication sign in method and enable phone authentication method. You should Add SHA Fingerprint in your application. To get SHA Fingerprint use the following Code with Command Prompt in Windows keytool -list -v -keystore "%USERPROFILE%\.and