Posts

Simple Notification in Android

Image
Notifications are a way to provide information to your customer which displays as a pop up on the device. It helps you to keep in touch with your customer. I am going to create a simple notification without going deep because everything is available on Google. We must understand a few concepts before going further. Notification channel:  Assume you have developed an app for an online learning center where they teach Maths and English. Students can either learn Maths, English, or Both. we must send notification related to Maths to only students who have taken Maths. In this case, we can create channels for Maths, English, and both so triggered notification will be delivered to students who have taken that subject. Each Notification channel can have a different Notification sound and different behavior that you can change from the Notification setting page. I forgot to tell you that Google has introduced the Notification channel from Android 8.0 i.e API level 26. Now yo...

Webview data directory for Android 9 (Pie)

Image
From Crashlytics report, i got to know that my app is crashing on Android 9 devices. After checking stacktrace log, it was related to data directory of webview running in multiprocess . Webview data directory store cookies, HTTP caches, and other persistent and temporary storage related to web browsing. java.lang.IllegalStateException: Can't set data directory suffix: WebView already initialized After reading Google documentation, It was clear that from android 9 webview running in multiprocess can not share same data directory so we have to make sure that webview in each process must have it’s own data directory which we can set by calling Webview.setDataDirectorySuffix(). To fix this issue, I have updated my application to check if my current process is other then my main process so i will set data directory to webview. By default, applications component run in a single  process  until and unless you run component in another  process . You can specify the pro...

Android Push Notification using FCM for Titanium

Image
In this blog, I am going to integrate the push notification in my Titanium app using the FCM module provide  by the Hans ( hansemannn)  . I have used another module for FCM but that was not working on devices running Oreo and i was looking for other modules and i came across this module and it was working fine on Oreo devices and it also provides me option to customise  the notifications also. Integrating FCM Assuming that you are familiar with Firebase cloud messaging, I am going to create a new project in the Firebase console. you can go to the Firebase console by using this URL .  you have to click on Add project to create a new Firebase project then it will open a pop up box where you can enter the details of your new app. I have entered app name  as NotificationDemo1 and you can also add Firebase to your  existing app by selecting it from the dropdown menu and you have two select the two checkboxes and clicl on create project...

Radio Button Example Android

Image
Radio buttons are used when you have multiple choices but you have to select only one. In  Android,  Radio buttons are grouped together by  android.widget.RadioGroup class.If radio buttons are inside Radio group so when one radio button is selected then all others becomes unselected. Now,I am going to make radio group "Gender " with two radio buttons "Male" &  "Female". activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="#FFFFFF"     android:orientation="vertical" >     <TextView         android:id="@+id/txtGender"         android:layout_width="wrap_content"         android:layout_height="wrap_content"       ...

SetError method in EditText box

Image
Today we are going to implement set error method for edittext.It is useful for diaplaying message if  user enters something wrong or leave it blank. MainActivity,java package com.arjun.test; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends Activity { EditText edtname; Button btncheck; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); edtname =(EditText)findViewById(R.id.edtName); btncheck = (Button)findViewById(R.id.btnCheck); btncheck.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub if(edtname.getText().length() ==0) { edtname.setError("Please fill name....

Installing app on memory card by default

Add following line in manifest file of your android app.Your app will install in memory card by default Add only this line: android:installLocation = "preferExternal" and permission <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> eg- <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.arjun.Medic" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".MedicActivity" android:label="@string/app_name" ...

Parsing JSON String in Android

Suppose i store my JSON response in string response. String response = {     "name": "John Smith",     "age": 32,     "employed": true,     "address": {         "street": "701 First Ave.",         "city": "Sunnyvale, CA 95125",         "country": "United States"     },     "children": [         {             "name": "Richard",             "age": 7         },         {             "name": "Susan",             "age": 4         },         {             "name": "James",             "age": 3         }     ] } { = This sign respresent that i...

SD Card in Android Enulator

Creating Sd card in emulator is east task.Just Follow these steps: step 1:Open your Android Virtual device manager(AVD) step 2:select your emulator step 3:Edit your emulator step 4:must specified size of your SD card 1024MB. step 5:in hardware option click new set property add SD card support: yes(value) step 6:start your emulator, in eclipse window–>showview–>other->android–>file explorer step 7->In file explorer open mnt->sdcard and using pushfile button for insert your file and image step 8:DONE